IntelliJ IDEA provides the following inline refactorings:
- Inline Variable refactoring replaces redundant variable usage with its initializer. See example. This refactoring is opposite to the Extract Variable refactoring.
- Inline Method refactoring results in placing method's body into the body of its caller(s). You can opt to:
- inline all occurrences of the method, and delete the method
- inline only a single occurrence, and retain the method
This refactoring is opposite to Extract Method.
- Inline to Anonymous Class refactoring allows replacing redundant class with its contents. Starting with Java 8, the inlined anonymous classes can be converted to lambdas automatically. See example.
- Inline Constructor allows compressing a chain of constructors, if one of them is a special case of another. See example.
- Inline JSP/JSPX works like a regular Java inline refactoring.
- Inline Superclass refactoring results in pushing superclass' methods into the class where they are used, and removing the superclass.
Inline to Anonymous Class
Performing inline refactoring
- Place the caret in the editor at the desired symbol to be inlined.
- Do one of the following:
- In the Inline dialog, that corresponds to the selected symbol, specify the inlining options.
- Preview and apply changes.
Last modified: 11 October 2017