Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [Xtend] recursive extension call
[Xtend] recursive extension call [message #514159] Fri, 12 February 2010 16:28 Go to next message
moni is currently offline moniFriend
Messages: 4
Registered: February 2010
Junior Member
Hallo,

i created a recursive extension call. since i could not use let to define internal variables, i created it like this

create this createSubapplication(SystemSubcomponent aSysComp, List[ApplicationType] fTypes, List[SystemImpl] allSystemImpls):
	this.setName(aSysComp.name)->
	this.subApplications.addAll(aSysComp.systemSubcomponent.createSubapplication(fTypes,allSystemImpls))->
	this;


this extension created all elements in the hierarchy. unfortunately it did not put this hierarchy into every element were it was supposed to be. i expected that more than one element of the same layer should include the same hierarchy but i found the complete hierary only within the last one. Is there any possibility to get the hierarchy into all elements?

expected:
- element 1
-- childelement
--- childchildelement ...
- element 2
-- childelement
--- childchildelement ...
- element 3
-- childelement
--- childchildelement ...


created:
- element 1
- element 2
- element 3
-- childelement
--- childchildelement ...


thanks for any help!
Re: [Xtend] recursive extension call [message #514452 is a reply to message #514159] Mon, 15 February 2010 12:19 Go to previous messageGo to next message
Erhard Weinell is currently offline Erhard WeinellFriend
Messages: 39
Registered: January 2010
Location: Kassel, Germany
Member
moni wrote:

> this extension created all elements in the hierarchy. unfortunately it
> did not put this hierarchy into every element were it was supposed to
> be. i expected that more than one element of the same layer should
> include the same hierarchy but i found the complete hierary only within
> the last one. Is there any possibility to get the hierarchy into all
> elements?

If you want the "childelement" to be contained in all these top-level
elements, than the only way to go is to create three objects and add
them accordingly. You experience intended behaviour of EMF: If you add
an EObject to a new container, it is removed from its previous container
first. Furthermore, Xtend's 'create' only creates one instance per
actual parameter tuple, so you should use a non-create extension but
create instances manually (using 'new').

Best regards,
Erhard Weinell
Re: [Xtend] recursive extension call [message #516222 is a reply to message #514159] Tue, 23 February 2010 09:27 Go to previous message
moni is currently offline moniFriend
Messages: 4
Registered: February 2010
Junior Member
thank you very much for your clear explanation! it helped me to finally wirte a piece of code that produces the desired outcome Very Happy
Previous Topic:ATL
Next Topic:[M2M] How to transform UML2 model to EMF model
Goto Forum:
  


Current Time: Fri Apr 26 02:42:14 GMT 2024

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

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

Back to the top