Renaming a Symbol

From RAD Studio
Jump to: navigation, search

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.

Renaming an identifier in Delphi

To rename an identifier in Delphi, follow the steps below:

  1. Right click the identifier in the Code Editor.
  2. 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).
    Refactor delphi.png
  3. Enter the new identifier name in the New name field.
    Rename delphi.png
  4. 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.
  5. Click OK. The Refactorings pane displays every occurrence of the identifier to be changed.
    Rrdelphirefactorings.png
  6. Review the proposed changes in the Refactorings pane and click the Apply Refactoring icon Apply.png to perform all listed refactorings. You can also click the Remove Refactoring icon Remove.png 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 the List identifier.

Renaming an identifier in C++

To rename an identifier in C++, follow the steps below:

  1. Right click the identifier in the Code Editor.
  2. Select Refactor > Rename menu command. This displays the Rename dialog box.
    Rename RN.png
  3. Enter the new identifier name in the text field.
    Rename Identifier.png
  4. Check one or more checkboxes to indicate the items to be renamed.
Note: For more information about this feature, please visit the Rename C++ page.

See Also