Quick Refactoring

Refactoring is a code editing technique used to "clean up" and improve the understandability of source code without affecting the code's external behavior. Quick Refactoring is a feature set that provides several fast and easy-to-use refactoring methods:

Quick Refactoring performs refactorings using Context Tagging Features rather than a formal language parser. Quick Refactorings are supported for C++, C#, Java, and Slick-C®.

Available Refactorings

To access Quick Refactoring, from the main menu, click Format → Quick Refactoring. Quick Refactoring menu can also be accessed from the right-click context menus in the Symbols and Defs views.

Quick Rename

Quick Rename uses the Context Tagging® to rename a symbol under the cursor or any symbol selected in the Defs or Symbols views. This operation works for all tagged languages. Quick Rename does not treat renaming classes, constructors, and destructors as a special case. Quick Rename will rename all of the overloads of a function. Quick Rename does not rename overridden methods (in parent and child classes).

Quick Extract Method

After selecting a set of lines, Quick Extract Method creates a new method with the selected lines as the body. It discovers any undeclared variables and creates them as parameters to the new method. The extracted method is created in the same scope as the original method.

Quick Modify Parameter List

This refactoring allows you to add, delete, and re-order parameters for a selected function. The refactoring will modify the parameter list for the selected function and all of its counterparts within the class hierarchy.

Quick Replace Literal with Constant

Replaces the selected literal with a constant, replacing use of the literal with the new constant.

Reviewing Refactoring Changes

When a refactoring finishes, the Refactoring results dialog box is displayed, allowing you to review the changes.

There are three panes in this window:

  • The left pane is read-only and shows the original file(s).

  • The right pane shows the refactored file(s). For convenience, this pane can be edited.

  • The bottom pane lists all files that have been modified by the refactoring. Clicking on any file in this list brings that file into view, where it can be reviewed and edited.

Click Save All at the bottom of this window to save all the refactoring and editing changes that were made on all files. Click Cancel to discard changes and have all files remain the way they were before the refactoring process.

Click Next Diffor Prev Diffto advance to the next or previous change made by the refactoring. Click File>> to restore the contents of the current selected file to its original contents.

Click Block>> to restore an entire block of changes to the original contents. Click Del Block to remove a block of code inserted by the refactoring. Click Line>> to restore the current line to its original contents.

Some refactorings, in particular Quick Modify Parameter List, may require further user input. In this case each input will be displayed under the file it is in, and there will be two additional buttons: Next Input and Prev Input. You will not be able to save the refactoring results until you have resolved all of the input requests.

Java Refactoring

The Eclipse JDT Refactor main menu item for Java refactoring disappears when you are not using the JDT Editor. SlickEdit Core has made several of these refactorings available in the editor's right-click menu, under the Source menu item:

  • Override/Implement Methods

  • Implement Getters and Setters

  • Generate Delegate Methods

  • Add Constructors from Superclass

  • Generate Constructor Using Fields

  • Externalize Strings

There are also other Java refactorings from the JDT accessible from the Refactor menu item of the editor's right-click context menu:

  • Move

  • Change Method Signature

  • Convert Anonymous Class to Nested

  • Move Member Type to New File

  • Pull Up

  • Push Down

  • Extract Interface

  • User Supertype Where Possible

  • Inline

  • Introduce Factory

  • Encapsulate Field

See the Eclipse Help for descriptions and other information regarding Java refactoring (Java Development User Guide → Reference → Refactoring).