Refactor This
Refactor This… lists only the refactorings that apply at the caret or selection: first the ones below, then any other refactorings the language server offers there (for example “Convert to arrow function” in TypeScript).
Available refactorings
Rename
1
Start the rename
Put the caret on a name and press
⇧F6 / Shift+F6. The name becomes editable in place, and its other occurrences
in the file change as you type.2
Finish or cancel
Press
↵ / Enter or ⇥ / Tab to apply the rename across the project. Esc restores the old name.3
Use the dialog for more options
Press
⇧F6 / Shift+F6 a second time to open the rename dialog instead.Introduce and extract
Introduce Variable, Introduce Constant, Introduce Field, Introduce Parameter and Extract Method work like this:- Select the expression or statements. With only a caret, a chooser lists the expressions around it; each is highlighted while you move through the list.
- If the expression occurs several times, choose whether to replace this occurrence or all of them (Multiple occurrences found).
- The new name is then edited in place.
↑/↓cycle through suggested names;↵/Enteraccepts.
Move, copy and rename files
In the Project view, Rename… (⇧F6 / Shift+F6), Move… (F6, drag and drop, or cut and paste) and Copy… (F5, copy and paste, or ⌥-drag / Alt-drag) open a dialog. With Search for references on, references to the file are updated through the language servers that support it (for example imports in TypeScript); Search in comments and strings also looks there. The changes are shown in a preview first.
In the editor, Move… on a symbol runs the server’s move refactoring, where the language has one.
Safe Delete
1
Start
Put the caret on a declaration and press
⌘⌦ / Alt+Delete, or use Safe Delete… on a file in the Project view.2
Confirm
Confirm the deletion. You can also search comments and strings.
3
Review usages
If the symbol is still used, Usages Detected offers View Usages, Delete Anyway or Cancel. Otherwise
the declaration is removed together with its doc comment and annotations, as one undo step.
Pull Members Up and Push Members Down
These move fields and methods between a Java class and its superclasses or subclasses. A dialog lets you pick the members and the destination; problems the move would cause are listed in Problems Detected before you continue. They are provided by the Java extension bundled with OpenIDEA, so they are not available for other languages.Undo
A refactoring is one undo step, even when it changed several files. After a multi-file refactoring, a notification offers Undo (and then Redo).Limits
- Refactorings other than Rename, Safe Delete and the syntax-based fallbacks need a running language server that offers them. Check the Language Services widget in the status bar if one is missing.
- Change Signature appears only when the server offers a signature rewrite as a code action.
- There is no structural search-and-replace refactoring in this menu; see Edit › Find › Replace Structurally… in Inspections.