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

Bug 30661

Summary: Source code ordering during code generation/formatting [code manipulation]
Product: [Eclipse Project] JDT Reporter: Valentin Baciu <valentinbaciu>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: RESOLVED WONTFIX QA Contact:
Severity: enhancement    
Priority: P3 Keywords: helpwanted
Version: 2.1   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Valentin Baciu CLA 2003-01-30 15:05:15 EST
There is a preference that allows changing the order in which Java source code 
elements are displayed in views (for example in the outline view).

I propose adding a preference that controls the order in which the source code 
is sorted (inserted) during code generation/formatting.

For example, if I use QuickFix to add a missing field, I want the field be 
placed at the end of the class' fields list. The code generator insists on 
placing it at the top of the class.

Similar for generating getters and setters. They are usually added at the
end but I want them added together with the other getters and setters,
preferably after the ones I have already but before the fields.

I know this is not how Sun's source code is usually written but in our
environment we prefer to have things sorted in the following order:

    public static fields
    constructors
    public methods
    protected methods
    private methods
    protected fields
    private fields

If possible, the code that controls this could also be used during code
formatting.
Comment 1 Philipe Mulet CLA 2003-01-30 16:52:33 EST
JDT/Core provides an API to sort compilation units using some custom 
Comparator. It is independant from actual formatting (we have a request to 
integrate this to our new formatter already).

Moving to JDT/UI which is surfacing this.
Comment 2 Dirk Baeumer CLA 2003-01-31 05:29:02 EST
For 2.1 we will only provide an action to sort the members as defined in 
prefernences->Java->Appearance->Member Sort Order.

But for 2.2 we should open this so that other plug-ins can provide their own 
sorting/ordering page.

Postpone > 2.1
Comment 3 Denis Roy CLA 2009-08-30 02:19:04 EDT
As of now 'LATER' and 'REMIND' resolutions are no longer supported.
Please reopen this bug if it is still valid for you.