Previewing and Applying Refactoring Operations
Go Up to Refactoring Procedures Index
You can preview most refactoring operations in the Refactorings pane (Delphi) and in the Apply Patch pane (C++). 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.
Contents
Preview and apply a Rename operation in Delphi
Follow the steps below to preview and apply a Rename operation in Delphi:
- In the Code Editor, right-click an 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. The Refactorings pane opens 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: Clear the View references before refactoring option to apply the refactoring operations immediately after clicking OK, without a preview of the changes..
Note: 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 and the Refactorings pane displays the list of errors registered.
To jump to a refactoring target from the Refactorings pane:
- Expand any of the nodes that appear in the Refactorings pane.
- Double-click the target refactoring identifier to highlight it 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 not possible. You need to reapply the refactoring after making changes to any files during the refactoring process.
Preview and apply a Rename operation in C++
Follow the steps below to preview and apply a Rename operation in C++:
- In the Code Editor, right-click an identifier to display the context menu.
- Select Refactor > Rename context menu command. This displays the Rename Symbol dialog box.
- Enter the new identifier name in the text field.
- Select the Preview changes before applying check box to preview the changes to your project files.
- Click OK to open the Apply Patch pane opens displaying 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 icon in the Apply Patch pane to apply all refactoring operations.
Note: Clear the Preview changes before applying option to apply the refactoring operations immediately after clicking OK, without a preview of the changes..
Note: To remove an item from the refactoring operation, select the item in the Apply Patch pane and click the Delete icon in the toolbar.
Warning: If the refactoring engine encounters errors, the refactoring is not applied and the Apply patch pane displays the list of errors registered.
To jump to a refactoring target from the Apply Patch pane:
- Expand any of the nodes that appear in the Apply Patch pane.
- Double-click the target refactoring identifier to highlight it 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 not possible. You need to reapply the refactoring after making changes to any files during the refactoring process.