Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EMF - Question about EMF code generation(doubt on "@generated NOT" on class)
icon14.gif  EMF - Question about EMF code generation [message #1354267] Wed, 14 May 2014 07:19 Go to next message
Mauro P. is currently offline Mauro P.Friend
Messages: 24
Registered: April 2011
Junior Member
Hi all,
I've got a question about the "@generated NOT" notation used by the emf code genration.
This is my situation.
Once i've generated the classes form the genmodel for the first time i would like to change some(not all) classes to make them extends or implements other classes/interfaces (different form the one generated) but i don't know where to put the "@generated NOT" notation to say the generator to not ovverride them on next generation.

I've tried to put the notation on the class comment, but when I do that, the entire calss is not regenerated (including methods and fileds), but i want that methods and fileds get regenrated (except the one marked as "@generated NOT" as default)

I've tryed also to put the notation on the constructor's comment but as presumed only the constructor was not regenerated.

Can someone explain me how to achieve that?

Thanks in advance
Mauro

[Updated on: Wed, 14 May 2014 11:38]

Report message to a moderator

Re: EMF - Question about EMF code generation [message #1354309 is a reply to message #1354267] Wed, 14 May 2014 07:42 Go to previous messageGo to next message
Hussein MHANNA is currently offline Hussein MHANNAFriend
Messages: 45
Registered: February 2014
Location: LAVAL
Member
Hi Mauro,

Putting "@generated NOT" on the class comment will prevent the modification on all the class content during the code re-generation.

Why you don't put the classes/interfaces that you want to extend/implements directly in you ecore model?

For example, if you want to implement/extends an interface/class taht isn't modeled with Ecore, then you can create an EClass (set its property interface to "true" in case of interafce) and fill its "Name" property and its "Instance Type Name" property that must be the full interface/class name (packagename.interfacename).


Hussein


ALL4TEC
Re: EMF - Question about EMF code generation [message #1354503 is a reply to message #1354267] Wed, 14 May 2014 09:33 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Mauro,

Comments below.

On 14/05/2014 9:19 AM, Mauro P. wrote:
> Hi all,
> I've got a question about the "@generated NOT" notation used by the
> emf code genration.
> This is my situation.
> Once i've generated the classes form the genmodel for the first time i
> would like to change some(not all) classes to make them extends or
> implements other classes/interfaces (different form the one generated)
> but i don't know where to put the "@generated NOT" notation to say the
> generator to not ovverride them on next generation.
Note that for a class or interface "@generated NOT" is special. It
blocks all regeneration. But anything else, e.g., "@generated not" will
block only the merging of the "extends/implements" part of the class
declaration itself. Hussein's suggestion to use @implements in the
generated class or @extends in the generated interface is even better if
that works for your case...
>
> I've tried to put the notation on the class comment, but when I do
> that, the entire calss is not regenerated (including methods and
> fileds), but i want that methods and fileds get regenrated (except the
> one marked as "@generated NOT" as default)
>
> I've tryed also to put the notation on the constructor's comment but
> as presumed only the constructor was not regenerated.
>
> Can someone explain me how to achieve that?
>
> Thanks in advance
> Mauro
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: EMF - Question about EMF code generation [message #1354595 is a reply to message #1354503] Wed, 14 May 2014 10:28 Go to previous message
Mauro P. is currently offline Mauro P.Friend
Messages: 24
Registered: April 2011
Junior Member
Hussein MHANNA wrote on Wed, 14 May 2014 03:42
Why you don't put the classes/interfaces that you want to extend/implements directly in you ecore model?
For example, if you want to implement/extends an interface/class taht isn't modeled with Ecore, then you can create an EClass (set its property interface to "true" in case of interafce) and fill its "Name" property and its "Instance Type Name" property that must be the full interface/class name (packagename.interfacename).

Thanks Hussein for the suggestion, but in my case this is not be applicable because I need to moodify the factory and packages classes. Otherwise is a great solution becouse calasses are generated correctly and no manual code changes are required.


Ed Merks wrote on Wed, 14 May 2014 05:33
Note that for a class or interface "@generated NOT" is special. It
blocks all regeneration. But anything else, e.g., "@generated not" will
block only the merging of the "extends/implements" part of the class
declaration itself. Hussein's suggestion to use @implements in the
generated class or @extends in the generated interface is even better if
that works for your case...

Really thnaks Ed. I didn't know that! Changin from "NOT" to "not" worked well!
Tanks all guys!
Previous Topic:[Net4j] TimeoutException while activating Client-Protocol
Next Topic:Is there a way to use a string as raw XML?
Goto Forum:
  


Current Time: Fri Mar 29 15:57:07 GMT 2024

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

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

Back to the top