Alex headshot

AlBlue’s Blog

Macs, Modularity and More

Sort Members now available as a clean up

2007, eclipse

After much time spent complaining about Eclipse, I've finally got off my posterior and contributed some code to Eclipse 3.3. (Actually, I contributed something for Eclipse 3.2 -- the "PDE Tools -> Open Manifest" when right-clicking on a plug-in project was mine; but hey, that's just a menu entry.) Now it's possible to perform 'Sort Members' as part of the Clean Up profiles in Eclipse, along with formatting code and organising imports. In fact, the Clean Up is better than the menu item by the same name, because if there are no changes needed then the Clean Up doesn't perform any changes. (The Sort Members will open an editor for each file that it needs to process.)

Given that you can hook up a Clean Up profile to be a save participant, it now means that you can sort members on any code when saving, thereby guaranteeing that the methods are always in sorted order (and thus minimising the chances of collisions in a version control system). It's off by default, but you might want to consider adding it to your list-of-things that should be set up on a project when defining coding standards for the rest of the team.

Separately, you should also now be able to select just sorting of members and optionally fields or enumerations. At the moment, it's an all-or-nothing thing; you can sort both or neither. There's a patch in the queue for this change, as well as allowing Sort Members to be done on the project/package level (instead of separately on each Java file) which may make it in at some point. Feel free to Cc yourself onto that bug in order to keep track of what happens there.