PsiElement (PsiElement psiElement, final boolean start) { PsiElement target = null; PsiElement parent = psiElement.getParent(); if (parent instanceof PsiErrorElement) { parent = parent.getParent(); } if (parent instanceof XmlTag) { if (start) { target = XmlTagUtil.getStartTagNameElement((XmlTag)parent); } else { target = XmlTagUtil.getEndTagNameElement((XmlTag)parent); if (target == null) { final PsiErrorElement errorElement = PsiTreeUtil.getChildOfType(parent, PsiErrorElement.class); target = XmlWrongClosingTagNameInspection.findEndTagName(errorElement); } } } return target; }