In the last tip, we saw how to add methods to the EMF generated classes. In this tip, lets see how to add javadoc comments to the methods.
In the generated methods, the default comment would be:
Since the meaning of the 'Pages' attribute isn't clear, we will add some more description there. But how? We can either edit the javadoc and add it there, but then if you were like me who don't want to touch the generated code, here is the way. Its more like the last tip.
Right click the element for which you wish to add the java doc, and add EAnnotation and set the Source to "http://www.eclipse.org/emf/2002/GenModel". Add a details entry to the EAnnotation and set the key to 'documentation' and value to the comment that you want to be generated.
Reload your .genmodel file and generate the code.
As you can see EMF still generates the old comments. This can be changed by dynamic templates, which I'll explain in another tip.
Update[29-May-2008]:
If you delete the source files and then generate the model code, you will find that the comments are appropriately generated:
No need of dynamic templates to do this. I'll be explaining the dynamic templates anyway in another tip!
May 17, 2008
Adding comments to the generated EMF classes
Subscribe to:
Post Comments (Atom)

0 comments:
Post a Comment