Bug 203965

Summary: Sort members incorrect sorts dependant variables
Product: [Eclipse Project] JDT Reporter: Brian Curnow <brian.curnow>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: VERIFIED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: jerome_lanneluc
Version: 3.3   
Target Milestone: 3.4 M3   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Brian Curnow CLA 2007-09-19 09:01:17 EDT
A class defined like this:

public class Good {
    private static final String B = "This is a" + A;
    private static final String A = " test";
}

(which doesn't compile) 

Will be correct sorted to:

public class Good {
    private static final String A = " test";
    private static final String B = "This is a" + A;
}

Because the variables are sorted in alphabetic order, however, the class:

public class Bad {

    private static final String B = " test";
    private static final String A = "This is a" + B;
}

(which does compile)

Will be incorrectly sorted to:

public class Bad {

    private static final String A = "This is a" + B;
    private static final String B = " test";
}

(which *does not* compile)

Sort members should not simply sort the variable name but should also take into account the dependency between variables.
Comment 1 Jerome Lanneluc CLA 2007-09-19 09:45:40 EDT
Sort members only considers the source, no resolution is done (you need to resolve "B" to know that it binds to field B).
No plan to change this.
Comment 2 Frederic Fusier CLA 2007-10-29 07:15:02 EDT
Verified for 3.4M3 using I20071029-0010 build.