Table of content
WholeTomato

Rename

Refactor with Rename when the existing name of a symbol is ambiguous, misleading, misspelled, or non-standard. Rename changes the definition, declaration in C/C++, and all references within a project or throughout a solution. Rename optionally changes "references" in comments and strings.

Rename is available for namespaces, classes, methods, fields, variables, and method parameters; and can be invoked from a definition, reference, or declaration of a symbol.

Visual Studio 2015 and newer

Although Rename built into Visual Studio is often sufficient, the version in Visual Assist is typically faster.

Access

Place the caret on a symbol and use the default shortcut (Shift+Alt+R) for Rename, or select Rename from the Quick Action and Refactoring menu (Shift+Alt+Q).

 

Rename Options

Enter the new name for your symbol, and select the scope of the rename. You can preview references before committing to the refactoring.

 

The Rename dialog shows options for the rename in the gear menu and as option pills between the name box and the list of references. A pill indicates whether its option is on.

  • Display inherited and overridden references (Alt+I)
  • Search all projects (Alt+S)
  • Display uses in comments and strings (Alt+M)
  • Unreal Core Redirect (Alt+U)

Click a pill, press its shortcut, or select the option from the gear menu to turn the option on or off.

Unreal Core Redirect appears only for Unreal Engine types, and only when support for Unreal Engine is on.

If you change an option while a search is running, Visual Assist restarts the search.

If you manually rename a symbol at its definition, Visual Assist may recognize the edit and offer to rename the references immediately, with or without a preview in the Rename dialog.

 

Access to Rename is also available in several tool windows, including the Hovering Class Browser of the VA View, and the VA Outline.

Rename in Multiple Projects

You can rename throughout a solution with the Search all projects option (Alt+S) in the Rename dialog. Multiple project nodes appear in the Rename list when references are found in multiple projects.

 

When not renaming in all projects, a rename is restricted to the project that contains the current file.

The Rename dialog opens with the scope of the previous Rename, Change Signature, or Find References.

Multiple References

Multiple references that occur on a single line in your source appear in multiple entries in the Rename list.

 

Highlight References

References found can appear bold and highlighted in the Rename list. By default, references where a symbol is modified are highlighted in MistyRose, whereas references where a symbol is read are highlighted in LightCyan.

 

Highlighting requires applying Enhanced Syntax Coloring to VA Views in the options dialog for Visual Assist.

 

Specify highlight colors in the options dialog.

 

Rename in an Inheritance Chain

Visual Assist can rename inherited references from parent classes and overridden references in child classes. Turn on Inherited and overridden (Alt+I) to use this setting. When you use this setting, virtual methods are renamed up and down the class hierarchy.

 

Rename Comment and String References

You can broaden a rename to include hits in relevant comments and strings with the Comments and strings option (Alt+M). Visual Assist uses heuristics to determine which hits are relevant, e.g. proximity to code references.

 

Rename Unreal Engine Types

When you rename an Unreal Engine type, the Unreal Core Redirect option (Alt+U) is available in the Rename dialog. This option does not appear for other symbols, or when support for Unreal Engine is off.

See Support for UE for more information.

Including and Excluding References

Select/deselect the checkboxes of the Rename dialog to include or exclude all references of a specific type.

 

Deselect entries in the Rename list to exclude specific references at the scope of project, file, or call-site.

Set a broader scope, e.g. through the inheritance chain or in comments, before excluding specific entries. The Rename list is refreshed when you change an option that affects scope; you will lose your exclusions when you change an option. 

View References

Double-click entries in the results list to view references in your source. If necessary, Visual Assist opens the file containing the reference, but the file does not get focus as long as the Rename dialog is open. 

Show Projects

Project nodes appear in the results list if a rename searched all projects and found references in more than one project. 

You can make project nodes appear for all renames via the options dialog for Visual Assist.

 

Rename Files

If you rename a symbol whose name is identical to that of a file, e.g. class foo in foo.cpp, Visual Assist prompts you to rename the like-named files after the rename of the symbol is complete. If directed, Visual Assist launches Rename Files, where you have the opportunity to preview the list of files to be renamed. 

Shared Scope Setting

The setting to rename in all projects is shared with the Find References and Change Signature commands. If you restrict Rename to the current project, the scope of the next Find References or Change Signature is restricted to the current project as well. If you broaden the scope of Rename to all projects, the next invocation of Find References or Change Signature will also search all projects.

 

Rename of System Symbols

Rename is available for system symbols, both for symbols defined in system include files and for solution symbols defined using system types.

Rename of a system symbol changes its references in a project or solution such that they refer to a different system symbol. Rename does not change the definition of the system symbol. For example, rename of MessageBoxA can change references such that MessageBoxW is used instead of MessageBoxA.

 

Undo

Rename can be undone (Ctrl+Z), even when a change affects multiple files in multiple projects.

Visual C++ 6.0

Multiple Undos are required to revert a single rename.

Rename Versus Change Signature

In most instances, use Change Signature instead of Rename to modify names of methods and their parameters. Although Rename is acceptable, Change Signature reaches deeper into parameter lists of declarations and definitions, and into the bodies of method implementations.