简体   繁体   中英

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?

You can search for usages of only ClassA: 在此处输入图片说明

Also you can restrict usages scope to certain files in project (including creating your custom scope): 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM