Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » xtext-dsl -> enrich-model -> xtend2-template?
xtext-dsl -> enrich-model -> xtend2-template? [message #1012839] Fri, 22 February 2013 05:05 Go to next message
m gie is currently offline m gie
Messages: 2
Registered: February 2013
Junior Member
Hi!
I have an xtext-dsl that I used to generate different artifacts from (i.e. SQL-Files, XML-File...).
Now I have a requirement to enrich the model with additional info before the code generation (i.e. info that comes from a jdbc datasource).

1) I downloaded the latest xtext-distribution and from what I understand I should do the generation of artifacts with xtend instead of xpand now. Is that correct?

2) I am a little bit lost in all the generated plugin-projects ragarding where that custom model-enrichment part would go. Any suggestions here?

thnx and regards,

mgie
Re: xtext-dsl -> enrich-model -> xtend2-template? [message #1013801 is a reply to message #1012839] Sun, 24 February 2013 05:43 Go to previous messageGo to next message
Axel Guckelsberger is currently offline Axel Guckelsberger
Messages: 213
Registered: July 2009
Senior Member
Hi,

you can just set/add/change model properties at the beginning of your Xtend
generator.

Here is an example for this:

http://ziku.la/xtend-trafo-example


HTH,

Axel

m gie wrote:

> Hi!
> I have an xtext-dsl that I used to generate different artifacts from (i.e.
> SQL-Files, XML-File...). Now I have a requirement to enrich the model with
> additional info before the code generation (i.e. info that comes from a
> jdbc datasource).
>
> 1) I downloaded the latest xtext-distribution and from what I understand I
> should do the generation of artifacts with xtend instead of xpand now. Is
> that correct?
>
> 2) I am a little bit lost in all the generated plugin-projects ragarding
> where that custom model-enrichment part would go. Any suggestions here?
>
> thnx and regards,
>
> mgie
Re: xtext-dsl -> enrich-model -> xtend2-template? [message #1014181 is a reply to message #1013801] Mon, 25 February 2013 05:09 Go to previous messageGo to next message
m gie is currently offline m gie
Messages: 2
Registered: February 2013
Junior Member
Ok, that sound reasonable. I am gonna try that.

Just one additional question:
In my xtend-generator I need to retrieve some information from a database.
So far my db-accessor gets instantiated and connects from within the xtend-generator,
which means that every change in my dsl triggers this action (as long as "Build Automatically" is switched on).
Is there a place in the language infrastructure where i can initialize a singleton of that Accessor and inject it
into the xtend-generator?

Re: xtext-dsl -> enrich-model -> xtend2-template? [message #1014213 is a reply to message #1014181] Mon, 25 February 2013 06:32 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan Koehnlein
Messages: 655
Registered: July 2009
Senior Member
Try @Singleton on the implementing class.

Am 25.02.13 11:09, schrieb m gie:
> Ok, that sound reasonable. I am gonna try that.
>
> Just one additional question:
> In my xtend-generator I need to retrieve some information from a database.
> So far my db-accessor gets instantiated and connects from within the
> xtend-generator,
> which means that every change in my dsl triggers this action (as long as
> "Build Automatically" is switched on).
> Is there a place in the language infrastructure where i can initialize a
> singleton of that Accessor and inject it
> into the xtend-generator?
>
>


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: xtext-dsl -> enrich-model -> xtend2-template? [message #1014214 is a reply to message #1012839] Mon, 25 February 2013 06:33 Go to previous message
Jan Koehnlein is currently offline Jan Koehnlein
Messages: 655
Registered: July 2009
Senior Member
Depends on what you do in the enrichment step.
I'd rather go for some extension methods to add methods with the needed
functionality in the generator, because the model is also used by other
components which might get confused.

Am 22.02.13 12:35, schrieb m gie:
> Hi!
> I have an xtext-dsl that I used to generate different artifacts from
> (i.e. SQL-Files, XML-File...).
> Now I have a requirement to enrich the model with additional info before
> the code generation (i.e. info that comes from a jdbc datasource).
>
> 1) I downloaded the latest xtext-distribution and from what I understand
> I should do the generation of artifacts with xtend instead of xpand now.
> Is that correct?
>
> 2) I am a little bit lost in all the generated plugin-projects ragarding
> where that custom model-enrichment part would go. Any suggestions here?
>
> thnx and regards,
>
> mgie


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Previous Topic:Using Actions Correctly in Xtext
Next Topic:Error when reloading resource from a context menu button before xtend 2 generation
Goto Forum:
  


Current Time: Mon Jul 28 08:32:44 EDT 2014

Powered by FUDForum. Page generated in 0.01948 seconds