Search usage of psiClass and cast reference back to psiMethod

Answered

I have a inner class B on a class A : 

Class A {

private void methodA(){
new B().methodB();
}

private Class B{
private void methodB(){
}
}

}

I am using ReferenceSearch to search the usage of class b but after i retrieve the reference i dont know how to retrieve the method methodA  from it:

ReferencesSearch.search(psiClassB).forEach(psiReference->{
PsiMethod methodA = ????
});

 

0
1 comment
Avatar
Permanently deleted user

I think i found out how to do it : 

PsiTreeUtil.collectParents(referenceMethod, PsiMethodImpl.class, true, e -> e instanceof PsiClass);
0

Please sign in to leave a comment.