Skip to main content



      Home
Home » Modeling » M2T (model-to-text transformation) » [Xtext] Isn't a copy operation side-effect free?
[Xtext] Isn't a copy operation side-effect free? [message #488001] Fri, 25 September 2009 05:23 Go to next message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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!
Previous Topic:Check: Live Validation
Next Topic:[Announce] M2T XPAND 0.8.0M2 is available
Goto Forum:
  


Current Time: Fri Jul 04 04:51:37 EDT 2025

Powered by FUDForum. Page generated in 0.27260 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top