boolean (PsiReferenceExpression refExpr) { try{ PsiExpression qualifier = refExpr.getQualifierExpression(); if (!(qualifier instanceof PsiReferenceExpression)) return false; if (refExpr.getTypeParameters().length > 0) return false; PsiElement qualifierRefElement = ((PsiReferenceExpression)qualifier).resolve(); if (!(qualifierRefElement instanceof PsiClass)) return false; PsiElement refElement = refExpr.resolve(); if (refElement == null) return false; PsiElementFactory factory = JavaPsiFacade.getElementFactory(refExpr.getProject()); if (refExpr.getParent() instanceof PsiMethodCallExpression){ PsiMethodCallExpression methodCall = (PsiMethodCallExpression)refExpr.getParent(); PsiMethodCallExpression newMethodCall = (PsiMethodCallExpression)factory.createExpressionFromText( refExpr.getReferenceName() + "()", refExpr); newMethodCall.getArgumentList().replace(methodCall.getArgumentList()); PsiElement newRefElement = newMethodCall.getMethodExpression().resolve(); return refElement.equals(newRefElement); } else if (refExpr instanceof PsiMethodReferenceExpression) { return false; } else { PsiReferenceExpression newRefExpr = (PsiReferenceExpression)factory.createExpressionFromText( refExpr.getReferenceName(), refExpr); PsiElement newRefElement = newRefExpr.resolve(); return refElement.equals(newRefElement); } } catch(IncorrectOperationException e){ LOG.error(e); return false; } }