Steve Chambers Steve Chambers - 1 month ago 8
Java Question

Is there a way of adding exclusions to Eclipse's "Sort all members"?

In general I like the "Sort all members" feature in Eclipse and have it turned on for the Save Actions.

However, occasionally I'd like to stop it for individual sections, e.g. enumerations. Is there a way of doing this?

Am aware of the "Ignore fields and enum constants" option but not keen on using this as in generally like my fields in alphabetical order. Also know I can undo the change after the first save and then save it again - but don't want to have to remember to do this every time.

Answer

I found the best way of doing this is to have the "Ignore fields and enum constants" option ticked for the Save Actions but unticked in Java Code Style - Clean Up. Then you can clean up manually as required via Source - Cleanup... and change anything that doesn't reorder correctly before saving.

Not ideal but seems the best way given Eclipse's limitations...