Renaming a Symbol
Go Up to Refactoring Procedures Index
Editing your Delphi or C++ code in the Code Editor, you can use the Refactor > Rename menu command to rename identifiers.
You can rename identifiers if the original identifier declaration is in your project, or in a project your project depends on, and this project is in the same open project group. You can rename such identifiers as type-names, method-names, variables, fields, and other. In Delphi, you can rename identifiers used with generics.
Contents
Renaming an identifier in Delphi
To rename an identifier in Delphi, follow the steps below:
- Right click the identifier in the Code Editor.
- Select Refactor > Rename identifierType 'identifierName' menu command. This displays the Rename identifierType 'identifierName' dialog box where identifierName is the actual name of the selected identifier and identifierType shows its type (method, variable, field, and other).
- Enter the new identifier name in the New name field.
- Select the View references before refactoring check box to preview the changes to your project files. If you clear this option, the refactoring is applied immediately, without a preview of the changes.
- Click OK. The Refactorings pane displays every occurrence of the identifier to be changed.
- Review the proposed changes in the Refactorings pane and click the Apply Refactoring icon to perform all listed refactorings. You can also click the Remove Refactoring icon to remove the selected refactoring from the pane.
Note: The Refactor > Rename identifierType 'identifierName' context menu command is context-sensitive. If you select a method identifier, the context menu command will be Rename method 'methodName' . Where methodName is the actual name of the method you have selected. This context-sensitivity applies for all other identifier types as well.
Restrictions (Delphi)
There is the following restriction for renaming generics:
- You cannot rename type parameters in generics.
- This means that if you have the following declaration:
type List<Item> = class ... end;
- Then you cannot rename the
Item
identifier (this is the type parameter), but you can rename theList
identifier.
Renaming an identifier in C++
To rename an identifier in C++, follow the steps below:
- Right click the identifier in the Code Editor.
- Select Refactor > Rename menu command. This displays the Rename dialog box.
- Enter the new identifier name in the text field.
- Check one or more checkboxes to indicate the items to be renamed.