Inline
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
See example.
This refactoring is opposite to Extract Method.
- Inline to Anonymous Class refactoring allows replacing redundant class with its contents.
- Inline Constructor allows compressing a chain of constructors, if one of them is a special case of another. Seeexample.
- 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.
Examples
Inline Variable
Inline Method
Inline Constructor
Inline Superclass
To perform the 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.
See Also
```
Last modified: 21 March 2017