Java Reference
In-Depth Information
Figure 9.14 Renaming a symbol is one of the most fundamental and
commonly used refactorings. It's hard to believe how difficult this task is
in a nonintelligent editor.
Refactor | Rename from the context menu. The process is the same regardless of
the type of symbol you're renaming.
The Rename dialog summarizes your selection and asks you to specify the new
name for the symbol. When you're renaming a field, parameter, or local variable,
the drop-down box lists IDEA 's suggestions for the new name: combinations
gleaned from the symbol's usage and type. If one of these is acceptable, select it.
Otherwise, enter your new name.
Two checkbox options are available in this dialog:
Search in comments and strings —If deselected, only Java code references
to the symbol (including those within JSP pages) are changed. If selected,
IDEA also finds and changes references to the symbol within code com-
ments, String references, and non-Java files (like XML ). Be careful when
using this option, because IDEA can only guess these types of usages; you
may want to enable the preview before the refactoring takes place.
Preview usages to be changed —If enabled, IDEA shows you all the
changes it plans to make to your source tree because of the renaming, giv-
ing you a chance to tweak the refactor or abort the operation.
When you're ready to issue the rename, click OK . If you haven't requested a pre-
view, IDEA makes all the necessary changes to your files. If you've requested a
preview, you'll see the preview window as shown earlier.
9.4.3
Refactoring to improve class or package organization
It's also possible to delete, copy, and move classes, methods, and other elements
in IDEA to improve the organization of your code. For instance, you can delete a
method or class you're no longer using, or move a class from one package to
another. These operations are more than simple cut-and-paste or file-movement
 
 
 
 
 
 
Search WWH ::




Custom Search