Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [Xtend2] Generating output file from several model files
[Xtend2] Generating output file from several model files [message #731696] Sun, 02 October 2011 14:47 Go to next message
Tobias Kniep is currently offline Tobias KniepFriend
Messages: 13
Registered: June 2010
Junior Member
Hello,

I'm currently migrating an existing Xtend/Xpand code generator to Xtend2. For some output files the current generator collects information from model elements spread over a lot of model files. This is done by calling the generator (org.eclipse.xpand2.Generator) from the MWE2 workflow with a statement like that:

expand = "main FOR model"


This gives the main template a list of all resources which can then be searched for the required model elements.

Now, with Xtend2 the doGenerate() function is called for each Resource independently. I understand that I can navigate to other Resources by first getting the ResourceSet and then all contained Resources. But how can I make sure that this is not repeated for each Resource over and over again? Assume, I have two model files A.dsl and B.dsl and just a single output file target.c that requires elements from both A.dsl and B.dsl. The doGenerate() function will be called for both model files but during the first call (for A.dsl) I'll already collect all required information and generate target.c. So when doGenerate() is called the second time, how can I make it recognize that it's not necessary to generate target.c again?

One possible solution I could think of would be to write an own GeneratorComponent which passes all resources from a slot to the Xtend2 class in one function call.
Is there any other/better solution to this?

Tobias
Re: [Xtend2] Generating output file from several model files [message #731699 is a reply to message #731696] Sun, 02 October 2011 15:02 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14677
Registered: July 2009
Senior Member
Hi,

Karsten has blogged on this: http://kthoms.wordpress.com/2011/07/12/xtend-generating-from-multiple-input-models/

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [Xtend2] Generating output file from several model files [message #731841 is a reply to message #731699] Mon, 03 October 2011 09:31 Go to previous message
Tobias Kniep is currently offline Tobias KniepFriend
Messages: 13
Registered: June 2010
Junior Member
Christian, thanks a lot. That's exactly what I need.

Tobias
Previous Topic:How to create Eclipse like Welcome Page
Next Topic:Problem with datatype rule - mismatched input
Goto Forum:
  


Current Time: Wed May 08 23:27:55 GMT 2024

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

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

Back to the top