Create from Usage
This collection of refactorings for top-down programming allows you to introduce code when and where you want, without changing your caret position or flipping between files. You can introduce enums, variables, and functions/methods at local, class, or global scope. Invoke this feature simply by typing a new symbol name and instructing Visual Assist X to create the desired target. The correct type is inferred for the resulting variable or method.
Create Class Member
Quickly add a state variable or helper method to a class while working elsewhere in that class. From the Create from Usage dialog, choose the "Member in" or "Method in" option. Click the link below the example for a demonstration.
Animate example
Note in the example above that the type of
currentElevation is inferred as int. If the r-value were instead 5280.0, the type would have been inferred as double. Visual Assist X uses the same language typing rules as the compiler to infer the correct type.
Create Parameter to Function/Method
Parameterize global functions or static methods to encourage re-use of utility code. In the following example, the unrecognized symbol
radius is designated as a parameter to the
getCircumference method.
Animate example
Create Enum Value
Define a new enum value from the call site. This can be done from an assignment, comparison, or switch statement (or other construct in which the type of the unknown symbol can be inferred as an enum).
Animate example
Create Global Function
Performing Create from Usage on an unknown function outside of class scope will result in a global function.
Create Local or Global Variables
When performing Create from Usage on an unknown variable outside of class scope, you are given a choice of creating a parameter to the containing function, or creating a local or global variable.
Formatting
Control the appearance of parameters (particularly whitespace) using the
Refactor Create Implementation VA Snippet of each language.
Edit the
Refactor Create From Usage Method Body VA Snippet of each language to specify the default code to be placed in the created method. For instance, you may wish to write code that does not compile to force you to go back and write the implementation. The default behavior is to throw a runtime exception indicating the method is not implemented.
Miscellaneous
C++ enum values to be inserted from the call site must use the Microsoft-specific syntax
qualifier::
name. This indicates to Visual Assist X that you are adding an enum value rather than introducing a new variable of the enum type.
While Visual Studio provides similar functionality for C# and VB only, users of these languages may still wish to employ the Create from Usage feature of Visual Assist X to take advantage of advanced formatting options.
If Visual Assist X is unable to infer the type of the variable or method being created, the placeholder "UnknownType" will be inserted.
Visual Assist X distinguishes unknown functions from unknown variables by looking for parentheses following the symbol name.