Skip to main content


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 07:34 Go to next message
Ian Warwick is currently offline Ian WarwickFriend
Messages: 44
Registered: April 2012
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 08: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 11:34 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
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


---
Get professional support from the Xtext committers at www.typefox.io
Re: Adding metadata to emf AST before generator/validator phase? [message #896542 is a reply to message #896424] Wed, 18 July 2012 19:10 Go to previous messageGo to next message
Ian Warwick is currently offline Ian WarwickFriend
Messages: 44
Registered: April 2012
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 20:28 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13359
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


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Adding metadata to emf AST before generator/validator phase? [message #896558 is a reply to message #896557] Wed, 18 July 2012 20:33 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13359
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


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.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: Sat Feb 22 07:56:00 GMT 2020

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

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

Back to the top