Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Post-processing the generated genmodel?
Post-processing the generated genmodel? [message #1067763] Wed, 10 July 2013 13:36 Go to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Hi,

I've been successfully using an IXtext2EcorePostProcessor in one of my projects.
Now I wonder if it is possible to also post-process the generated genmodel, in my case in order to set a rootExtendsInterface attribute.

So, when the post-processor is invoked, does the genmodel already exist in memory? Is there a way to get hold of that either from a IXtext2EcorePostProcessor or using a similar hook?

In other projects I'm happy with manually maintaining the meta model, but in this project the language isn't quite mature enough, i.e., I still want Xtext to generate the meta model whenever the grammar is changed.

TIA,
Stephan
Re: Post-processing the generated genmodel? [message #1067813 is a reply to message #1067763] Wed, 10 July 2013 16:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi what about to override and use org.eclipse.xtext.generator.ecore.EcoreGeneratorFragment.getGenModel(ResourceSet, Grammar, XpandExecutionContext, List<EPackage>)

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Post-processing the generated genmodel? [message #1067815 is a reply to message #1067813] Wed, 10 July 2013 16:56 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Thanks for the hint. Sounds cool.

Two issues
- @noextend This class is not intended to be subclassed by clients.
- EvaluationException : No Definition MyProcessingEcoreGenerator::generate(String) for org::eclipse::xtext::impl::GrammarImpl could be found! Internal error : element was null

any ideas?

Apart from these issues, the modification of the genmodel works fine, actually!

I'll keep trying,
Stephan
Re: Post-processing the generated genmodel? [message #1067819 is a reply to message #1067815] Wed, 10 July 2013 17:05 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi you may have to override the template detection meachism too to
take the old fragments package and not yours

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Post-processing the generated genmodel? [message #1067822 is a reply to message #1067819] Wed, 10 July 2013 17:25 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
yep, thanks, I added this:

	@Override
	protected String getTemplate() {
		return EcoreGeneratorFragment.class.getName().replaceAll("\\.", "::");
	}


And now I can modify the genmodel on the fly (provided I don't worry to much about the @noextend tag Smile )

thanks,
Stephan
Re: Post-processing the generated genmodel? [message #1067829 is a reply to message #1067822] Wed, 10 July 2013 18:11 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Btw feel free to file a enhancement request for this

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Post-processing the generated genmodel? [message #1067986 is a reply to message #1067829] Thu, 11 July 2013 15:00 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Trying my trick during maven build the MWE2Launcher couldn't resolve MyProcessingEcoreGenerator and I was quite at a loss about this difference between directly invoking the .mwe2 (OK) and letting fornax do this (NOK).

The only way I could fix that was creating a new project just for that one class and have it built before the main xtext project.
Yea, maybe better integrating this with Xtext would help, but to really tell I would need better understanding of how the MWE2Launcher finds any classes of the current project when invoked via maven/fornax.

For my own application things are fine.
Re: Post-processing the generated genmodel? [message #1067995 is a reply to message #1067986] Thu, 11 July 2013 15:28 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi

you have to move the fragment to a own bundle.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Post-processing the generated genmodel? [message #1067997 is a reply to message #1067995] Thu, 11 July 2013 15:30 Go to previous message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
that's what I did Smile
Previous Topic:Content Assist for JvmTypeReference stops working when redefining its syntax
Next Topic:Filter Java types in content assist
Goto Forum:
  


Current Time: Thu Apr 25 14:59:52 GMT 2024

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

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

Back to the top