XmlAttribute (PsiElement element, Editor editor) { var result = PsiTreeUtil.getParentOfType(element, XmlAttribute.class); if (result != null) return result; if (element.getTextRange().getStartOffset() == editor.getCaretModel().getOffset()) { return PsiTreeUtil.getParentOfType(PsiTreeUtil.prevLeaf(element), XmlAttribute.class); } return null; }