blob: b6128efa5687a4e34ac53e883e35dddbf0c54a39 [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<meta name="copyright"
content="Copyright (c) IBM Corporation and others 2000, 2010. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page.">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>Refactor Actions</title>
<link rel="stylesheet" href="../book.css" charset="ISO-8859-1"
type="text/css">
</head>
<body>
<h1>Refactor Actions</h1>
<p>Refactor menu commands:</p>
<table border="1" cellspacing="0" cellpadding="5" summary="Refactor menu commands">
<tbody>
<tr>
<th>
<p>Name</p>
</th>
<th>
<p>Description</p>
</th>
</tr>
<tr>
<td align="left" valign="top">
<p>Rename</p>
</td>
<td align="left" valign="top">Renames the selected element and
(if enabled) corrects all references to the elements (also in other
files). <br>
<table border="0" cellspacing="1" cellpadding="5" summary="Rename refactorings">
<tbody>
<tr>
<td align="left" valign="top">Available:</td>
<td>Methods, method parameters, fields, local variables,
types, type parameters, enum constants, compilation units,
packages, source folders, projects and on a text selection
resolving to one of these element types</td>
</tr>
<tr>
<td align="left" valign="top">Shortcut:</td>
<td align="left" valign="top">Alt + Shift + R</td>
</tr>
<tr>
<td align="left" valign="top">Options:</td>
<td align="left" valign="top">Renaming a type does allow to
rename similarly named variables and methods. Enable 'Update
similarly named variables and methods' in the Rename Type dialog.
Select 'Configure...' to configure the strategy for matching type
names. <br>
<br>
Renaming a package does allow to rename its subpackages. Enable
'Rename subpackages' in the Rename Package dialog.<br>
<br>
Enable 'Keep original method as delegate to changed method' to keep the original method.
Optionally you can deprecate the old method.
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top">
<p>Move</p>
</td>
<td align="left" valign="top">Moves the selected elements and
(if enabled) corrects all references to the elements (also in other
files). <br>
<table border="0" cellspacing="1" cellpadding="5" summary="Move refactorings">
<tbody>
<tr>
<td align="left" valign="top">Available:</td>
<td>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</td>
</tr>
<tr>
<td align="left" valign="top">Shortcut:</td>
<td align="left" valign="top">Alt + Shift + V</td>
</tr>
<tr>
<td align="left" valign="top">Options:</td>
<td align="left" valign="top">You can use Drag &amp; Drop in
the Package Explorer to start this refactoring.</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top">Change Method Signature</td>
<td>Changes parameter names, parameter types, parameter order
and updates all references to the corresponding method. Additionally,
parameters and thrown exceptions can be removed or added and method return type and
method visibility can be changed. <br>
<table border="0" cellspacing="1" cellpadding="5" summary="Change Method Signature refactorings">
<tbody>
<tr>
<td align="left" valign="top">Available:</td>
<td>Methods or on text selection resolving to a method</td>
</tr>
<tr>
<td align="left" valign="top">Shortcut:</td>
<td align="left" valign="top">Alt + Shift + C</td>
</tr>
<tr>
<td align="left" valign="top">Options:</td>
<td align="left" valign="top">Enable 'Keep original method as
delegate to changed method' in the Change Method Signature dialog
to keep the original method.</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr align="left" valign="top">
<td>Extract Method</td>
<td>Creates a new method containing the statements or expression
currently selected and replaces the selection with a reference to the
new method. This feature is useful for cleaning up lengthy,
cluttered, or overly-complicated methods. <br>
<table border="0" cellspacing="1" cellpadding="5" summary="Extract Method refactorings">
<tbody>
<tr>
<td align="left" valign="top">Available:</td>
<td>You can use&nbsp;<em>Expand Selection to</em> from the <a
href="ref-menu-edit.htm">Edit</a> menu to get a valid selection
range.
<br>This refactoring is also available as <a href="ref-java-editor-quickassist.htm">quick assist</a> on
statements and expressions selected in the editor.
</td>
</tr>
<tr>
<td align="left" valign="top">Shortcut:</td>
<td align="left" valign="top">Alt + Shift + M</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr align="left" valign="top">
<td>Extract Local Variable</td>
<td>Creates a new variable assigned to the expression currently
selected and replaces the selection with a reference to the new
variable. <br>
<table border="0" cellspacing="1" cellpadding="5" summary="Extract local variable refactorings">
<tbody>
<tr>
<td align="left" valign="top">Available:</td>
<td>Text selections that resolve to local variables. You can
use&nbsp;<em>Expand Selection to</em> from the <a
href="ref-menu-edit.htm">Edit</a> menu to get a valid selection
range.
<br>This refactoring is also available as <a href="ref-java-editor-quickassist.htm">quick assist</a> on
expressions selected in the editor.
</td>
</tr>
<tr>
<td align="left" valign="top">Shortcut:</td>
<td align="left" valign="top">Alt + Shift + L</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top">Extract Constant</td>
<td>Creates a static final field from the selected expression
and substitutes a field reference, and optionally rewrites other
places where the same expression occurs. <br>
<table border="0" cellspacing="1" cellpadding="5" summary="Extract Constant refactoring">
<tbody>
<tr>
<td align="left" valign="top">Available:</td>
<td>Constant expressions or text selections which resolve to
constant expressions
<br>This refactoring is also available as <a href="ref-java-editor-quickassist.htm">quick assist</a> on
expressions selected in the editor.
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr align="left" valign="top">
<td align="left" valign="top">Inline</td>
<td>Inline local variables, methods or constants. <br>
<table border="0" cellspacing="1" cellpadding="5" summary="Inline refactoring">
<tbody>
<tr>
<td align="left" valign="top">Available:</td>
<td>Methods, static final fields and text selections that
resolve to methods, static final fields or local variables
<br>This refactoring is also available as <a href="ref-java-editor-quickassist.htm">quick assist</a> on
local variables selected in the editor.
</td>
</tr>
<tr>
<td align="left" valign="top">Shortcut:</td>
<td align="left" valign="top">Alt + Shift + I</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top">Convert Anonymous Class to Nested</td>
<td>Converts an anonymous inner class to a member class. <br>
<table border="0" cellspacing="1" cellpadding="5" summary="Convert Anonymous Class to Nested refactoring">
<tbody>
<tr>
<td align="left" valign="top">Available:</td>
<td>Anonymous inner classes</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top">Move Type to New File</td>
<td>Creates a new Java compilation unit for the selected member type or the selected secondary
type, updating all references as needed. For non-static member types,
a field is added to allow access to the former enclosing instance, if
necessary. <br>
<table border="0" cellspacing="1" cellpadding="5" summary="Move Type to New File refactoring">
<tbody>
<tr>
<td align="left" valign="top">Available:</td>
<td>Member types, secondary types, or text resolving to a member type or a secondary type.
<br>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top">Convert Local Variable to Field</td>
<td>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. <br>
<table border="0" cellspacing="1" cellpadding="5" summary="Convert Local Variable to Field refactoring">
<tbody>
<tr>
<td align="left" valign="top">Available:</td>
<td>Text selections that resolve to local variables.
<br>This refactoring is also available as <a href="ref-java-editor-quickassist.htm">quick assist</a> on
local variables selected in the editor.
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top">Extract Superclass</td>
<td>Extracts a common superclass from a set of sibling types.
The selected sibling types become direct subclasses of the extracted
superclass after applying the refactoring. <br>
<table border="0" cellspacing="1" cellpadding="5" summary="Extract Superclass refactoring">
<tbody>
<tr>
<td align="left" valign="top">Available:</td>
<td>Types</td>
</tr>
<tr>
<td align="left" valign="top">Options:</td>
<td align="left" valign="top">Enable 'Use the extracted class
where possible' to use the newly created class wherever possible.
See <em>Use Supertype Where Possible</em>.</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top">Extract Interface</td>
<td>Creates a new interface with a set of methods and makes the
selected class implement the interface. <br>
<table border="0" cellspacing="1" cellpadding="5" summary="Extract Interface refactoring">
<tbody>
<tr>
<td align="left" valign="top">Available:</td>
<td>Types</td>
</tr>
<tr>
<td align="left" valign="top">Options:</td>
<td align="left" valign="top">Enable 'Use the extracted
interface type where possible' to use the newly created interface
wherever possible. See <em>Use Supertype Where Possible</em>.</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top">Use Supertype Where Possible</td>
<td>Replaces occurrences of a type with one of its supertypes
after identifying all places where this replacement is possible. <br>
<table border="0" cellspacing="1" cellpadding="5" summary="Use Supertype Where Possible refactoring">
<tbody>
<tr>
<td align="left" valign="top">Available:</td>
<td>Types</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top">Push Down</td>
<td>Moves a set of methods and fields from a class to its
subclasses. <br>
<table border="0" cellspacing="1" cellpadding="5" summary="Push Down refactoring">
<tbody>
<tr>
<td align="left" valign="top">Available:</td>
<td>One or more methods and fields declared in the same type
or on a text selection inside a field or method</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top">Pull Up</td>
<td align="left" valign="top">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. <br>
<table border="0" cellspacing="1" cellpadding="5" summary="Pull Up refactoring">
<tbody>
<tr>
<td align="left" valign="top">Available:</td>
<td>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</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top">Extract Class</td>
<td>Replaces a set of fields with new container object. All references to the fields are
updated to access the new container object.<br>
<table border="0" cellspacing="1" cellpadding="5" summary="Extract Class refactoring">
<tbody>
<tr>
<td align="left" valign="top">Available:</td>
<td>The set of fields or a type containing fields</td>
</tr>
<tr>
<td align="left" valign="top">Options:</td>
<td align="left" valign="top">Enable 'Create Getter and Setters' to add
accessor methods to the new type</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top">Introduce Parameter Object</td>
<td>Replaces a set of parameters with a new class,
and updates all callers of the method to pass an instance of the new
class as the value to the introduce parameter.<br>
<table border="0" cellspacing="1" cellpadding="5" summary="Introduce Parameter Object refactoring">
<tbody>
<tr>
<td align="left" valign="top">Available:</td>
<td>Methods or on text selection resolving to a method</td>
</tr>
<tr>
<td align="left" valign="top">Options:</td>
<td align="left" valign="top">Enable 'Keep original method as
delegate to changed method' in the Introduce Parameter Object dialog
to keep the original method.</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top">Introduce Indirection</td>
<td>Creates a static indirection method delegating to the
selected method. <br>
<table border="0" cellspacing="1" cellpadding="5" summary="Introduce Indirection refactoring">
<tbody>
<tr>
<td align="left" valign="top">Available:</td>
<td>Methods or on text selection resolving to a method</td>
</tr>
<tr>
<td align="left" valign="top">Options:</td>
<td align="left" valign="top">Enable 'Redirect all method
invocations' to replace all calls to the original method by calls
to the indirection method.</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top">Introduce Factory</td>
<td>Creates a new factory method, which will call a selected
constructor and return the created object. All references to the
constructor will be replaced by calls to the new factory method. <br>
<table border="0" cellspacing="1" cellpadding="5" summary="Introduce Factory refactoring">
<tbody>
<tr>
<td align="left" valign="top">Available:</td>
<td>Constructor declarations</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top">Introduce Parameter</td>
<td>Replaces an expression with a reference to a new method
parameter, and updates all callers of the method to pass the
expression as the value of that parameter. <br>
<table border="0" cellspacing="1" cellpadding="5" summary="Introduce Parameter refactoring">
<tbody>
<tr>
<td align="left" valign="top">Available:</td>
<td>Text selections that resolve to expressions</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top">Encapsulate Field</td>
<td>Replaces all references to a field with getter and setter
methods. <br>
<table border="0" cellspacing="1" cellpadding="5" summary="Encapsulate Field refactoring">
<tbody>
<tr>
<td align="left" valign="top">Available:</td>
<td>Field or a text selection resolving to a field.
<br>This refactoring is also available as <a href="ref-java-editor-quickassist.htm">quick assist</a> on
field declarations and references selected in the editor.
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top">Generalize Declared Type</td>
<td>Allows the user to choose a supertype of the reference's
current type. If the reference can be safely changed to the new type,
it is. <br>
<table border="0" cellspacing="1" cellpadding="5" summary="Generalize Declared Type refactoring">
<tbody>
<tr>
<td align="left" valign="top">Available:</td>
<td>Type references and declarations of fields, local
variables, and parameters with reference types</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top">Infer Generic Type Arguments</td>
<td>Replaces raw type occurrences of generic types by
parameterized types after identifying all places where this
replacement is possible. <br>
<table border="0" cellspacing="1" cellpadding="5" summary="Infer Generic Type Arguments refactoring">
<tbody>
<tr>
<td align="left" valign="top">Available:</td>
<td>Projects, packages, and types</td>
</tr>
<tr>
<td align="left" valign="top">Options:</td>
<td>'Assume clone() returns an instance of the receiver
type'. Well-behaved classes generally respect this rule, but if
you know that your code violates it, uncheck the box. <br>
<br>
'Leave unconstrained type arguments raw (rather than inferring
&lt;?&gt;)'. If there are no constraints on the elements of e.g.
ArrayList a, uncheck this box will cause Eclipse to still
provide a wildcard parameter, replacing the reference with
ArrayList&lt;?&gt;.</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top">Migrate JAR File</td>
<td>Migrates a JAR File on the build path of a project in your
workspace to a newer version, possibly using refactoring information
stored in the new JAR File to avoid breaking changes. <br>
<table border="0" cellspacing="1" cellpadding="5" summary="Migrate JAR File refactoring">
<tbody>
<tr>
<td align="left" valign="top">Available:</td>
<td>JAR Files on build path</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top">Create Script</td>
<td>Creates a script of the refactorings that have been applied
in the workspace. Refactoring scripts can either be saved to a file
or copied to the clipboard. See <em>Apply Script</em>. <br>
<table border="0" cellspacing="1" cellpadding="5" summary="Create Script">
<tbody>
<tr>
<td align="left" valign="top">Available:</td>
<td>Always</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top">Apply Script</td>
<td>Applies a refactoring script to projects in your workspace.
Refactoring scripts can either be loaded from a file or from the
clipboard. See <em>Create Script</em>. <br>
<table border="0" cellspacing="1" cellpadding="5" summary="Apply Script">
<tbody>
<tr>
<td align="left" valign="top">Available:</td>
<td>Always</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top">History</td>
<td>Browses the workspace refactoring history and offers the
option to delete refactorings from the refactoring history. <br>
<table border="0" cellspacing="1" cellpadding="1" summary="History">
<tbody>
<tr>
<td align="left" valign="top">Available:</td>
<td>Always</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<p>Refactoring commands are also available from the context menus in
many views and the Java editor.</p>
<h3 class="related">Related concepts</h3>
<a href="../concepts/concept-refactoring.htm">Refactoring support</a>
<h3 class="related">Related references</h3>
<a href="ref-wizard-refactorings.htm">Refactoring dialogs</a><br>
<a href="preferences/ref-preferences-java.htm">Java preferences</a>
</body>
</html>