Show: Delphi C++
Display Preferences

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 Symbol dialog box.
    Refactor c++.png
  3. Enter the new identifier name in the text field.
    Rename c++.png
  4. Select the Preview changes before applying check box to preview the changes to your project files. If you do not select this option, the refactoring is applied immediately, without a preview of the changes.
  5. Click OK. The Apply Patch pane displays every occurrence of the identifier to be changed.
    Rrcppapplypatch.png
  6. Review the proposed changes in the Apply Patch pane and click the Apply icon Apply.png to perform all listed refactorings. Click the Delete icon Remove.png to remove the selected refactoring from the pane.


Note: This feature requires the project to use a Clang-enhanced compiler.

Restrictions (C++)

Rename Refactoring for C++ has the following restrictions:

  • Inactive Code
Code that is not compiled cannot be refactored. For example, code in an inactive preprocessor block.
Unabletorefactorifdef-edcodetrimmed50%.png
Codeunabletorefactormarked50%.png


  • Macros
When an identifier is a macro, Rename Refactoring does not recognize the macro as an identifier that can be renamed. If a renamed identifier is used in a macro, Rename Refactoring identifies it but leaves it OFF by default. You can access this change, review, and re-enable it or leave it off.


  • Template members
Rename Refactoring does not handle renames in templates.
Note: You still can rename templates and its types in a specialized template declaration. The restrictions in this topic only apply to renaming member methods and/or variables of a template class.


  • Non-ANSI Characters
Rename Refactoring does not support the use of non-ANSI characters in project names and paths.


  • Component Names
C++ Rename Refactoring does not rename component names in a form file (.dfm or .fmx) when renaming a reference to the component in code.

Cancel Rename Refactoring

Rename Refactoring process can be canceled from the progress dialog.

RefactorProgressDialog.png

See Also

Personal tools
RAD Studio 10.2 Tokyo
In other languages
Previous Versions
Assistance