Community
Participate
Working Groups
(customer request) CompilationUnits occasionally end up with field definitions spread throughout the file. It is a tedious (manual) task to get all of the fields brought together at the top of the file. It would be useful if there was a way to make this occur. It could possibly be a formatting option, or a menu operation. It is difficult to ask for a menu operation since this is not a common operation (and would add clutter). It is possible to add a pre-processor to the formatter for code reorganization before invoking the code formatting engine.
John, would fixing bug 13013 help you here? you could drag the fields and drop them over the type icon, which would drop them there - at the top of the type definition
jindent supports this sorting option. The formatter is pluggable and it would be possible to integrate jindent into Eclipse. No plans to add this to the built-in formatter.
Reopening
This is more a formatting issue than a refactoring issue. Moving to JDT Core for commenting. They are investigating in a new formatter infrastructure.
Still, reordering source may cause binary compatibility issues (innerclasses numbered differently). Therefore I am reluctant to consider it as a formatting feature. However, I would want to have such a feature too, along with a way to sort members by name (fields, types then methods). I think this can be implemented in term of the JavaModel alone... like the fragmented source view.
Just for clarification, I too think it should be some kind of pre-processing of the source. Not part of the formatter, since they are occasions where I only want to resort, not touch the formatting.
Maybe this should be part of the formatter, simply with a lightweight mode.
This is a subset of the request in bug 14597. *** This bug has been marked as a duplicate of 14597 ***