[Xtext] Isn't a copy operation side-effect free? [message #488001] |
Fri, 25 September 2009 05:23  |
Eclipse User |
|
|
|
Hello everybody!
I just discovered something I didn't know.. I have something like this in my code:
create ClassA newObj copyObj(ClassB o):
newObj.setAssociation(o.ass)->
newObj;
where ass represents an association (having containment=true in the metamodel) with another class, let's say classC. My problem is that after setAssociation() has been performed, the association in o is set to null, while I want this operation to be side-effect free..
Can you hint me a workaround please?
Many thanks!
Bye!
|
|
|
Re: [Xtext] Isn't a copy operation side-effect free? [message #488060 is a reply to message #488001] |
Fri, 25 September 2009 09:19  |
Eclipse User |
|
|
|
Hi smoking,
as an EObject may only be contained in one and only one container, you
modify it by setAssociation(o.ass) which puts it into another container.
You may want to EcoreUtil.copy() your model before you perform the
transformation.
Hope that helps,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
smoking schrieb:
> Hello everybody!
>
> I just discovered something I didn't know.. I have something like this
> in my code:
>
> create ClassA newObj copyObj(ClassB o):
> newObj.setAssociation(o.ass)->
> newObj;
>
> where ass represents an association (having containment=true in the
> metamodel) with another class, let's say classC. My problem is that
> after setAssociation() has been performed, the association in o is set
> to null, while I want this operation to be side-effect free..
> Can you hint me a workaround please?
>
> Many thanks!
> Bye!
|
|
|
Powered by
FUDForum. Page generated in 0.27260 seconds