Chamly Idunil Chamly Idunil - 1 month ago 5
Java Question

Find Method usages only for specified class in Intelij-Idea

I am using Intelijidea and I have problem with method usage finding.

Suppose I have interface Worker.

public interface Worker {

void startWork();
void endWork();
}


And I have two implementation.

public class Develper implements Worker {
@Override
public void startWork() {
System.out.println("Developer Start Working");
}

@Override
public void endWork() {

}
}

public class Qa implements Worker {
@Override
public void startWork() {
System.out.println("QA start Work");
}

@Override
public void endWork() {

}
}


I open Developer class and trying to find usage of startWork.
I want only to view usage of Developer.startWork implemented method.

but when i find usage it shows both Developer and Qa startWork method usages.
how can i avoid Qa.startWork method usage when finding Developer.startWork usages.

Please advice.

Answer

I'm using IntelliJ IDEA 15.0.1 .

I think what you see when using the "find usages" functionality depends from the context.

If you place the cursor in method name Developer.startWork and invoke find usages , you should see a small dialog. You are asked "Do you want to find usages of the base method?" .

If you say "No", and in your sources you did only call the method via the base class or interface (Worker.start() in your example), IDEA doesn't show you any hits. Thats correct.

If you call the overridden method via Developer.startWork() , and press "No" in the dialog, then you will see the usages of the specific implementation.

Update: enter image description here

enter image description here

enter image description here

enter image description here

Comments