@Override
    public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
        final int offset = editor.getCaretModel().getOffset();
        final PsiElement element = file.findElementAt(offset);
        assert element != null;

        final XmlTag tag = PsiTreeUtil.getParentOfType(element, XmlTag.class);
        assert tag != null && tag.getLocalName().equals("if");

        final String test = tag.getAttributeValue("test");
        final String body = tag.getValue().getText();

        final XmlTag parentTag = tag.getParentTag();
        assert parentTag != null;

        final XmlTag chooseTag = parentTag.createChildTag("choose", XsltSupport.XSLT_NS, null, false);
        final XmlTag whenTag = parentTag.createChildTag("when", XsltSupport.XSLT_NS, body, false);
        final XmlTag otherwiseTag = parentTag.createChildTag("otherwise", XsltSupport.XSLT_NS, "\n\n", false);
        whenTag.setAttribute("test", test);
        chooseTag.add(whenTag);
        chooseTag.add(otherwiseTag);

      CodeStyleManager.getInstance(tag.getManager().getProject()).reformat(tag.replace(chooseTag));
    }
@Override
    public void invoke(@NotNull Project project, Editor editor, PsiFile file)