Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Code generation: dirtying (@generated) JavaDoc of interfaces, in order to keep handwritten "ext
Code generation: dirtying (@generated) JavaDoc of interfaces, in order to keep handwritten "ext [message #1766356] Tue, 20 June 2017 13:53 Go to next message
Cristian Spiescu is currently offline Cristian SpiescuFriend
Messages: 100
Registered: July 2009
Senior Member
Hello,

I am migrating from an older EMF version (from Eclipse 3.7) to the current one. I'm under the impression that the "@generated" doesn't work like before (cf. manual), for interfaces.

I have a model element for which I have added some additional "extends". I have modified the original "@generated" clause, by adding an additional text: "@generated keep_header". When I generate the code from the .genmodel file, the generator doesn't seem to take into account what I did, so it completely overwrites the interface "header"; i.e. I loose the interfaces that I added manually.

If I use "@generated NOT", then the generator doesn't regenerate the children of the interface (i.e. methods). This is indeed according to the manual.

Do you have any thoughts on this?

Thank you in advance.
Best regards,
Cristian.
Re: Code generation: dirtying (@generated) JavaDoc of interfaces, in order to keep handwritten " [message #1766384 is a reply to message #1766356] Tue, 20 June 2017 20:17 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
You can use @extends/@implements with the fully qualified in the begin-user-doc section (so it's not merged away) to add additional things. You can also use @generated not to block just the changes to the extends/implements part of the class/interface header.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Code generation: dirtying (@generated) JavaDoc of interfaces, in order to keep handwritten & [message #1766444 is a reply to message #1766384] Wed, 21 June 2017 14:06 Go to previous messageGo to next message
Cristian Spiescu is currently offline Cristian SpiescuFriend
Messages: 100
Registered: July 2009
Senior Member
Thanks a lot Ed!

@extends/implements works also in older EMFs? E.g. 2.5?

And regarding my initial question: is it correct that older EMF, for classes/interfaces, treated differently @generated NOT and @generated _WHATEVER_?

Best regards,
Cristian.
Re: Code generation: dirtying (@generated) JavaDoc of interfaces, in order to keep handwritten & [message #1766453 is a reply to message #1766444] Wed, 21 June 2017 15:00 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
It looks like the @extends/@implements rules in /org.eclipse.emf.codegen.ecore/templates/emf-merge.xml were last modified 11 years ago, so yes those should be supported by EMF 2.5. And yes, @generated NOT has the effective of recursively blocked all merging of nested members. So on a class or interface it blocks all merging of everything whereas @generated _ANYTHING_ELSE will only block the merging of the header itself, i.e., the implements/extends part of the declaration.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Code generation: dirtying (@generated) JavaDoc of interfaces, in order to keep handwritten & [message #1766459 is a reply to message #1766453] Wed, 21 June 2017 15:38 Go to previous messageGo to next message
Cristian Spiescu is currently offline Cristian SpiescuFriend
Messages: 100
Registered: July 2009
Senior Member
I understand; so the behavior was not changed.

So, in my case, I add "@generated keep_header", and the statement below in my case doesn't work:

@generated _ANYTHING_ELSE will only block the merging of the header itself, i.e., the implements/extends part of the declaration


I.e. the new interface that I added to "extends" is deleted on next generation. Maybe I'm doing something wrong? If not, this seems to be a bug.

Best regards,
Cristian
Re: Code generation: dirtying (@generated) JavaDoc of interfaces, in order to keep handwritten & [message #1766465 is a reply to message #1766459] Wed, 21 June 2017 16:25 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Yes, it seems on interfaces the @generated _whatever_ doesn't block the changing of the extends part of the header declaration. On classes it does work as expected. So indeed that seems a bit inconsistent. In any case, using @extends/@implements is better in general because then any other changes to the Ecore model are still properly regenerated...

Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:How to define xml name and plural name of a TAG
Next Topic:[Transaction] An exception was (not) ignored during command execution
Goto Forum:
  


Current Time: Sat Apr 20 04:20:21 GMT 2024

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

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

Back to the top