- Introduce variable
Refactoring commands are available:
- in ReSharper | Refactor menu
- on the context menu of the editor
- on the Refactor This context menu
ReSharper distinguishes functions and variables. According to the type of the property that should be refactored, the process of renaming goes on in two possible ways.
To rename a function, written by you, defined in js module or a library one, follow the procedure steps
When you rename a variable, refactoring is performed without dialogs.
- Position the caret at the name of a variable.
- Do one of the following:
- On the main menu, choose ReSharper | Refactor | Rename.
- Press F2.
- Press Ctrl+Shift+R and select Rename in/on the Refactor This context menu.
- The edited variable is placed in a red rectangle, all others in black dotted rectangles.
- Type a new name and press Enter to apply the changes.
Consider the following example:
The Introduce variable refactoring allows to create a new local variable based on a selected expression. Before the refactoring is applied you are prompted to decide whether to replace all occurrences of the expression or the selected one.
The algorithm of introducing variable is almost the same as described in the
Consider the example below: