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

Bug 308372

Summary: GEF project should define and adopt source code formatting guidelines
Product: [Tools] GEF Reporter: Alexander Nyßen <nyssen>
Component: MiscAssignee: Alexander Nyßen <nyssen>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: aboyko, ahunter.eclipse, irbull, steeg, unger
Version: 3.6   
Target Milestone: 3.6.0 (Helios) RC2   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Java-Editor Auto-Save settings none

Description Alexander Nyßen CLA 2010-04-07 13:39:10 EDT
As part of the definition of a proper GEF development environment, source code formatting guidelines should be specified (which could at easiest be the Eclipse built-in formatter profile) and the existing source code should be re-formatted to match these guidelines. 

Currently there is no project-specific definition about which formatter settings to apply to GEF source code, while most of the existing source code does also not comply with the Eclipse built-in formatter profile. This way, creation and adoption of patches can be difficult only because of formatting issues that easily arise. I would thus propose to adopt the Eclipse built-in formatter settings to all of the existing GEF source code and to prescribe them as part of a GEF development environment from that moment on, so that contributors can more easily create patches.
Comment 1 Anthony Hunter CLA 2010-04-09 10:55:21 EDT
Next week I will select each of the Draw2d, Zest and GEF bundles and do an organize imports and then a source format. I plan to leave the code formats the same as the default in Eclipse 3.6.

I am going to look and see if the platform has changed any of the defaults in their bundles, I do not think they have.

Let me know if this is not a good thing.
Comment 2 Alexander Nyßen CLA 2010-04-09 11:12:03 EDT
For me the default formatter settings are fine, nevertheless because they enable contributors to create patches without having to set up special formatters in their development environment.

I would recommend to also specify an auto-save action (as a project-specific setting) for all plugins to ensure formatting/organizing imports is always performed upon saving changes. This would help to prevent that the format can become invalid again just because somebody forgets to apply the formatter/organizer. It may also ensure that all patches are created w.r.t. the defined formatter settings and do not use unnecessary imports.
Comment 3 Ian Bull CLA 2010-04-09 12:35:35 EDT
(In reply to comment #1)
> Let me know if this is not a good thing.

This seems ok, the only concern I have is with outstanding patches... they likely won't apply after re-formatting the code.

For Zest this should be ok.  What about the Draw2D and GEF bundles?
Comment 4 Anthony Hunter CLA 2010-04-09 14:34:34 EDT
As I said in the gef-dev newsgroup, I went though all the defects in Bugzilla with patches and added comments with regards to each defect.

I have not gone though the feature patches, but most are old. I imagine if someone wants their contribution, they would be willing to create a new patch for Post Helios.
Comment 5 Andreas Unger CLA 2010-04-13 05:51:57 EDT
I agree that proper formatting guidelines should be defined, however, I'm not really happy with the default settings of the Eclipse formatter. Especially the 80-character line limitation is not appropriate nowadays. In my opinion, code that has been formatted with the default settings is unreadable.
Comment 6 Anthony Hunter CLA 2010-05-03 13:10:25 EDT
We released 3.6 M7 today so moving unresolved bugs to 3.6 RC1.

We need to re-access if we can complete these for Helios.
Comment 7 Alexander Nyßen CLA 2010-05-03 14:58:07 EDT
Anthony, wouldn't it be a good opportunity to perform re-formatting now, directly after the milestone has been build?
Comment 8 Anthony Hunter CLA 2010-05-17 15:35:46 EDT
We have two active bugs with patches going on. The second we get these in I am going to:

- format
- organize imports
- update copyrights
Comment 9 Anthony Hunter CLA 2010-05-19 16:27:59 EDT
Committed "Organize Imports" to HEAD(In reply to comment #8)
> We have two active bugs with patches going on. The second we get these in I am
> going to:
> 
> - format
> - organize imports
> - update copyrights

Committed in three deliveries to HEAD:

- organize imports
- format
- update copyrights

Using Eclipse 3.6 RC1
Comment 10 Alexander Nyßen CLA 2010-05-19 16:38:02 EDT
Created attachment 169219 [details]
Java-Editor Auto-Save settings

May I propose that - as I already mentioned - we also define an auto-save action for the java-editor to ensure that formatting and imports remain intact (I have added a screenshots with the settings we could use)?
Comment 11 Anthony Hunter CLA 2010-05-19 16:42:10 EDT
Sounds good to me, can you commit the new org.eclipse.jdt.ui.prefs to each of the plugins in GEF/Draw2d/Zest ?
Comment 12 Alexander Nyßen CLA 2010-05-19 16:44:11 EDT
Yes, I will take care.
Comment 13 Anthony Hunter CLA 2010-05-19 16:46:12 EDT
We forgot to add Fabian to this Bugzilla so he is aware too. I will let Fabian
do these activities to the dot4zest plugins.
Comment 14 Alexander Nyßen CLA 2010-05-19 16:53:09 EDT
Committed preference-settings for all Java-nature plug-ins of Draw2D, GEF, and Zest (
despite org.eclispe.zest.core, which already had defined more strict options, including the organization of imports and the re-formatting) to cvs HEAD.
Comment 15 Alexander Nyßen CLA 2010-05-19 16:58:25 EDT
Updated the Contributor Guide (http://wiki.eclipse.org/GEF_Contributor_Guide) to mention this as well.
Comment 16 Fabian Steeg CLA 2010-05-24 12:14:58 EDT
(In reply to comment #13)
> We forgot to add Fabian to this Bugzilla so he is aware too. I will let Fabian
> do these activities to the dot4zest plugins.

Thanks for adding me - I have updated the formatting, headers and settings in the dot4zest plugins.