boolean (@NotNull TemplateActionContext templateActionContext) { PsiFile file = templateActionContext.getFile(); int offset = templateActionContext.getStartOffset(); if (!XmlContextType.isInXml(file, offset)) return false; PsiElement element = file.findElementAt(offset); if (element == null) return false; if (PsiTreeUtil.getParentOfType(element, XmlText.class, false) != null) { return true; } PsiElement parent = element.getParent(); if (parent instanceof PsiErrorElement) { parent = parent.getParent(); } return parent instanceof XmlDocument; }