Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Custom Code Overridden - Generator Model
Custom Code Overridden - Generator Model [message #1243193] Mon, 10 February 2014 16:53 Go to next message
Peter Johnsen is currently offline Peter JohnsenFriend
Messages: 60
Registered: January 2012
Member
Hey,

I use a mwe script to generate code...e.g.:

 component = org.eclipse.emf.mwe2.ecore.EcoreGenerator
  {
    generateCustomClasses = false
    genModel = "platform:/.../gen.genmodel"
    srcPath = "platform:/.../src"
  }


However, this causes my custom added code (in the Java classes) to be overriden, even though I have @generated NOT or just add a Method in the class.

Any ide how this can be avoided? Thanks!
Re: Custom Code Overridden - Generator Model [message #1243206 is a reply to message #1243193] Mon, 10 February 2014 17:11 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13637
Registered: July 2009
Senior Member
Create a class PersonImplCustom extends PersonImpl in the same
package and customize the code there
http://christiandietrich.wordpress.com/2013/07/26/use-of-ecoregenerator
-to-customize-emfs-generated-java-classes/

--
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


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Custom Code Overridden - Generator Model [message #1243783 is a reply to message #1243206] Tue, 11 February 2014 12:38 Go to previous messageGo to next message
Peter Johnsen is currently offline Peter JohnsenFriend
Messages: 60
Registered: January 2012
Member
Hi,

I'm aware of this option, but I'm talking about code that are added in the "original" Java classes. This code is overriden, which is not desirable. Is there an option or something than can be used in the mwe-script?
Re: Custom Code Overridden - Generator Model [message #1243788 is a reply to message #1243783] Tue, 11 February 2014 12:49 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13637
Registered: July 2009
Senior Member
Hi,

you have to write your own/subclass EcoreGenerator
and reenable jmerge there


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Custom Code Overridden - Generator Model [message #1243848 is a reply to message #1243788] Tue, 11 February 2014 14:30 Go to previous messageGo to next message
Peter Johnsen is currently offline Peter JohnsenFriend
Messages: 60
Registered: January 2012
Member
Thanks,

why is this not enabled by default?
Re: Custom Code Overridden - Generator Model [message #1243849 is a reply to message #1243848] Tue, 11 February 2014 14:32 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13637
Registered: July 2009
Senior Member
cause the component is made for generation gap and not protected regions

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:different instances of editor were given
Next Topic:Generated ecore models refer to Xbase using relative paths
Goto Forum:
  


Current Time: Sun Oct 25 03:13:24 GMT 2020

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

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

Back to the top