Previewing and Applying Refactoring Operations
Go Up to Refactoring Procedures Index
You can preview most refactoring operations in the Refactorings pane. Some refactorings occur immediately and allow no preview. The preview shows you how the refactoring engine evaluates and applies refactoring operations to various types of identifiers and other refactoring targets. Previewing is set as the default behavior. When you preview a refactoring operation, the engine gathers refactoring information in a background thread and fills in the information as the information is collected.
If you apply a refactoring operation right away, it is performed in a background thread also, but a modal dialog blocks the UI activity. If the refactoring engine encounters an error during the information gathering phase of the operation, it will not apply the refactoring operation. The engine only applies the refactoring operation if it finds no errors during the information gathering phase.
To preview and apply Rename operation:
- Open a project.
- In the Code Editor, right-click some identifier to display the context menu.
- Select Refactor > Rename identifierType 'identifierName' context menu command. The Rename context menu command is context-sensitive; it shows the actual name identifierName of the selected identifier and its type identifierType (method, type, variable, field, etc.). This displays the Rename identifierType 'identifierName' dialog box.
- Type a new identifier name in the New name text box.
- Select the View references before refactoring check box.
- Click OK. This opens the Refactorings pane and displays a hierarchical list of all items potentially to be renamed. You can jump to each of these items in the Code Editor.
- Click the Apply Refactoring icon in the Refactorings pane to apply all refactoring operations.
Note: As long as the View references before refactoring check box is not selected, the refactoring occurs immediately at clicking OK.
Note: If you want to remove an item from the refactoring operation, select the item in the Refactorings pane and click the Remove Refactoring icon in the toolbar.
Warning: If the refactoring engine encounters errors, the refactoring is not applied. The errors are displayed in the Refactorings pane.
To jump to a refactoring target from the Refactorings pane:
- Expand any of the nodes that appear in the Refactorings pane.
- Click on the target refactoring identifier that you would like to view in the Code Editor.
- Make any changes you would like in the Code Editor.
Warning: If you change an item in the Code Editor, the refactoring operation is prevented. You need to reapply the refactoring after making changes to any files during the refactoring process.