Community
Participate
Working Groups
Build ID: I20070621-1340 Steps To Reproduce: 1. Use default Code Formatter settings: Eclipse: [built-in] 2. Enter this code fragment: import a.b; // import c.d; import e.f; 3. Run the Code Formatter 4. Result is this: import a.b; // import c.d; import e.f; This doesn't make a lot of sense; but also: - it happens even if you switch off all comment formatting in the Comments tab; - it didn't happen in 3.2; - it isn't consistent, because if you format just this: import a.b; // import c.d; you get this: import a.b; // import c.d; So it looks like buggy behaviour to me. More information:
Ownership has changed for the formatter, but I surely will not have enough time to fix your bug during the 3.5 development process, hence set its priority to P5. Please provide a patch if you definitely need the bug to be fixed in this version and I'll have a look at it... TIA
I'll have look on this as it could be interesting to fix it before fixing bug 293300...
Here's a simple test case to show this issue: import java.util.List; //import java.util.HashMap; import java.util.Set; public class X { } Using the Eclipse built-in profile, it is formatted as follow: import java.util.List; //import java.util.HashMap; import java.util.Set; public class X { } Note that this was properly formatted with Eclipse 3.2.2
Created attachment 151423 [details] Proposed patch This is a big patch as it also remove duplicated methods to print comment: - printTrailingComment() - printTrailingComment(int) Note that the strategy for trailing comments has not been really modified, just integrated in the printComment(int, int) method to allow fixes around comments consuming easier to do (e.g. bug 293300). Note also the specific algorithm for trailing comments consumed in import declarations area. This was a little bit tricky as in some cases, comments have to be consumed as trailing comments and in some other cases as common comments... This patch passes all JDT/Core tests (of course) but also all formatter massive regression tests on the 3 full sources workspaces (Eclipse 3.0, Galileo and JDKs) where it fixes respectively 9, 31 and 61 invalid formatting outputs produced by the current version in HEAD...
Created attachment 151464 [details] Proposed patch (store elapsed time in massive tests) Same patch but improve FormatterMassiveRegressionTests to dump the time spent to format all units and save the results in log file. Doing this I also verified that the new algorithm didn't introduce performance regression.
I also run the massive tests for different formatter profiles - Eclipse built-in - Eclipse built-in + no comments - Eclipse built-in + join lines only in comments - Eclipse built-in + join lines only in comments + all braces on next line and didn't notice any regression either... So, as all tests are green, I have released the patch for 3.6M4 in HEAD stream.
(In reply to comment #6) > So, as all tests are green, I have released the patch for 3.6M4 in HEAD stream. Definitely. Thanks for the good work, Frédéric!
Verified for 3.6M4 using I20091207-1800