Eclipse 2.1 - New and Noteworthy

Java Development Tools

Refactoring


New Refactorings

Many new refactoring actions are available:

  • Move Instance Method: this refactoring allows you to move the method to the declared class of one of its parameters or fields. This creates a new method and converts the old method into a delegate (passing it a pointer to this if necessary).
  • Push Members Down: this refactoring allows you to move a set of methods and fields from a class to its subclasses.
  • Inline Method: this refactoring inlines calls to a particular Java method, either at a selected call site or everywhere the method is called. It is available polymorphically via the Refactor > Inline menu entry.
  • Inline Constant: this refactoring inlines uses of a particular Java static final field, either at a selected reference site or everywhere the field is referenced. It is available polymorphically via the Refactor > Inline menu entry.
  • Extract Constant: this refactoring creates a static final field from the selected expression and substitutes a field reference, and optionally rewrites other places where the same expression occurs.
  • Convert Local Variable to Field: this refactoring allows you to turn a local variable into a field. If the variable is initialized on creation, then the operation moves the initialization to the new field's declaration or to the class's constructors.
  • Convert Anonymous Class to Nested Class: if an anonymous inner class in your code is too large, this refactoring will help you convert it to a member class.
  • Convert Member Type to Top Level Type: this refactoring creates a new Java compilation unit for the selected member type, updating all references as needed. For non-static member types, a field is added to allow access to the former enclosing instance.
  • Extract Interface: this refactoring creates a new interface with a set of methods and makes the selected class implement the interface, optionally changing references to the class to the new interface wherever possible.
  • Use Supertype Where Possible: this refactoring replaces occurrences of a type with one of its supertypes after identifying all places where this replacement is possible.

Improved Refactorings

Several refactoring actions have been improved:

  • Change Method Signature: this refactoring is a replacement for the Modify Parameters refactoring. It allows you to change a method's visibility and return type, and add, remove, rename and reorder method parameters.
  • Pull Members Up: this refactoring has been improved in several ways
    • you can pull members up more than 1 level in the hierarchy
    • instead of pulling them up, you can declare methods as abstract in the selected supertype
    • you can compute the smallest set of members that need to be pulled up together in order to satisfy visibility constraints
  • Extract Method: you can reorder and rename parameters of the extracted method.
  • Rename and Move Refactorings: when renaming a Java type or package (or when moving a type to a different package), the fully qualified name of the element can now be updated in non-Java files as well.

New lightweight refactoring UI

Activating any Java refactoring operation now shows a small starting dialog to gather information needed to perform the refactoring. Click OK to execute the refactoring without further ado, or click Preview to see its effects before deciding whether to go ahead.

New lightweight refactoring dialog


 

Previous Index Next

Copyright IBM Corporation and others 2000, 2003