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?

0
Avatar
Permanently deleted user

I'd try to extract

x.x();

to a new static method foo.

0

that will only replace usages in one class, not everywhere

0
Avatar
Permanently deleted user

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

0

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

0
Avatar
Permanently deleted user

Refactor > Replace Method Code Duplicates

0

请先登录再写评论。