Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » javadoc for generated artifacts(How to change javadoc of generated EObjects)
javadoc for generated artifacts [message #895851] Mon, 16 July 2012 10:11 Go to next message
Olivier Petri is currently offline Olivier PetriFriend
Messages: 9
Registered: July 2012
Junior Member
Hi there,

Xtext generated grammar elements start with javadoc like this:

* <!-- begin-user-doc -->
* ...there really should be more of a description here...
* <!-- end-user-doc -->

Is there a way to actually set the "user-doc"?

I've been trying to add comments to the grammar file in serval ways, searched the xtext and antlr documentation, and, of course, asked google. But no success so far.

Any hint is appreciated.

Olivier

[Updated on: Mon, 16 July 2012 11:39]

Report message to a moderator

Re: javadoc for generated artifacts [message #896441 is a reply to message #895851] Wed, 18 July 2012 12:06 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 658
Registered: July 2009
Senior Member
These comments are geenrated by the EMF code generator we run to
generate the Java classes from the generated Ecore model. As we
overwrite this code completely on every generator run, you must switch
to an imported Ecore model and generate / maintain the EMF stuff manually.

Am 16.07.12 12:11, schrieb Olivier Petri:
> Hi there,
>
> Xtext generated grammar elements start with javadoc like this:
>
> * <!-- begin-user-doc -->
> * ...there really should be more of a description here...
> * <!-- end-user-doc -->
>
> Is there a way to actually set the "user-doc"?
> I've been trying to add comments to the grammar file in serval ways,
> searched the xtext and antlr documentation, and, of course, asked
> google. But no success so far.
>
> Any hint is appreciated.
>
> Olivier
>


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: javadoc for generated artifacts [message #987028 is a reply to message #895851] Fri, 23 November 2012 03:32 Go to previous messageGo to next message
Barrie Treloar is currently offline Barrie TreloarFriend
Messages: 52
Registered: July 2009
Member
Is it not possible to use javadoc like commenting on the grammar file and attach this to the ecore model prior to code generation?

Alternatively, can EMF be enhanced to not emit this boiler plate?
As the currently generated stuff is dangerous to use since it implies to the end user that the developer has not provided enough information. I'd almost prefer an empty javadoc string as the boilerplate stuff is set this value or get this value and adds no additional information to the method signature for bean getters/setters.
Re: javadoc for generated artifacts [message #987264 is a reply to message #987028] Sun, 25 November 2012 11:23 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 658
Registered: July 2009
Senior Member
As I said, switch to an imported, manually maintained Ecore model gives
you all the freedom you need. The generated metamodel approach is great
for getting started quickly, but from my experience people switch to the
imported Ecore model in the long run anyway. This is because the Ecore
model is an important API between the language and the processing
infrastructure (generator, interpreter) you will keep absolute control of.

Am 23.11.12 04:32, schrieb Barrie Treloar:
> Is it not possible to use javadoc like commenting on the grammar file
> and attach this to the ecore model prior to code generation?
>
> Alternatively, can EMF be enhanced to not emit this boiler plate?
> As the currently generated stuff is dangerous to use since it implies to
> the end user that the developer has not provided enough information. I'd
> almost prefer an empty javadoc string as the boilerplate stuff is set
> this value or get this value and adds no additional information to the
> method signature for bean getters/setters.


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: javadoc for generated artifacts [message #987314 is a reply to message #987264] Mon, 26 November 2012 01:18 Go to previous messageGo to next message
Barrie Treloar is currently offline Barrie TreloarFriend
Messages: 52
Registered: July 2009
Member
Jan Kohnlein wrote on Sun, 25 November 2012 06:23
As I said, switch to an imported, manually maintained Ecore model gives
you all the freedom you need. The generated metamodel approach is great
for getting started quickly, but from my experience people switch to the
imported Ecore model in the long run anyway. This is because the Ecore
model is an important API between the language and the processing
infrastructure (generator, interpreter) you will keep absolute control of.


Any chance you provide a link to what I need to look at?

I remember reading http://www.eclipse.org/Xtext/documentation.html#package_declarations but nothing about what I need to do write my own Ecore model (other than just understanding EMF). Can I bootstrap from my grammar? Because I'm not looking forward to manually building that model...
Re: javadoc for generated artifacts [message #987365 is a reply to message #987314] Mon, 26 November 2012 10:04 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 658
Registered: July 2009
Senior Member
It should be as simple as

-Copy the ecore file and the genmodel file from the src-gen to the src
folder
-Adapt the mwe2 workflow as described in
http://www.eclipse.org/Xtext/documentation.html#syntax
-Change your EPackage declaration in the grammar from 'generate' to 'import'


Am 26.11.12 02:18, schrieb Barrie Treloar:
> Jan Kohnlein wrote on Sun, 25 November 2012 06:23
>> As I said, switch to an imported, manually maintained Ecore model
>> gives you all the freedom you need. The generated metamodel approach
>> is great for getting started quickly, but from my experience people
>> switch to the imported Ecore model in the long run anyway. This is
>> because the Ecore model is an important API between the language and
>> the processing infrastructure (generator, interpreter) you will keep
>> absolute control of.
>
>
> Any chance you provide a link to what I need to look at?
>
> I remember reading
> http://www.eclipse.org/Xtext/documentation.html#package_declarations but
> nothing about what I need to do write my own Ecore model (other than
> just understanding EMF). Can I bootstrap from my grammar? Because I'm
> not looking forward to manually building that model...


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: javadoc for generated artifacts [message #987366 is a reply to message #987365] Mon, 26 November 2012 10:12 Go to previous message
Barrie Treloar is currently offline Barrie TreloarFriend
Messages: 52
Registered: July 2009
Member
Jan Kohnlein wrote on Mon, 26 November 2012 05:04
It should be as simple as

-Copy the ecore file and the genmodel file from the src-gen to the src
folder
-Adapt the mwe2 workflow as described in
http://www.eclipse.org/Xtext/documentation.html#syntax
-Change your EPackage declaration in the grammar from 'generate' to 'import'


Sweet.

I'll be giving that a go once I finish the grammar.

I'm super happy with how easy it has been so far, obviously there are learning curve issues and having a knowledge of ANTLRs internals made my life a bit easier.

I've read the docs through once, but its not until you try to do something that you appreciate having enough detail to get the job done.

Unit testing is making incremental development of grammar quick and safe.
Including getting cross references working!
Previous Topic:should Xtext builder lock the entire workspace?
Next Topic:Unit testing hidden terminal - ParseHelper returning null model
Goto Forum:
  


Current Time: Sun Dec 21 20:13:42 GMT 2014

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

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