Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 279924 - [toString] toString() generator: Fields in declaration order
Summary: [toString] toString() generator: Fields in declaration order
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.5   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 3.6 M1   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-11 07:12 EDT by Vinayasimha CLA
Modified: 2009-06-16 12:31 EDT (History)
2 users (show)

See Also:


Attachments
patch (15.20 KB, patch)
2009-06-12 10:54 EDT, Mateusz Matela CLA
markus.kell.r: iplog+
markus.kell.r: review+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Vinayasimha CLA 2009-06-11 07:12:35 EDT
toString() generator adding the fields in alphabetical order. It would be better if it adds in the order whatever the order fields declared in the class.
Comment 1 Walter Harley CLA 2009-06-11 11:50:23 EDT
Moving from APT to Text - this has nothing to do with APT.
Comment 2 Markus Keller CLA 2009-06-11 12:33:48 EDT
We had a similar problem with 'Generate Constructor using Fields', see bug 215161. The essence of the fix there was that IType#getFields() is always in source order (that's also the case for IType#getChildren()).

If the alphabetic order is still deemed worthwhile in the end, we could add a 'Sort' button on the right.

Mateusz, are you interested?
Comment 3 Mateusz Matela CLA 2009-06-12 07:42:11 EDT
Yep, I'm on it.
Comment 4 Mateusz Matela CLA 2009-06-12 10:54:53 EDT
Created attachment 139037 [details]
patch
Comment 5 Markus Keller CLA 2009-06-16 12:30:43 EDT
Sweet, thanks! Released to HEAD with 2 changes:

GenerateToStringAction#populateMembers(..):
Made static, added Javadoc, made type of allMembers more specific.

GenerateToStringContentProvider#sort():
Changed to use com.ibm.icu.text.Collator (Eclipse platform convention).