Skip to main content



      Home
Home » Modeling » M2T (model-to-text transformation) » [XTEND] Iteration over a List
[XTEND] Iteration over a List [message #526403] Sat, 10 April 2010 09:09 Go to next message
Eclipse UserFriend
Hi,

I'm having a little issue with Lists in xtend. Here is my problem:

I have these functions:

String transformDec(ada::single_task_declaration task) :
	"task "+task.identifier+" is\n"+task.entryDec.transformDec()
	+"end "+task.identifier+";\n"
;

String transformDec(ada::entry_declaration entry) :
	"entry "+entry.identifier+";\n"
;


entryDec is a List of objects of type entry_declaration and the generated code is like this:

task Component_acces1 is
[entry r1_reponsePositive;
, entry r1_reponseNegative;
, entry r1_voitureArrive;
]end Component_acces1;


I don't need the brackets and commas, i want it to be like this :

task Component_acces1 is
entry r1_reponsePositive;
entry r1_reponseNegative;
entry r1_voitureArrive;
end Component_acces1;

Your help is much appreciated!
Re: [XTEND] Iteration over a List [message #526415 is a reply to message #526403] Sat, 10 April 2010 12:55 Go to previous messageGo to next message
Eclipse UserFriend
hello,

just call toString("") on your list: task.entryDec.transformDec().toString("")
Re: [XTEND] Iteration over a List [message #526537 is a reply to message #526403] Mon, 12 April 2010 04:35 Go to previous messageGo to next message
Eclipse UserFriend
You should use Xpand to generate the code.

«DEFINE transformDec FOR ada::single_task_declaration-»
task «this.identifier» is
«FOREACH this.entryDec AS entry-»
  «entry.identifier»;
«ENDFOREACH-»
end «this.identifier»;


Regards,
~Karsten
Re: [XTEND] Iteration over a List [message #526881 is a reply to message #526415] Tue, 13 April 2010 07:50 Go to previous message
Eclipse UserFriend
Christian Dietrich wrote on Sat, 10 April 2010 12:55
hello,

just call toString("") on your list: task.entryDec.transformDec().toString("")



Thanks a lot, it worked. I have the code working on Xpand but i need it using Xtend.

Thanks for your help Smile .
Previous Topic:[Xpand] from 2 models to text
Next Topic:Xpand IMPORT problem
Goto Forum:
  


Current Time: Wed Jul 30 12:21:14 EDT 2025

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

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

Back to the top