Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » let expression for a set in XPand and Xtend
let expression for a set in XPand and Xtend [message #694738] Sat, 09 July 2011 14:08 Go to next message
st oehm is currently offline st oehm
Messages: 79
Registered: October 2009
Member
hi to all
i wonder if it is possible to have an local variable in XPand or XTend that is an empty Set or List.
i tired a lot of things and variations of this "let set = new Set[Classifier]:"
for now i have just i take a set which is not empty and make it empty with the removeAll call, but that is not very nice
furhermore my xtend expression is complicated through this problem

in XPand i have a similar problem
i want to add something to this set, but this operation should not be in the generated code, for now i have something like this

«LET parents.name.removeAll(parents.name) AS menge»
«LET parents.ownedOperation AS allOperations»
«FOREACH allOperations AS o»
«IF menge.contains(o.name)»
«ELSE» «EXPAND operations FOR o»
«LET
menge.add(o.name) AS menge»
«ENDLET»
«ENDIF»
«ENDFOREACH»
«ENDLET»
«ENDLET»

as you can see the outer statement is for creating an empty Set (not ver nice) the second let ist just normal, and in the inner-let i add something to the empty Set
this works but is not very nice

summing up i need to create a empty set with the let statement (for XPand and XTend) and i need to add elements to a set wich is not generated in xpand
is this possible

best regards
stoehm
Re: let expression for a set in XPand and Xtend [message #694740 is a reply to message #694738] Sat, 09 July 2011 14:12 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6388
Registered: July 2009
Senior Member
Hi, the literal for an empty list is {}.

~Christian
Re: let expression for a set in XPand and Xtend [message #694744 is a reply to message #694740] Sat, 09 July 2011 14:21 Go to previous messageGo to next message
st oehm is currently offline st oehm
Messages: 79
Registered: October 2009
Member
hi christian
thanks for your reply, that makes things a lot easier
but i have still the problem, that i want to add an elemnt to the local set, which not should be printed out, the solution above works but is not very nice

best regards
stoehm
Re: let expression for a set in XPand and Xtend [message #694747 is a reply to message #694744] Sat, 09 July 2011 14:29 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6388
Registered: July 2009
Senior Member
Hi,

therefore a simple advice: use more xtend and less xpand Wink
so why don't you do something like

btw why do you have to do this duplicate operations filtering at all? if someone models this ops twice this may have a reason ;-

~Christian
Re: let expression for a set in XPand and Xtend [message #694750 is a reply to message #694747] Sat, 09 July 2011 14:33 Go to previous message
st oehm is currently offline st oehm
Messages: 79
Registered: October 2009
Member
hi christian
hmm of course i just have to use XTend (maybe the solution was to obvious)
i filter this operations, because i need this for simulating multipleInheritance in Java. if there is the same attribute or operation in more than one superclass i just select one

thanks for super fast replying
best regards
stoehm
Previous Topic:[Acceleo] Retrieve a Class : from an association in a property / from her name in the model
Next Topic:[Acceleo] Jet template to acceleo converter
Goto Forum:
  


Current Time: Fri Oct 24 21:36:54 GMT 2014

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

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