RAD Studio (Common)
ContentsIndex
PreviousUpNext
Symbol Rename Overview (Delphi, C#, C++)

Renames identifiers and all references to the target identifier. You can rename an identifier if the original declaration identifier is in your project or in a project your project depends on, in the Project Group. You can also rename an identifier if it is an error identifier, for instance, an undeclared identifier or type. 

The refactoring engine enforces a few renaming rules:

  • You cannot rename an identifier to a keyword.
  • You cannot rename an identifier to the same identifier name unless its case differs.
  • You cannot rename an identifier from within a dependent project when the project where the original declaration identifier resides is not open.
  • You cannot rename symbols imported by the compiler.
  • You cannot rename an overridden method when the base method is declared in a class that is not in your project.
  • If an error results from a refactoring, the engine cannot apply the change. For example, you cannot rename an identifier to a name that already exists in the same declaration scope. If you still want to rename your identifier, you need to rename the identifier that already has the target name first, then refresh the refactoring. You can also redo the refactoring and select a new name. The refactoring engine traverses parent scopes, searching for an identifier with the same name. If the engine finds an identifier with the same name, it issues a warning.

Renaming a method, type, and other objects is functionally the same as renaming an identifier. If you select a procedure name in the Code Editor, you can rename it. If the procedure is overloaded, the refactoring engine renames only the overloaded procedure and only calls to the overloaded procedure. An example of this rule follows:

procedure Foo; overload;
procedure Foo(A:Integer); overload;
Foo();
Foo;
Foo(5);

If you rename the first procedure Foo in the preceding code block, the engine renames the first, third, and fourth items. 

If you rename an overridden identifier, the engine renames all of the base declarations and descendent declarations, which means the original virtual identifier and all overridden symbols that exist. An example of this rule follows:

TFoo = class
    procedure Foo; virtual;
end;

TFoo2 = class(TFoo)
    procedure Foo; override;
end;

TFoo3 = class(TFoo)
    procedure Foo; override;
end;

TFoo4 = class(TFoo3)
    procedure Foo; override;
end;

Performing a rename operation on Foo renames all instances of Foo shown in the preceding code sample.

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!