Bruce
Bruce

Reputation: 8849

Eclipse Refactor all method call

In eclipse java i used a static method call in several places.

A.method1();

How can i change these all calls in one change using refacor to B.method2()

Upvotes: 1

Views: 1445

Answers (2)

harvyS
harvyS

Reputation: 648

Solution based on code refactoring called "Inline ...", it replaces every method call with its implementation. Example: Before we have: obj1.method1(){}; and obj2.method2(obj1){ obj1.method1(); };

After applying eclipse refactoring "Inline ..." we will have every call of obj2.method2(obj1); replaced with call obj1.method1();

That was easy!

Upvotes: 2

Eng. Samer T
Eng. Samer T

Reputation: 6526

I think the easy way is by press ctrl+f to open find/replace window, then you can replace your code in one shot by clicking "Replace All" like this:

enter image description here

if you are trying to replace the signature only not the method name then you can do so by alt+shift+c here is a reference:

if you are trying to change the method name, then go to class which you defined the method in it the press alt+shift+r to rename the method declaration in that class and everywhere you call it. and here is a reference:

Upvotes: 0

Related Questions