Refactor actions

Refactor menu commands:

Name

Function

Keyboard Shortcut

Undo

Does an Undo of the last refactoring. The refactoring undo buffer is only valid as long as no other source changes than refactoring have been performed.

Alt + Shift + Z

Redo

Does a Redo of the last undone refactoring. The refactoring undo/redo buffer is only valid as long as no other source changes than refactoring have been performed.

Alt + Shift + Y

Rename

Starts the Rename refactoring dialog:  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. 

Alt + Shift + R

Move

Starts the Move refactoring dialog: Moves the selected elements and (if enabled) corrects all references to the elements (also in other files). Can be applied to one instance method (which can be moved to a component), 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. 

Alt + Shift + V
Change Method Signature

Starts the Change Method Signature refactoring dialog. Changes parameter names, parameter types, parameter order and updates all references to the corresponding method. Additionally, parameters can be removed or added and method return type as well as its visibility can be changed. This refactoring can be applied to methods or on text selection resolving to a method. 

 
Convert Anonymous Class to Nested

Start the Convert Anonymous Class to Nested Class refactoring dialog. Helps you convert an anonymous inner class to a member class. This refactoring can be applied to anonymous inner classes.

 
Convert Nested Type to Top Level

Starts the Convert Nested Type to Top Level Type refactoring dialog. 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. This refactoring can be applied to member types or text resolving to a member type.

 
Push Down

Starts the Push Down refactoring dialog. Moves a set of methods and fields from a class to its subclasses. This refactoring can be applied to one or more methods and fields declared in the same type or on a text selection inside a field or method. 

 

Pull Up

Starts the Pull Up refactoring wizard. Moves a field or method to a superclass of its declaring class or (in the case of methods) declares the method as abstract in the superclass. This refactoring can be applied on one or more methods, fields and member types declared in the same type or on a text selection inside a field, method or member type. 

 
Extract Interface

Starts the Extract Interface refactoring dialog. 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. This refactoring can be applied to types.

 
Use Supertype Where Possible

Starts the Use Supertype Where Possible dialog. Replaces occurrences of a type with one of its supertypes after identifying all places where this replacement is possible.This refactoring is available on types.

 
Inline Starts the Inline refactoring dialog. Inlines local variables, methods or constants. This refactoring is available on methods, static final fields and text selections that resolve to methods, static final fields or local variables. Alt + Shift + I
Extract Method Starts the Extract Method refactoring dialog. 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. 
Alt + Shift + M
Extract Local Variable

Starts the Extract Variable refactoring dialog. Creates a new variable assigned to the expression currently selected and replaces the selection with a reference to the new variable. This refactoring is available on text selections that resolve to local variables. You can use Expand Selection to from the Edit menu to get a valid selection range.

Alt + Shift + L
Extract Constant

Starts the Extract Constant refactoring dialog. Creates a static final field from the selected expression and substitutes a field reference, and optionally rewrites other places where the same expression occurs. This refactoring is available on static final fields and text selections that resolve to static final fields.

 
Convert Local Variable to Field

Start the Convert Local Variable to Field refactoring dialog. 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. This refactoring is available on text selections that resolve to local variables.

 
Encapsulate Field Starts the Self Encapsulate Field refactoring dialog. 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.  

Refactoring commands are also available from the context menus in many views and the Java editor.

Related concepts
Refactoring support

Related tasks
Refactoring
Using Structured Selection

Related reference
Refactoring preference page
Refactoring dialogs
Extract Method Errors

Legal notices