RAD Studio (Common)
ContentsIndex
PreviousUpNext
Previewing and Applying Refactoring Operations

You can preview most refactoring operations in the Refactoring pane. Some refactorings occur immediately and allow no preview. You might want to use the preview feature when you first begin to perform refactoring operations. The preview shows you how the refactoring engine evaluates and applies refactoring operations to various types of symbols 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 a refactoring operation

  1. Open a project.
  2. Locate a symbol name in the Code Editor.
  3. Select the symbol name.
  4. Right-click to display the context menu.
  5. Select RefactoringRename 'symbol type' where symbol type is one of the valid types, such as method, variable, or field. This displays the Rename Symbol dialog.
  6. Type a new name in the New name text box.
  7. Select the View references before refactoring check box.
  8. Click OK. This displays a hierarchical list of the potentially refactored items, in chronological order as they were found. You can jump to each item in the Code Editor.
    Note: If you want to remove an item from the refactoring operation, select the item and click the Delete Refactoring
    icon in the toolbar.

To jump to a refactoring target from the Message Pane

  1. Expand any of the nodes that appear in the Message Pane.
  2. Click on the target refactoring operation that you would like to view in the Code Editor.
  3. 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 process, while the Message Pane contains refactoring targets.

To apply refactorings

  1. Open a project.
  2. Locate a symbol name in the Code Editor.
  3. Select the symbol name.
  4. Right-click to display the context menu.
  5. Select RefactoringRename 'symbol type' where symbol type is one of the valid types, such as method, variable, or field. This displays the Rename Symbol dialog.
  6. Type a new name in the New name text box.
  7. Click OK. As long as the View references before refactoring check box is not selected, the refactoring occurs immediately.
    Warning: If the refactoring engine encounters errors, the refactoring is not applied. The errors are displayed in the Message Pane
    .

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!