I have a project with hundreds of implementations of an interface. I'd like to find the usages of a method in just ONE implementation of that interface. Intellij (and Eclipse) both show me all usages of that method in all of the implementations - hundreds of them.
I highlight the method in one implementation of the interface, right-click and select "find usages", and it shows me all usages of that method in all implementations.
None of the usage options in Intellij seem to get me just one implementation.
public interface Dog {
void bark(int volume);
}
public class Lab implements Dog {
public void bark(int volume) {
System.out.println("woof");
}
}
public class Collie implements Dog {
public void bark(int volume) {
System.out.println("woof");
}
}
public class Main {
public static void main(String[] args) {
Dog onyx = new Lab();
Dog lassie = new Collie();
onyx.bark(50);
lassie.bark(20);
}
}
If I highlight the Lab bark method, click show usages, I want to just see the onyx.bark(50) line in main.java, not both bark usages in main.java.
I realize that if I use Lab onyx = new Lab() and Collie lassie = new Collie() in the main class, find references will work, but that's not how the project is written. Maybe there's no way for the IDE to determine the implementing class when the type is the interface, but it sure would be useful.