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 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, Quick Action and 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.
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.
Convert Between Pointer to Instance
Change object pointers to object references, and vice versa.
Quickly convert type in a declaration, swap "." and "->" in references, and adjust "*" and "&" as appropriate.
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 file, and can remain in the header file 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 file, or extracts the implementation directly to source.
Replace an expression with a variable that explains the purpose of the replaced code.
Introduce Variable defines a temporary variable in the innermost scope of the selection, initializes the temporary variable with the replaced code, and replaces one or multiple occurrences of the expression with the temporary variable.
In C/C++, easily move the implementation of a method from source to a header file or class declaration.
This refactoring places implementations in header files for inline execution. The refactoring also moves a method implementation into a class declaration, near other methods in the same class. Define the format of the implementations with a VA Snippet.
Move Implementation to Source File
In C/C++, move the implementation of a method from header file 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.
Move Method Implementations to Source File
In C/C++, move all implementations from header file to source file in a single operation.
To complement to the refactoring command that moves a single implementation, this plural version moves all methods from a header file to a class. Invoke the command from the name of a class, not from one of its members. A dialog appears in which you can select the implementations to move.
Move Selection to New File
Move code to a new header file 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 file.
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.
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++, header files and source files are renamed in pairs, and the rename of a header file automatically updates all directives that #include the header file. In C#, design and code-behind files are renamed simultaneously.
Simplify Instance Declaration
Make declarations of objects easier to understand.
Eliminate the extraneous setting of an object to a new instance of its type.
After invoking the refactoring, the object is created and initialized in a simpler, but equivalent, declaration.