Search in sources :

Example 1 with XsltExtractFunctionAction

use of org.intellij.lang.xpath.xslt.refactoring.XsltExtractFunctionAction in project intellij-community by JetBrains.

the class Xslt2RefactoringTest method doExtractFunction.

private void doExtractFunction() throws Throwable {
    myFixture.configureByFile(getTestFileName() + ".xsl");
    final Editor editor = myFixture.getEditor();
    assertTrue("Selection required", editor.getSelectionModel().hasSelection());
    editor.getCaretModel().moveToOffset(editor.getSelectionModel().getSelectionStart());
    final XsltExtractFunctionAction action = new XsltExtractFunctionAction() {

        @Override
        protected RefactoringOptions getSettings(XPathExpression expression, Set<XPathExpression> matchingExpressions) {
            return new RefactoringOptions() {

                @Override
                public boolean isCanceled() {
                    return false;
                }

                @Override
                public String getName() {
                    return "f:foo";
                }
            };
        }
    };
    final PsiFile file = InjectedLanguageUtil.findInjectedPsiNoCommit(myFixture.getFile(), editor.getCaretModel().getOffset());
    final Editor editorWindow = InjectedLanguageUtil.getInjectedEditorForInjectedFile(editor, file);
    assertTrue(editorWindow instanceof EditorWindow);
    action.invoke(myFixture.getProject(), editorWindow, file, null);
    myFixture.checkResultByFile(getTestFileName() + "_after.xsl");
}
Also used : XPathExpression(org.intellij.lang.xpath.psi.XPathExpression) Set(java.util.Set) PsiFile(com.intellij.psi.PsiFile) Editor(com.intellij.openapi.editor.Editor) XsltExtractFunctionAction(org.intellij.lang.xpath.xslt.refactoring.XsltExtractFunctionAction) RefactoringOptions(org.intellij.lang.xpath.xslt.refactoring.RefactoringOptions) EditorWindow(com.intellij.injected.editor.EditorWindow)

Aggregations

EditorWindow (com.intellij.injected.editor.EditorWindow)1 Editor (com.intellij.openapi.editor.Editor)1 PsiFile (com.intellij.psi.PsiFile)1 Set (java.util.Set)1 XPathExpression (org.intellij.lang.xpath.psi.XPathExpression)1 RefactoringOptions (org.intellij.lang.xpath.xslt.refactoring.RefactoringOptions)1 XsltExtractFunctionAction (org.intellij.lang.xpath.xslt.refactoring.XsltExtractFunctionAction)1