boolean (final PsiReference psiReference) { PsiElement element = psiReference.getElement(); if (PsiTreeUtil.isAncestor(myPsiElement, element.getNavigationElement(), false)) { return true; } if (element instanceof PsiReferenceExpression) { PsiExpression qualifier = ((PsiReferenceExpression)element).getQualifierExpression(); while (qualifier instanceof PsiParenthesizedExpression) { qualifier = ((PsiParenthesizedExpression) qualifier).getExpression(); } if (qualifier instanceof PsiNewExpression newExpr) { PsiJavaCodeReferenceElement classRef = newExpr.getClassReference(); if (classRef != null && myPsiElement.isEquivalentTo(classRef.resolve())) { return true; } } } return false; }