user11718989
user11718989

Reputation:

How do I limit the results of Intellij Find Usages to only those of a specific class?

I am a new user to Intellij. I have a hierarchy where both ClassA and ClassB implement foo() in MyInterface:

public interface MyInterface{
    void foo()
}
public class ClassA implements MyInterface{
    @Override
    public void foo(){
        System.out.println("Hello");
    }
}
public class ClassB implements MyInterface{
    @Override
    public void foo(){
        System.out.println("World");
    }
}
public class HelloWorld {
    public static void main(String[] args){
         new ClassA().foo();
         new ClassB().foo();
    }
}

When I do Find Usages on the foo() definition in ClassA, both the foo() from ClassA and ClassB are found. Is there a way to only have the foo() called on the ClassA instance found?

Upvotes: 0

Views: 112

Answers (1)

Andrey
Andrey

Reputation: 16381

You can search for usages of only ClassA: enter image description here

Also you can restrict usages scope to certain files in project (including creating your custom scope): enter image description here

Upvotes: 2

Related Questions