Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Adding metadata to emf AST before generator/validator phase?
icon5.gif  Adding metadata to emf AST before generator/validator phase? [message #896355] Wed, 18 July 2012 03:34 Go to next message
Ian Warwick is currently offline Ian Warwick
Messages: 11
Registered: April 2012
Junior Member
Hi,

I would like to add some metadata to the EMF model before the generator (and ideally validator) phase.

This metadata is not part of my DSL's syntax, its just inferred from the model as a convention.

Is there an ideal place that occurs before the validator and generator phase?, such as when the model is turned from text into EMF that I can hook into?

I have looked at my languages RuntimeModule and can see I can override various Guice mappings, but I am unsure which one.

Appologies for the newbie questions, xtext is a bit overwhelming.

EDIT: I found a great article that looks like what I am after, but the article is a year old and there could be more support for this that I am unaware of christiandietrich.wordpress.com/2011/07/22/customizing-xtext-metamodel-inference-using-xtend2 ?

[Updated on: Wed, 18 July 2012 04:10]

Report message to a moderator

Re: Adding metadata to emf AST before generator/validator phase? [message #896424 is a reply to message #896355] Wed, 18 July 2012 07:34 Go to previous messageGo to next message
Jan Kohnlein is currently offline Jan Kohnlein
Messages: 570
Registered: July 2009
Senior Member
Have a look at org.eclipse.xtext.resource.DerivedStateAwareResource. It
adds a hook to add whatever state after parsing.

The respective binding is

public Class<? extends org.eclipse.xtext.resource.XtextResource>
bindXtextResource()



Am 18.07.12 09:34, schrieb Ian Warwick:
> Hi,
>
> I would like to add some metadata to the EMF model before the generator
> (and ideally validator) phase.
>
> This metadata is not part of my DSL's syntax, its just inferred from the
> model as a convention.
>
> Is there an ideal place that occurs before the validator and generator
> phase?, such as when the model is turned from text into EMF that I can
> hook into?
> I have looked at my languages RuntimeModule and can see I can override
> various Guice mappings, but I am unsure which one.
>
> Appologies for the newbie questions, xtext is a bit overwhelming.


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: Adding metadata to emf AST before generator/validator phase? [message #896542 is a reply to message #896424] Wed, 18 July 2012 15:10 Go to previous messageGo to next message
Ian Warwick is currently offline Ian Warwick
Messages: 11
Registered: April 2012
Junior Member
Hi Jan,

Thanks so much for that, that is awesome. I now need to figure out how to attach metadata to my ecore model objects since xtext generates the ecore model, I guess I need to somehow add fields and properties in one way or another.

Is there a usual way to do this?

Regards,

Ian
Re: Adding metadata to emf AST before generator/validator phase? [message #896557 is a reply to message #896542] Wed, 18 July 2012 16:28 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 4387
Registered: July 2009
Senior Member
Hi,

be documentation on this somehow seemed to be lost.
(was http://www.eclipse.org/Xtext/documentation/2_0_0/020-grammar-language.php#customPostProcessing)
have a look http://christiandietrich.wordpress.com/2011/07/22/customizing-xtext-metamodel-inference-using-xtend2/

~Christian

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Adding metadata to emf AST before generator/validator phase? [message #896558 is a reply to message #896557] Wed, 18 July 2012 16:33 Go to previous message
Christian Dietrich is currently offline Christian Dietrich
Messages: 4387
Registered: July 2009
Senior Member
Alternatively you can use a manually maintained metamodel
~ Christian
--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Previous Topic:make String type attributes to be unique
Next Topic:Xtext sometimes fails to resolve references in global scope
Goto Forum:
  


Current Time: Sun May 19 23:51:38 EDT 2013

Powered by FUDForum. Page generated in 0.02053 seconds