Skip to main content


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 10:05 Go to next message
m gie is currently offline m gieFriend
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 10:43 Go to previous messageGo to next message
Axel Guckelsberger is currently offline Axel GuckelsbergerFriend
Messages: 354
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 10:09 Go to previous messageGo to next message
m gie is currently offline m gieFriend
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 11:32 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
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


---
Get professional support from the Xtext committers at www.typefox.io
Re: xtext-dsl -> enrich-model -> xtend2-template? [message #1014214 is a reply to message #1012839] Mon, 25 February 2013 11:33 Go to previous message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
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


---
Get professional support from the Xtext committers at www.typefox.io
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: Tue Apr 16 21:41:32 GMT 2024

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

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

Back to the top