Renaming a Symbol

From RAD Studio
Jump to: navigation, search

Go Up to Refactoring Procedures Index


Editing your Delphi 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.

To rename an identifier:

  1. Select the identifier in the Code Editor.
  2. Right-click to display the context menu.
  3. 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).
  4. Enter the new identifier name in the New Name field.
  5. If you want to preview the changes to your project files, select the View References Before Refactoring check box. If this option is unchecked, the refactoring is applied immediately, without a preview of the changes.
  6. Click OK. The Refactorings pane displays every occurrence of the identifier to be changed.
  7. Review the proposed changes in the Refactorings pane and use the Apply Refactoring toolbar icon to perform all listed refactorings. Use the Remove Refactoring button 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 holds true for all other identifier types, as well.

Restrictions

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.


See Also