Eclipse 3.0 - New and Noteworthy

Java Refactoring

Quick menus for source and refactoring actions

The refactoring and source commands can be accessed via a quick menu. Select the element to be manipulated in the Java editor or in a Java view and press Alt+Shift+S for the quick source menu or Alt+Shift+T for the quick refactor menu.

The Quick Refactoring Menu

Refactorings update references in Javadocs Rename, Move, and Change Method Signature refactorings now update references in Javadoc comments too. This includes references in @see and @link tags, as well as @param and @throws clauses.

The Rename dialog has been simplified as a consequence:

Rename Type Dialog

The old option Update references in Javadoc comments has been folded into Update references. The old options Update references in regular comments and Update references in string literals have been merged into Update textual matches in comments and strings.

Generalize Type refactoring Select a declaration of a variable, parameter, field, or method return type in a Java editor and choose Refactoring > Generalize Type.

Generalize Type - Wizard

The wizard shows the supertype hierarchy for the variable. Selecting one of the available types updates the declaration.

Generalize Type - After

Introduce Factory refactoring Select a constructor declaration or call in the Java editor and choose Refactoring > Introduce Factory.

Introduce Factory - Before

Introduce Factory Wizard

A static factory method is created that calls the now-private constructor, and all calls to the given constructor are replaced with calls to the new factory method.

Introduce Factory - After

Introduce Parameter refactoring Select an expression in a Java editor and choose Refactoring > Introduce Parameter.

Introduce Parameter - Before

The containing method is given a new parameter and the selected expression is copied to the argument list of all the call sites.

Introduce Parameter - After

Improved Change Method Signature refactoring In the Java editor, select a method and choose Refactoring > Change Method Signature.

Change Signature Wizard

The refactoring now
  • renames parameters in overriding methods as well,
  • updates references in javadocs
  • offers Content Assist (Ctrl+Space) in the parameter type column,
  • allows to change the method name,
  • allows to change thrown exceptions.

Furthermore, editing in the parameters table has been streamlined such that you can use standard navigation keys (Tab, Shift+Tab, Arrow Up & Down). Editing can be started by clicking into a cell, or pressing F2 or Enter.

Extract Method from inner types

For Java code contained in an anonymous, local, or non-static member type, the Extract Method refactoring now allows the new method to be created in an outer type.

Extract Method Wizard

Extract method finds duplicate code fragments

Extract method now finds duplicate code fragments and helps extracting them into the new method as well. For example, when extracting the expression foo(a) + bar(b) from the snippet:

Extract Method Wizard

the resulting code is:

Extract Method Wizard

Previous     Next

Copyright 2000, 2004 IBM Corporation and others.