boolean (PsiParameter parameter) { for (PsiReference reference : ReferencesSearch.search(parameter, GlobalSearchScope.projectScope(myProject), false)) { final PsiElement refElement = reference.getElement(); final PsiElement anonymousClass = PsiTreeUtil.getParentOfType(refElement, PsiAnonymousClass.class); if (anonymousClass != null && PsiTreeUtil.isAncestor(myMethod, anonymousClass, true)) { return true; } } return false; }