Bug 218542 - [clean up] sort members sorts fields by visibility even if field sorting is disabled
Summary: [clean up] sort members sorts fields by visibility even if field sorting is d...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows 2000
: P3 major (vote)
Target Milestone: 3.4 M6   Edit
Assignee: Benno Baumgartner CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-02-11 13:46 EST by Wes Isberg CLA
Modified: 2008-03-25 18:29 EDT (History)
3 users (show)

See Also:


Attachments
fix (5.21 KB, patch)
2008-02-12 04:18 EST, Benno Baumgartner CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Wes Isberg CLA 2008-02-11 13:46:01 EST
Sort-members-but-ignore-fields fails to prevent sorting by member access, which results in field reordering that causes compiler error.

(1) In Preferences, 
(a) In Java, editor, save action, enable "Code Organizing" tab, "Members" section, "Sort members" checkbox and "Ignore fields and enum constants" radio button
(b) In Java, appearance, Members Sort Order, enable checkbox "Sort members in same category by visibility"

(2) Create the following class:
package main;
public class Main {
	static final Object b = "a";
	public static final Object a = b;
}

(3) Edit (add spaces) and save
RESULT: a re-ordered before b, causing compile-time error
True in 3.4M5 and 3.3.1.1.

Workaround: disable (1)(a) or (b).  This means we can't use save actions to enforce code formatting for our team.  We do want methods sorted.
Comment 1 Wes Isberg CLA 2008-02-11 13:47:30 EST
Suggesting M6 schedule :)
Comment 2 Dani Megert CLA 2008-02-12 02:38:22 EST
Ugly but probably not easy to detect without flow analysis or temporary compilation in the background.

Wes, please don't set priority and target milestone. Those fields are reserved for the developers.
Comment 3 Dani Megert CLA 2008-02-12 03:24:21 EST
>Ugly but probably not easy to detect without flow analysis or temporary
>compilation in the background.
Actually, this is not needed as "Ignore fields and enum constants" is selected. Hence we probably just forgot to apply this when doing the visibility dance.
Comment 4 Benno Baumgartner CLA 2008-02-12 03:42:37 EST
Yes, the fields must not be sorted if 'do not sort fields' is enabled, no matter
what. Sort Members action has the same problem, probably like this since day
one.
Comment 5 Benno Baumgartner CLA 2008-02-12 04:18:30 EST
Created attachment 89483 [details]
fix

Got introduced by bug 65304
Comment 6 Benno Baumgartner CLA 2008-02-12 04:21:46 EST
fixed > I20080206-1800
Comment 7 Wes Isberg CLA 2008-02-12 11:36:06 EST
Sorry about trying to set a schedule.  Thanks much for the quick reply and fix.  That encourages me to write up more of the bugs I find.
Comment 8 Martin Aeschlimann CLA 2008-03-25 18:29:11 EDT
verified in I20080325-0100