boolean (@NotNull PsiElement element) { IElementType i = getLastChildNode().getElementType(); boolean resolvingToMethod = element instanceof PsiMethod; if (i == JavaTokenType.IDENTIFIER) { if (!(element instanceof PsiPackage)) { if (!(element instanceof PsiNamedElement)) return false; String name = ((PsiNamedElement)element).getName(); if (name == null) return false; if (!name.equals(getLastChildNode().getText())) return false; } } else if (i == JavaTokenType.SUPER_KEYWORD || i == JavaTokenType.THIS_KEYWORD) { if (!resolvingToMethod) return false; if (!((PsiMethod)element).isConstructor()) return false; } PsiElement parent = getParent(); boolean parentIsMethodCall = parent instanceof PsiMethodCallExpression; // optimization: methodCallExpression should resolve to a method if (parentIsMethodCall != resolvingToMethod) return false; return element.getManager().areElementsEquivalent(element, advancedResolve(true).getElement()); }