Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [SOLVED] Disabling DSL metamodel source generation
[SOLVED] Disabling DSL metamodel source generation [message #1704188] Sat, 08 August 2015 10:47 Go to next message
Davide G is currently offline Davide GFriend
Messages: 36
Registered: October 2013
Member
Hi, i'm writing a grammar using Xtext that includes the following rules:

MyList
:
	  elements+=Element
	| elements+=Element ',' elements+=Element 
;

Element
:
	name=ID
;


and i would like to implements the interface Iterable<EObject> to the class MyListImpl that
implements the data type for MyList rule. MyListImpl is automatically generated from Xtext every time I launch the .mwe2 script. However I would like Xtext to prevent from automatically generating and updating MyListImpl class, so I can add custom fields or methods to it and eventually changing the grammar rules without modifying every time the class MyListImpl. Is it possible to do this?

[Updated on: Sun, 09 August 2015 15:00]

Report message to a moderator

Re: Disabling DSL metamodel source generation [message #1704193 is a reply to message #1704188] Sat, 08 August 2015 14:16 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

i dont know if this is a good idea.

but you can:

- swtich to a manually maintained metamodel (XCore or pure ecore with org.eclipse.emf.mwe2.ecore.EcoreGenerator that supports generation gap)
- use IXtext2EcorePostProcessor to customize the metamodel generation and add derived stuff there (Depending on your usecase)



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Sat, 08 August 2015 14:17]

Report message to a moderator

Re: Disabling DSL metamodel source generation [message #1704231 is a reply to message #1704193] Sun, 09 August 2015 11:59 Go to previous messageGo to next message
Davide G is currently offline Davide GFriend
Messages: 36
Registered: October 2013
Member
Christian Dietrich wrote on Sat, 08 August 2015 10:16
Hi,

i dont know if this is a good idea.

but you can:

- swtich to a manually maintained metamodel (XCore or pure ecore with org.eclipse.emf.mwe2.ecore.EcoreGenerator that supports generation gap)
- use IXtext2EcorePostProcessor to customize the metamodel generation and add derived stuff there (Depending on your usecase)



Thank you for your fast response. I think I've found a simple solution:

- Create the grammar EMF metamodel project, and define a metamodel.
- Create an Xtext project using the created metamodel project.

Why to do this? Because I've found much clearer and elegant to separate between the metamodel source code and the grammar/Xtext code (when an external metamodel is used, Xtext projects doesn't contains ecore generated classes). Furthermore, I've found the tag "@generated not" is working into the EMF projects, so that fields and methods can be manually defined: in this way any modification is not lost even when the ecore metamodel needs to be changed.
Re: Disabling DSL metamodel source generation [message #1704232 is a reply to message #1704231] Sun, 09 August 2015 12:22 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

this is what i mean with manually maintained metamodel.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Disabling DSL metamodel source generation [message #1704234 is a reply to message #1704232] Sun, 09 August 2015 14:59 Go to previous message
Davide G is currently offline Davide GFriend
Messages: 36
Registered: October 2013
Member
Christian Dietrich wrote on Sun, 09 August 2015 08:22
Hi,

this is what i mean with manually maintained metamodel.


I got it! Thanks a lot Wink
Previous Topic:MWE failing on referenced Ecore Model
Next Topic:Do we have a way to get the differences between xtext model before and after partial parse?
Goto Forum:
  


Current Time: Tue Mar 19 11:52:04 GMT 2024

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

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

Back to the top