Home » Modeling » OCL » oclIsTypeOf error with OCLinEcore
|
Re: oclIsTypeOf error with OCLinEcore [message #702229 is a reply to message #701981] |
Tue, 26 July 2011 05:43 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi
oclIsTypeOf takes a Type argument. Type Literals and Type Expressions
are ill-defined in the OCL specification and Eclipse OCL is prototyping
solutions to these problems.
self.left_member is not a type expression so your expression cannot work.
From the error message, it looks as if you're using the Helios release.
I think the Indigo release is more precise on the bad type.
In the Indigo, release oclType() has fully reflective semantics so you
could well find that
self.left_member.oclIsTypeOf(self.left_member.oclType())
works. (Did you perhaps mean oclIsKindOf which is more general?)
Regards
Ed Willink
On 25/07/2011 21:21, fafanellu wrote:
> Hi again, I use a metamodel where a class A is composed of two
> eReferences : leftMember and rightMember. Those references can be of
> some types I created, let's say : T1, T2, T3...
>
> when I test the trivial operation self.left_member=self.left_member in
> the OCLinEcore console, I get a response.
>
> when I test self.right_member.oclIsTypeOf(T1), I also get a boolean
> answer.
>
> but, when I test something like
> self.left_member.oclIsTypeOf(self.right_member) or even
> self.left_member.oclIsTypeOf(self.left_member), I am given the
> following error : Cannot find operation (oclIsTypeOf(T1)) for the type
> (T1).
>
> Is it because of my class hierarchy ? How can I solve this ? thanks
|
|
| | | |
Re: oclIsTypeOf error with OCLinEcore [message #702685 is a reply to message #702646] |
Tue, 26 July 2011 17:12 |
fafanellu Messages: 37 Registered: July 2011 |
Member |
|
|
since you told me to test with the Indigo, I installed it and imported my ecore project inside. The OCL version is 3.1.0.
this message :
Quote:Hi again,
I tried self.left_member.oclIsTypeOf(self.left_member.oclType()) but the operation oclType() seems to be unknown (moreover, it is not proposed among the others operations I get after having typed the dot...).
I get the following error :
Cannot find operation (oclType()) for the type (T1)
The purpose of what I would like to do with this is just to check that both of the members linked to class A belong to the same type, I think you have guessed it
I'm a little bit lost...how could I fix this ?
thanks
was written after having tested the code with the Indigo version
[Updated on: Tue, 26 July 2011 17:52] Report message to a moderator
|
|
| | |
Re: oclIsTypeOf error with OCLinEcore [message #702799 is a reply to message #702710] |
Tue, 26 July 2011 20:19 |
fafanellu Messages: 37 Registered: July 2011 |
Member |
|
|
Here we are, I tried to make a very simple example to explain what I want.
Type is an abstract class with two children, T1 and T2.
Expression is a class with two eReferences, left_member and right_member, which can be T1 or T2.
When I create a dynamic instance of Expression, I give it its two members (left and right). My goal is to check with OCL if both of them belong to the same type (i.e, for instance, within the Expression context, self.left_member.oclIsTyeOf(T1)=true and self.right_member.oclIsTyeOf(T1)=true)
My problem is oclIsTypeOf() operation, as I said before...
self.left_member.oclIsTyeOf(T1) does work, it evaluates the type of left_member and writes it, but I can't compare it with the right_member type...
thanks
-
Attachment: example.jpg
(Size: 57.50KB, Downloaded 756 times)
[Updated on: Tue, 26 July 2011 20:23] Report message to a moderator
|
|
|
Re: oclIsTypeOf error with OCLinEcore [message #703098 is a reply to message #702799] |
Wed, 27 July 2011 06:43 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi
If you want me to help provide something I can work with. A JPEG is
pretty but unuseable.
self.left_member.oclIsTyeOf(T1)=true and self.right_member.oclIsTyeOf(T1)=true)
clearly doesn'tr work since it has a double typo.
Regards
Ed Willink
On 26/07/2011 21:19, fafanellu wrote:
> Here we are, I tried to make a very simple example to explain what I want.
> Type is an abstract class with two children, T1 and T2.
> Expression is a class with two eReferences, left_member and right_member, which can be T1 or T2.
> When I create a dynamic instance of Expression, I give it its two members (left and right). My goal is to check with OCL if both of them belong to the same type (i.e, for instance, within the Expression context, self.left_member.oclIsTyeOf(T1)=true and self.right_member.oclIsTyeOf(T1)=true)
>
>
|
|
|
Re: oclIsTypeOf error with OCLinEcore [message #703202 is a reply to message #703098] |
Wed, 27 July 2011 09:32 |
fafanellu Messages: 37 Registered: July 2011 |
Member |
|
|
Hi,
here is what I have for my .ecore metamodel.
abstract class Type;
class T1 extends Type;
class T2 extends Type;
class Expression
{
property left_member : Type[1] { ordered composes };
property right_member : Type[1] { ordered composes };
}
I meant that when I use the oclIsTypeOf() operation in a simple context, it works. I'll try to explain it clearly :
I instanciated the Expression class using the dynamic instance creation, then I gave it a left member and a right member, I chose to give to both of them the same type : T1.
As I said above, oclIsTypeOf() operation works fine if I use it in this way :
Evaluating:
self.left_member.oclIsTypeOf(T1)
Results:
true
Evaluating:
self.right_member.oclIsTypeOf(T2)
Results:
false
Evaluating:
self.right_member.oclIsTypeOf(T1)
Results:
true
But my problem is : what if I didn't use the same type for left_member and right_member ?
How can I check directly with OCL that both of them belong to the same type ? Do I use the right operation ? My problem, I think, is about what parameters I give to oclIsTypeOf().
regards
[Updated on: Wed, 27 July 2011 12:48] Report message to a moderator
|
|
| | | | |
Re: oclIsTypeOf error with OCLinEcore [message #704124 is a reply to message #703712] |
Thu, 28 July 2011 09:51 |
fafanellu Messages: 37 Registered: July 2011 |
Member |
|
|
Well, when I start to type in the "normal" console "self.", I am proposed some things after the dot : left-member, right_member, and some OCL operations.
In the Xtext console, I am not, so I thought it didn't work.
But I've just tried to write my code "manually", and it works well !!
Thanks !!
I'm now trying to integrate it in the .ecore metamodel, as a class invariant (is this a class invariant ?).
Again, I thank you for your help
|
|
|
Re: oclIsTypeOf error with OCLinEcore [message #704416 is a reply to message #704124] |
Thu, 28 July 2011 15:39 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi
Xtext offers no completion after "." by default since the choice can be
massive. Customizing this is one of many
editor improvements that might happen for Juno. If you type "xxx.a" then
backup to the dot you do get
some completions; can't promise that they're accurate.
Regards
Ed Willink
On 28/07/2011 10:51, fafanellu wrote:
> Well, when I start to type in the "normal" console "self.", I am
> proposed some things after the dot : left-member, right_member, and
> some OCL operations.
> In the Xtext console, I am not, so I thought it didn't work.
>
> But I've just tried to write my code "manually", and it works well !! :)
>
> Thanks !!
>
> I'm now trying to integrate it in the .ecore metamodel, as a class
> invariant (is this a class invariant ?).
>
> Again, I thank you for your help :)
|
|
| |
Goto Forum:
Current Time: Fri Apr 19 11:28:50 GMT 2024
Powered by FUDForum. Page generated in 0.02238 seconds
|