how to "introduce indirection" like in eclipse?

eclipse has this feature. it can find all usages of a method and replace it with another call which then calls the original one.
before:

class X {
void x() {...}
}

//somewhere else
x.x();
-----------------

after:

static void foo(X x) {x.x()}

//somewhere else foo is called instead of x
foo(x);

-----------
i can fake this partially by renaming a method, but there is manual plumbing involved. can idea do this automatically?

5 comments
Comment actions Permalink

I'd try to extract

x.x();

to a new static method foo.

0
Comment actions Permalink

that will only replace usages in one class, not everywhere

0
Comment actions Permalink

You know that you can trigger it for the whole project?

0
Comment actions Permalink

how? i can make it public and static, but i have no option for letting idea check the whole project

0
Comment actions Permalink

Refactor > Replace Method Code Duplicates

0

Please sign in to leave a comment.