Home » Modeling » OCL » oclIsTypeOf error with OCLinEcore
oclIsTypeOf error with OCLinEcore [message #701981] |
Mon, 25 July 2011 16:21  |
Eclipse User |
|
|
|
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 #702229 is a reply to message #701981] |
Tue, 26 July 2011 01:43   |
Eclipse User |
|
|
|
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 #702799 is a reply to message #702710] |
Tue, 26 July 2011 16:19   |
Eclipse User |
|
|
|
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 877 times)
[Updated on: Tue, 26 July 2011 16:23] by Moderator
|
|
|
Re: oclIsTypeOf error with OCLinEcore [message #703098 is a reply to message #702799] |
Wed, 27 July 2011 02:43   |
Eclipse User |
|
|
|
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 #704124 is a reply to message #703712] |
Thu, 28 July 2011 05:51   |
Eclipse User |
|
|
|
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 11:39   |
Eclipse User |
|
|
|
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: Wed Jul 09 08:26:07 EDT 2025
Powered by FUDForum. Page generated in 0.07539 seconds
|