@Override
    public void invoke(@NotNull final Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
        editor = editor instanceof EditorWindow ? ((EditorWindow)editor).getDelegate() : editor;

        XmlTag tag = PsiTreeUtil.getContextOfType(myReference, XmlTag.class, true);
        if (tag == null) return;

        XmlTag xmlTag = tag.createChildTag("variable", XsltSupport.XSLT_NS, null, false);
        xmlTag.setAttribute("name", myReference.getReferencedName());
        xmlTag.setAttribute("select", "dummy");

        final XmlAttribute select = xmlTag.getAttribute("select", null);
        assert select != null;
        final PsiElement dummy = XsltSupport.getAttValueToken(select);
        assert dummy != null;

        final TemplateBuilderImpl builder = createTemplateBuilder(xmlTag);
        builder.replaceElement(dummy, new MacroCallNode(new CompleteMacro()));
        builder.setEndVariableAfter(select);
        final Template template = builder.buildTemplate();
        template.addTextSegment("\n");
        template.setToIndent(true);


        final XmlTag insertionPoint = findVariableInsertionPoint(tag);
        moveTo(editor, insertionPoint);

        TemplateManager.getInstance(project).startTemplate(editor, template);
    }
@Override
    public void invoke(@NotNull final Project project, Editor editor, PsiFile file)