Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [XTEND] Iteration over a List
[XTEND] Iteration over a List [message #526403] Sat, 10 April 2010 13:09 Go to next message
Amine  is currently offline Amine Friend
Messages: 10
Registered: March 2010
Junior Member
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 16:55 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hello,

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


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [XTEND] Iteration over a List [message #526537 is a reply to message #526403] Mon, 12 April 2010 08:35 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

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


Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: [XTEND] Iteration over a List [message #526881 is a reply to message #526415] Tue, 13 April 2010 11:50 Go to previous message
Amine  is currently offline Amine Friend
Messages: 10
Registered: March 2010
Junior Member
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: Thu Apr 25 08:58:46 GMT 2024

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

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

Back to the top