In Eclipse IDE how do you customize the Java code style formatter to have it sort the class members with a specified order, for example to group all instance methods by visibility?
+2
A:
If the question is, "how do you customize the 'Source -> Format' command to re-order members?", I don't think it can be done. To change the order used for the 'Source -> Sort Members' command, change the "Members Sort Order" preference: "Window -> Preferences -> Java -> Appearance -> Members Sort Order"
Chris Conway
2008-10-13 16:28:45
It seems to me this only affects the sort order in viewers, e.g. an outline. It does not reformat the source file.
Joel
2008-10-13 16:53:27
This is the order that will be used if you do "Source -> Sort Members". "Source -> Format" does not re-order members AFAIK.
Chris Conway
2008-10-13 17:16:40
A:
Another way to do this is to perform a code Clean Up:
Setting sorting order:
1 - Window -> Preferences -> Java -> Appearance -> Members Sort Order - Check "Sort members in same category by visibility
2 - Window -> Preferences ... Java -> Code Style -> Clean up ... On code Organizing, select Sort Members
Clean up:
3 - On your java source, right click -> Source -> Clean up.
André
2009-12-10 19:45:46