ReferenceSearch within a specific method (Java)

So what I am trying to do is to filter my ReferenceSearch so that it only retrieves PsiReferences of a PsiElement within a specific method.
Usually, I do

references =;

to find all the references in my .java class.

Now I want to get the references of a specific method. How can I do that? I tried

references =, method.getUseScope()).findAll();

but this does not seem to work.

How can I filter this search? Or, as a workaround, how can I conveniently filter the references afterwards to make sure they are located within a certain method? However, the first variant would be prefered.

1 comment
Comment actions Permalink

try passing in new LocalSearchScope(method)


Please sign in to leave a comment.