Introduce Variable

Index of All Documentation » Wing Pro Reference Manual » Refactoring »

The Introduce Variable operation adds a variable that is initialized to the value of an existing expression and then replaces all occurrences of that expression with the new variable. To start an introduce variable operation, select an expression in the editor and choose Introduce Variable from the Refactor menu or from the Refactor sub-menu of the editor's right-click context menu. Wing will find all places the expression is used in the current scope and list them in the Refactoring tool. To complete the operation, enter the name for the new variable and press Enter or click on the Introduce Variable button.

The introduced variable name may include a dot. For example, a name starting with self. may be used to introduce an instance attribute in a method.

Note that each found match for the expression is displayed with a check box that can be deselected to omit that match from the introduce variable operation.

After it completes, the introduce variable operation can be undone with the Revert button in the Refactoring tool.