Wiki

Case Status
Log In

Wiki

 
Whole Tomato Software - Home
  • RSS Feed

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).

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

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 via a checkbox 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. When using 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. Visual Assist uses heuristics to determine which hits are relevant, e.g. proximity to code references.

Including and Excluding References

Use the context menu 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 broader scope, e.g. through the inheritance chain or in comments, before excluding specific entries. The Rename list is refreshed when you change a setting that affects scope; you will lose your exclusions when you change a setting.

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.

Stop a Rename Search

You can prematurely terminate lengthy searches by clicking "Stop" in a Rename dialog, or by via the shortcut to cancel a build (Ctrl+Break).

Stop a search prematurely only to change the scope of a rename, or abort the rename entirely. Committing to a rename after a stopped search will likely break your solution.

Show Projects

Projects nodes appears 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 Signature or Change Signature will also search all projects. The shared setting prevents you from inadvertently refactoring references inconsistent with those you review using Find References.

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. Fox example, rename of MessageBoxA can change references such that MessageBoxW is used instead of MessageBoxA.

Rename of a system type used in a project or solution changes changes references to that of a different system symbol. For example, rename of std:vector can change references such that std:set is used instead of std:vector.

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 in lieu 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.