|
|
|
Re: Xpand: avoid duplicates? [message #683430 is a reply to message #683404] |
Mon, 13 June 2011 17:58 |
|
Hi i am thinking of something like
template/extensions.ext (you need to and xtend stdlib to path)
extension org::eclipse::xtend::util::stdlib::globalvar;
String addProcessedElement(Object o) :
getGlobalVar("processed") == null ? (storeGlobalVar("processed", {o}) -> "") : (((List)getGlobalVar("processed")).add(o) -> "");
Boolean isProcessedElement(Object o) :
getGlobalVar("processed") == null ? false : ((List)getGlobalVar("processed")).contains(o);
«IMPORT metamodel»
«EXTENSION template::extensions»
«DEFINE main FOR Split»
«addProcessedElement(this)»
«FILE "testoutput.txt"-»
«this.name-» (following: «FOREACH followingElement_A AS e» «e.name» «ENDFOREACH»)
-------------------------------
«EXPAND def1 FOREACH this.followingElement_A»
«ENDFILE»
«ENDDEFINE»
«DEFINE def1 FOR Class1»
«addProcessedElement(this)»
«this.name» (following: «FOREACH followingElement_B AS e» «e.name» «ENDFOREACH»)
-------------------------------
«EXPAND def2 FOREACH this.followingElement_B»
«ENDDEFINE»
«DEFINE def2 FOR Class2»
«IF !isProcessedElement(this)»
«addProcessedElement(this)»
«this.name»
«ENDIF»
«ENDDEFINE»
~Christian
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03650 seconds