Community
Participate
Working Groups
Build Identifier: 20110301-1815 Using Sort Members / sort all members on an enum set up like this: public enum Test { Second, // second comment First, // first comment Third // third comment } results in a sorted list of variables, but the comments don't move with them: public enum Test { First, // second comment Second, // first comment Third // third comment } I was also able to use comments like /* first comment */ and they also did not get moved when the Sort Members was used. I wasn't sure if this was a "Normal" bug -- if you aren't paying attention, your code becomes fouled, but execution is not broken. Reproducible: Always Steps to Reproduce: 1. Create enum like: public enum Test { Second, /* second comment */ First, /* first comment */ Third /* third comment */ } 2. Either select the file in Package Explorer and select Sort Members or use Alt+Shift+S, M, <enter>, then select sort all members, OK 3. you should get the errant result like this: public enum Test { First, /* second comment */ Second, /* first comment */ Third /* third comment */ } Note the comments are wrong
Moving to JDT/UI
The CompilationUnitSorter is in JDT/Core. If I compare enum constants to e.g. class fields, a difference I see is that the extended source range of the fields include the comments, but the enums don't. package xy; public enum Test { Second, // second comment First, // first comment Third // third comment } class Klazz { int fSecond; // second comment boolean fFirst; // first comment long fThird; // third comment }
BTW: The correct way to document enum constants is to use Javadoc: public enum Test { /** second comment */ Second, /** first comment */ First, /** third comment */ Third }
Thanks Markus. I'll investigate.
(In reply to comment #3) > BTW: The correct way to document enum constants is to use Javadoc: > > public enum Test { > /** second comment */ > Second, > /** first comment */ > First, > /** third comment */ > Third > } Perferred perhaps... correct implies what was done was incorrect which is arguable. Regardless, had I used this method, the sorting appears to work but I would hope the issue can still be resolved as it can unknowingly create misleading comments in the code. Had they been // TODO: reminders they would have been messed up as well.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.