Reduce the complexity of your code, improve its readability, and make it extensible without changing its external behavior. Refactor legacy code, code you inherit, or the first version of your own work.
Access to Refactoring Commands
Refactoring commands are available in menus accessible by keyboard and mouse, and contents of the refactoring menus vary with context. Refactoring is available in the tool windows of Visual Assist, and in the text editor on symbols, selections, and whitespace.
Open a context-aware refactoring menu for the current symbol with the default shortcut Shift+Alt+Q.
Obtain a complete list of refactoring commands in the context menu of the text editor.
Hover over a symbol and Visual Assist displays an icon when refactoring is available. Click the icon to open a context-aware menu.
Rename symbols quickly and accurately, in your active project and throughout your solution.
This often-used refactoring renames the definition and declaration of a symbol, all references to it, and optionally, occurrences in comments and strings. A preview of all targets to be renamed is always shown so you are confident the rename does what you expect. Deselect any references you want untouched, and undo the entire operation if you make a mistake.
Rename is available for:
- Method parameters
Select Rename from any of the refactoring menus, specify a new name, and set your options. The preview of changes differentiates read-only and writeable occurrences.
Change the signature of a method from any reference, implementation, or declaration.
Update the signature of a method or function in a simple dialog, and Visual Assist infers the differences between the original and new signatures. Reorder, rename, add, and delete parameters with this powerful refactoring that also updates all references to your method. When renaming a parameter, references to it within the method are also renamed.
Change any or all of the following parts of a signature:
- Method name
- Return type
- Parameter names
- Parameter types
- Parameter order
- Number of parameters
Similar to the rename refactoring, set the scope of the change and preview the set of references that will be refactored.
Create accessors to a member field by encapsulating the field.
Restrict actions on a member field with the Encapsulate Field refactoring. Accessors are created and named automatically, and your original field is untouched in the event you need legacy code to compile as you update references. If you encapsulate a new field, immediately make the field private to restrict future access.
In C/C++, accessor methods are created adjacent to a declaration in a header, and can remain in the header for inline execution.
If you prefer implementations in a source file, follow Encapsulate Field with another refactoring to move the implementations to a corresponding source file.
Move a segment of code into a separate method, and replace the segment with a call to the extracted method.
Make long methods easier to read and share common blocks of code with the Extract Method refactoring. Extract multiple lines, or a segment of one. The return value and parameters of the extracted method are determined for you.
In C/C++, the refactoring creates an inline method in a header, or extracts the implementation directly to source.
Rename your active document without breaking the build.
Rename the active document and its corresponding files easily, without interrupting your flow or breaking the build. Visual Assist automatically updates files, projects, and solutions, and then propagates the rename through source control systems that integrate with Microsoft Visual Studio.
In C/C++, headers and source files are renamed in pairs, and the rename of a header automatically updates all directives that #include the header. In C#, design and code-behind files are renamed simultaneously.
Move Selection to New File
Move code to a new header or source file, and have the new file added to the active project automatically.
The refactoring creates the new file in the same directory as the active document. Define the format of the new file with a VA Snippet. In C/C++, Visual Assist can replace the selection in the active document with an #include if the selection is moved to a header.
Move Implementation to Source File
In C/C++, easily move the implementation of a method from header to source file.
This refactoring is often initiated after other refactorings that place implementations in header files for inline execution, e.g. Encapsulate Field. The refactoring creates a declaration in the header, and moves the implementation near those of other methods in the same class. Define the format of the implementation with a VA Snippet.