Simple Custom Refactoring in IntelliJ
This question is a follow-up for this . Say I have some class Foo. class Foo { protected String x = "x"; public String getX() { return x; } } I have a program that uses Foo and violates LoD ( Law of Demeter ). class Bar { protected Foo foo; public Bar() { this.foo = new Foo(); } public Foo getFoo() { return foo; } } public static void main(String [] args) { Bar bar = new Bar(); String x = bar.getFoo().getX(); } I can refactor this code to use LoD in two steps. ⌥ ⌘ m bar.getFoo().getX() -> getFooX(bar) (extract to method, also find and replace occurrences) F6 getFooX(bar) -> bar.getFooX() (move