Sunday, September 14, 2008

Reorder Eclipse Plug-in for Java Editor

The asymmetrical way in which the , (comma) is used to separate the items in parameter and arguments lists always causes problem when one wants to reorder that list in Java editor. Is that why Java allows trailing commas in array initializer? ;) may be. The Reorder plug-in supports single click swapping of a parameter, argument or array initializer expressions with previous or next item in the list. Each item of the sequence can be a simple literal, an identifier or a more complex function call expression. The comma delimiter is correctly handled.

This plug-in adds two toolbar buttons to the Java editor:

  • Swap backward
  • Swap forward


With the caret at | in:

void method(int iii, String |sss, boolean bbb){}
pressing the Swap forward button yields:
void method(int iii, boolean bbb, String |sss){}
or pressing Swap backward button with the original source yields:
void method(String |sss, int iii, boolean bbb){}

You can download the plug-in from here.


  • Key bindings for the actions
  • Generalization of the concept to other language editors

DISCLAIMER: This plug-in is experimental. So no guarantees. Use the plug-in at your own risk.

No comments: