GMF aspects: organize java imports [message #635887] |
Thu, 28 October 2010 13:46  |
Eclipse User |
|
|
|
Hello,
I recently discovered that you can customize the code generation by using aspects. This makes the code much more maintainable and avoid to modify the generated code directly.
I was wondering how the java imports work ? When I customize some of the define blocks and try to use some custom types, I get errors in my generated code since the type cannot be resolved (opening the file and adding the java import fixes the problem).
I noticed that this is somehow automatically done in the GMF templates: fully qualified names are used everywhere but are then removed after the code generation and replaced by their corresponding import.
I tried to do the same but the fully qualified names are not replaced (and there's no additional import).
How can I do something similar as in the original GMF templates ?
|
|
|
Re: GMF aspects: organize java imports [message #635891 is a reply to message #635887] |
Thu, 28 October 2010 14:07   |
Eclipse User |
|
|
|
Hi,
we are using it and the import are well done.
I don't remember of any customization to do that working.
One idea, are you regenerated MANIFEST.MF too?
if no, perhaps you should try to set "required plugin identifiers" in gmfgen->gen editor generator -> gen plugin?
Regards,
|
|
|
Re: GMF aspects: organize java imports [message #635895 is a reply to message #635891] |
Thu, 28 October 2010 14:30   |
Eclipse User |
|
|
|
Hi Aurelien,
Thanks for your answer.
I tried to remove the Manifest.MF so that it is completely regenerated on the next code generation but this doesn't fix the problem.
I looked at the option in the gmfgen file about the required plugin identifiers but it looks strange to me, since there are only two identifiers (related to Draw2D), so the existing code generation doesn't really work with that.
In fact, how does the code generator add the java imports on top of the generated files ? Was my assumption correct ?
Because I looked at some of the GMF templates and saw that they always use fully qualified names which are not present anymore in the generated file.
By the way, I discovered the aspects in GMF because of your blog, so thanks for that too
|
|
|
Re: GMF aspects: organize java imports [message #635898 is a reply to message #635895] |
Thu, 28 October 2010 14:34   |
Eclipse User |
|
|
|
Cedric wrote on Thu, 28 October 2010 16:30 | Hi Aurelien,
I tried to remove the Manifest.MF so that it is completely regenerated on the next code generation but this doesn't fix the problem.
I looked at the option in the gmfgen file about the required plugin identifiers but it looks strange to me, since there are only two identifiers (related to Draw2D), so the existing code generation doesn't really work with that.
|
Add your own plugin identifier and regenerate cleaning also the MANIFEST.MF. So like that, the import can be resolved.
Cedric wrote on Thu, 28 October 2010 16:30 |
In fact, how does the code generator add the java imports on top of the generated files ? Was my assumption correct ?
|
I believe that there is a java beautifier action done at the end of the generation.
Cedric wrote on Thu, 28 October 2010 16:30 |
By the way, I discovered the aspects in GMF because of your blog, so thanks for that too
|
Happy that it helps you 
|
|
|
Re: GMF aspects: organize java imports [message #636037 is a reply to message #635898] |
Fri, 29 October 2010 06:43  |
Eclipse User |
|
|
|
Hello Aurélien,
Thanks for your answer. I tried your suggestion but the problem still persists. In fact, it works fine for all qualified names except when it comes to my own plug-ins.
Even when the fully qualified name points to some generated code (like for instance the Messages class which is in the XXXX.diagram.part package).
Anyway, for all the other classes it works fine, so I guess this is not really important. I'll simply have the fully qualified name sometimes in the generated code.
Anyway, thanks for your help !
Cédric
|
|
|
Powered by
FUDForum. Page generated in 0.03872 seconds