Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 210040 - activate automatic formating on Java editor save
Summary: activate automatic formating on Java editor save
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Mylyn (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P1 trivial (vote)
Target Milestone: 3.0   Edit
Assignee: Steffen Pingel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 221043
  Show dependency tree
 
Reported: 2007-11-15 17:31 EST by Steffen Pingel CLA
Modified: 2008-03-02 18:16 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Steffen Pingel CLA 2007-11-15 17:31:52 EST
Enable automatically formatting of source files on editor saving for all Mylyn projects.
Comment 1 Eugene Kuleshov CLA 2007-11-15 17:42:26 EST
If my opinion counts, please don't do this. Steffen you'll be the first one to complain about changed whitespaces in patches.
Comment 2 Steffen Pingel CLA 2007-11-15 18:02:20 EST
One reason I filed this bug is that I hope we would get less patches with white space changes in the future. It will simply automate the policy of always formatting code before check-in that already exists.
Comment 3 Mik Kersten CLA 2007-11-23 17:34:59 EST
I think that it is important for us to do this in order to do this, because after the up-front cost of having to use the Fuzz Factor in patches, we will ensure that patches do not add improperly formatted code to our source code base.  This has been a problem because it makes stack traces innacurate.  Also, in the end means that we end up with more trouble for accepting patches, because committers will randomly end up reformatting the whole file when they get to it.

We should make sure that we have as many patches applied as possible before doing this.  
Comment 4 Eugene Kuleshov CLA 2007-11-23 18:13:34 EST
(In reply to comment #3)
> ...it is important for us to do this in order to do this...

Mik, I read the whole comment several times but still don't understand what you've been trying to say. Can you please summarize in one sentence if you are voting for automatic formatting or against it. Thanks.
Comment 5 Mik Kersten CLA 2007-11-23 21:44:26 EST
Sorry if it wasn't clear.  I stated "it is important for us to do this", i.e. I'm voting for it.
Comment 6 Steffen Pingel CLA 2007-12-04 18:17:37 EST
Rob, what are your thoughts?

In addition I would like to enable these code cleanups which will enforce coding standards that we have and enforce additional good coding practices:

- Organize Imports
- Convert control statement bodies to block
- Add final modifier to private fields
- Add missing '@Override' annotations
- Add missing '@Deprecated' annotations
- Remove unnecessary casts
Comment 7 Mik Kersten CLA 2007-12-05 21:17:02 EST
+1 for all proposed, except perhaps "Add final modifier..", unless that's a best practice used elsewhere.  

Steffen: do you know what settings Platform uses?
Comment 8 Steffen Pingel CLA 2007-12-05 21:53:36 EST
I looked at a few jdt and pde projects but none had any cleanup or save participant rules configured on a project basis. I don't know if platform has any guidelines for this.

I am fine with leaving the "Add final modifier..." disabled. It would probably make sense to run these rules on the whole code base once so we don't end up with whitespace changes in all commits after enabling this (e.g. before the next release is tagged).
Comment 9 Eugene Kuleshov CLA 2007-12-06 00:05:04 EST
May I suggest to do that after pending patches are applied
Comment 10 Mik Kersten CLA 2007-12-06 11:51:16 EST
+1 for doing before tagging.  This will help keep the 2.2 and later stack traces stable.  Note that clean up can be invoked via popup menu on one or more source folders.  Please comment before you start on this so that we can make sure as many patches as possible are applied.
Comment 11 Steffen Pingel CLA 2008-02-07 17:14:25 EST
I have been using (manual) code cleanup for a while now and find it very useful to add the final modifier for fields that are not muted. This cleanup makes it very easy to identify fields that change throughout the life-cycle of an object and helps to refactor classes to make them immutable which is a good practice. The cleanup can also help to identify programming errors when a final modifier is not added although it was expected (e.g. due to a missing assignment in the constructor). Unless there are objections I would therefore like to enable the "Add final modifier to private fields" cleanup.

To avoid "breaking" 2.x stack traces the code clean up will happen in HEAD as soon as 2.3 is released and branched. We will go through the outstanding patches before that and determine if they should be applied before the cleanup.
Comment 12 Mik Kersten CLA 2008-02-12 12:43:11 EST
Sounds great.
Comment 13 Steffen Pingel CLA 2008-03-01 16:47:52 EST
I have enabled the clean up and applied it to all plug-ins in HEAD except for bugzilla (bug 221043). The code has been tagged with these tags:

 bug_210040_code_cleanup_before
 bug_210040_code_cleanup_after
Comment 14 Steffen Pingel CLA 2008-03-01 16:48:04 EST
Done.
Comment 15 Mik Kersten CLA 2008-03-02 18:16:50 EST
Hmmm, interesting, in this case I quite like the association between the tag and the bug that describes it.