Inline
The Inline refactoring lets you reverse the Extract refactoring for a method, constructor, parameter, superclass, anonymous class, and closure (for Swift).
You can inline the pattern variable since the Java 14 version. In this case, all the occurrences will be replaced with old-style cast expression.
Place the caret at the code fragment you want to inline.
Press Ctrl+Alt+N. Alternatively, right-click the code fragment and select the inline refactoring that you need from the
menu.In the Inline dialog, specify the inlining options.
(Optional) Select Preview to preview changes.
Preview and apply changes.
Examples
Inline Variable
Inline Variable refactoring replaces redundant variable usage with its initializer.
Example 1
Example 2
Inline Method
Inline Method results in placing the method's body into the body of its caller(s).
Example 1
Example 2
Inline Abstract Method
Inlining an abstract method that has exactly one implementation replaces calls to the method with the concrete implementation's code and removes the need for the method declaration and its call.
Inline Constructor
Inline Constructor allows compressing a chain of constructors if one of them is a special case of another.
Inline Superclass
The Inline Superclass refactoring results in pushing superclass' methods into the class where they are used and removing the superclass.
Inline to Anonymous Class
Inline to Anonymous Class refactoring allows replacing a redundant class with its contents. Starting with Java 8, the inlined anonymous classes can be converted to lambdas automatically.
Inline Parameter
The Inline Parameter refactoring allows you to replace usages of the parameter with the value from the arguments of the method call.