Extend EcoreEnvironment locally [message #917816] |
Thu, 20 September 2012 09:04  |
Eclipse User |
|
|
|
Hello,
there is an opportunity to extend the EcoreEnvironment by using for
example the "defineOperation" method. I did this for example to extend
the OCLEnvironment by the operation "getValue()" of a EFeatureMapEntry.
But when I tried to evaluate this operation I got a NullPointerException
caused by line 227 in the class EcoreEvaluationEnvironment.
I think this occurrs because of a mistake in line 206.
When an operation is added to the Environment a so called "ShadowClass"
with the added EOperation will be created. But in the shadow class no
information about the correct InstanceClass is stored.
To get this information I changed line 206 to:
EClassifier container = OCLStandardLibraryImpl.getOwner(operation);
Am I right, is this a mistake?
Best regards,
Lilija Klassen
|
|
|
|
Re: Extend EcoreEnvironment locally [message #918635 is a reply to message #918056] |
Fri, 21 September 2012 03:32   |
Eclipse User |
|
|
|
Hey,
Oh yes, sorry for that I use version 3.1.0, but its also the same line
in version 3.2.0.
class EcoreEvaluationEnvironment, method getJavaMethodFor,
line 206: EClass container = operation.getEContainingClass();
Regards
Lilija Klassen
Am 20.09.2012 19:43, schrieb Ed Willink:
> Hi
>
> You give no clue about which version you use.
>
> For me line 206 is a blank line.
>
> Regards
>
> Ed Willink
>
>
>
> On 20/09/2012 14:04, Lilija Klassen wrote:
>> Hello,
>>
>> there is an opportunity to extend the EcoreEnvironment by using for
>> example the "defineOperation" method. I did this for example to extend
>> the OCLEnvironment by the operation "getValue()" of a EFeatureMapEntry.
>>
>> But when I tried to evaluate this operation I got a
>> NullPointerException caused by line 227 in the class
>> EcoreEvaluationEnvironment.
>> I think this occurrs because of a mistake in line 206.
>>
>> When an operation is added to the Environment a so called
>> "ShadowClass" with the added EOperation will be created. But in the
>> shadow class no information about the correct InstanceClass is stored.
>>
>> To get this information I changed line 206 to:
>> EClassifier container = OCLStandardLibraryImpl.getOwner(operation);
>>
>> Am I right, is this a mistake?
>>
>> Best regards,
>>
>> Lilija Klassen
>>
>
|
|
|
Re: Extend EcoreEnvironment locally [message #918863 is a reply to message #917816] |
Fri, 21 September 2012 08:19  |
Eclipse User |
|
|
|
Hi
ShadowClasses are a necessary evil when using an underlying meta-model
representation that does not allow DataTypes to have Operations. (The
Pivot model for new Eclipse OCL code does not have this restriction.)
The existing tests of defineOperation seem to ge only for Classes.
Your (remarkably obvious) example for an EDataType fails as you observe.
Your change seems to do no damage (apart from a small execution cost) so
I've raised https://bugs.eclipse.org/bugs/show_bug.cgi?id=390094 to
incorporate it.
Thanks.
Regards
Ed Willink
On 20/09/2012 14:04, Lilija Klassen wrote:
> Hello,
>
> there is an opportunity to extend the EcoreEnvironment by using for
> example the "defineOperation" method. I did this for example to extend
> the OCLEnvironment by the operation "getValue()" of a EFeatureMapEntry.
>
> But when I tried to evaluate this operation I got a
> NullPointerException caused by line 227 in the class
> EcoreEvaluationEnvironment.
> I think this occurrs because of a mistake in line 206.
>
> When an operation is added to the Environment a so called
> "ShadowClass" with the added EOperation will be created. But in the
> shadow class no information about the correct InstanceClass is stored.
>
> To get this information I changed line 206 to:
> EClassifier container = OCLStandardLibraryImpl.getOwner(operation);
>
> Am I right, is this a mistake?
>
> Best regards,
>
> Lilija Klassen
>
|
|
|
Powered by
FUDForum. Page generated in 0.04756 seconds