The goal of refactoring (behavior-preserving program transformation) is to make a system-wide code change without affecting the behavior of the system. The JDT provides assistance for managing refactorings.
The JDT supports a number of transformations (e.g. Extract Method, Inline Local Variable) described in Martin Fowler's book "Refactoring: Improving the Design of Existing Code", Addison Wesley 1999.
When performing a refactoring operation, you can optionally preview all the impending changes resulting from a refactoring action before you choose to carry them out. Thus, you can execute a refactoring in one of two ways:
Refactoring with preview
In a controlled refactoring, you are notified of potential problems and are given a detailed preview of what the refactoring action will do.
Refactoring without preview
In a quick refactoring, the potential problem notification and preview are omitted. If a Stop problem is detected, the refactoring will be halted and a list of problems will be displayed.
Refactoring commands are available from the context menus of several Java views (e.g. Package Explorer, Outline) and editors.
Refactor menu commands:
Starts the Rename refactoring wizard: Renames the selected element and (if enabled) corrects all references to the elements (also in other files). Is available on methods, fields, local variables, method parameters, types, compilation units, packages, source folders, projects and on a text selection resolving to one of these element types.
Starts the Move refactoring wizard: Moves the selected elements and (if enabled) corrects all references to the elements (also in other files). Can be applied on one or more static methods, static fields, types, compilation units, packages, source folders and projects and on a text selection resolving to one of these element types.
Starts the Pull Up refactoring wizard: Moves a field or method to its super class. Can be applied on one or more methods and fields from the same type or on a text selection resolving to a field or method.
Starts the Modify Parameters refactoring wizard. Changes parameter names and parameter order and updates all references to the corresponding method. Can be applied on methods with parameters or on text selection resolving to a method with parameters.
Starts the Extract Method refactoring wizard. Creates a new method containing the statements or expression currently selected and replaces the selection with a reference to the new method. You can use Expand Selection to from the Edit menu to get a valid selection range. This feature is useful for cleaning up lengthy, cluttered, or overly-complicated methods.
Starts the Extract Variable refactoring wizard. Creates a new variable assigned to the expression currently selected and replaces the selection with a reference to the new variable. You can use Expand Selection to from the Edit menu to get a valid selection range.
Inline Local Variable
Starts the Inline Local Variable refactoring wizard. Replaces the references to the selected local variable with the variable's initializer expression and removes the variable.
Self Encapsulate Field
Starts the Self Encapsulate Field refactoring wizard. Replaces all references to a field with getting and setting methods. Is applicable to a selected field or a text selection resolving to a field.
Note: Refactoring commands are also available from the context menus in many views and the Java editor.