Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 281324

Summary: Add ability to run a source Clean Up after code generation
Product: [Modeling] EMF Reporter: Thomas Hallgren <thomas>
Component: ToolsAssignee: Dave Steinberg <davidms>
Status: CLOSED DUPLICATE QA Contact:
Severity: enhancement    
Priority: P3 CC: Ed.Merks, marcelop
Version: 2.5.0   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Thomas Hallgren CLA 2009-06-24 05:00:10 EDT
The genmodel has a property to enable automatic code formatting on generated code. It would be great if this was extended to include a full code clean-up. Many projects have clean-up rules that include code formatting and additional things like members sort order, removal of unnecessary imports, annotations, etc.
Comment 1 Ed Merks CLA 2009-08-02 12:15:08 EDT
*** Bug 285367 has been marked as a duplicate of this bug. ***
Comment 2 Ed Merks CLA 2009-08-09 08:56:21 EDT
Marcelo,

I seem to recall having looked at this in the past and that there was no programmatic way to invoke cleanup as part of code generation (which needs to work without the UI).
Comment 3 Marcelo Paternostro CLA 2009-08-09 11:58:40 EDT
Although I can do a second investigation, a quick search on Google indicates that JDT's Clean Up feature is still tied to the UI.  The second link below (from October, 2008) sort of shows that things have not changed too much since I've looked at it.

http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.jdt.doc.isv/reference/api/org/eclipse/jdt/ui/cleanup/package-summary.html
http://dev.eclipse.org/newslists/news.eclipse.tools.jdt/msg23593.html

Comment 4 Thomas Hallgren CLA 2009-08-09 15:02:07 EDT
Perhaps something similar to what Achim does in bug 278844 is needed. If it's in the same vicinity, perhaps the timing is good to file another bugzilla.
Comment 5 Thomas Hallgren CLA 2009-10-05 17:05:33 EDT
I find myself cleaning up, over and over again, and still being uncertain if I forgot some clean up every time I check in.

It would help me a lot even if the genmodel did a clean-up automatically only when running with a UI. In fact, I don't see myself ever generating the model code and then checking-in when running headless.

I do understand that running headless code generation as part of a build is very interesting. But a clean-up is a bit different in that it's often not needed in that scenario. If the code builds, who cares if it looks nice right? In contrast, when you do actual work on the code in your IDE with the intention of checking it in to a SCM, it's essential that the clean-up is performed. Both because you'd like to see it in nicely cleaned and formatted while working, and perhaps more importantly that a failure to do that will create a merge hell.

Would it be difficult to add this as a UI only function?
Comment 6 Dave Steinberg CLA 2009-10-06 11:02:03 EDT
I think it would be somewhat difficult, as all compilation-unit-level handling happens in the UI-independent code. It sounds like this would be a nice convenience but, unfortunately, with things as tight as they are, I just can't see it as a priority.
Comment 7 Ed Merks CLA 2012-10-17 10:47:42 EDT
We now clean up used imports during merge so that's the most important cleanup I believe.

*** This bug has been marked as a duplicate of bug 175282 ***