XmlElement (@NotNull PsiFile psiFile, @NotNull Editor editor) { PsiElement contextNode = psiFile.findElementAt(editor.getCaretModel().getOffset()); while (contextNode != null && !isValidContextNode(contextNode)) { contextNode = contextNode.getParent(); } assert contextNode == null || contextNode instanceof XmlElement; return (XmlElement)contextNode; }