Search in sources :

Example 1 with ExtractedFunctionSignatureGenerator

use of com.intellij.lang.javascript.refactoring.extractMethod.ExtractedFunctionSignatureGenerator in project intellij-plugins by JetBrains.

the class CreateASFunctionIntentionTest method testCanGetIntroductionScopeForActionScriptClassMember.

public void testCanGetIntroductionScopeForActionScriptClassMember() throws Exception {
    configureByText(ActionScriptFileType.INSTANCE, "package {\n" + "class test{\n" + "    function foo() {\n" + "        <caret>bar();\n" + "    }\n" + "}\n" + "}");
    JSExtractFunctionHandler extractFunctionHandler = new JSExtractFunctionHandler();
    int offset = myEditor.getCaretModel().getOffset();
    JSFunction function = PsiTreeUtil.getParentOfType(myFile.findElementAt(offset), JSFunction.class);
    List<JSExtractFunctionHandler.IntroductionScope> scopes = extractFunctionHandler.findBases(function);
    JSSignatureContext context = new JSSignatureContext() {

        @Override
        public boolean isActionScript() {
            return true;
        }

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

        @Nullable
        @Override
        public PsiElement getAnchor() {
            return null;
        }

        @NotNull
        @Override
        public List<JSExtractFunctionHandler.IntroductionScope> getIntroductionScopes() {
            return scopes;
        }
    };
    Pass<JSExtractFunctionHandler.IntroductionScope> callback = new Pass<JSExtractFunctionHandler.IntroductionScope>() {

        @Override
        public void pass(JSExtractFunctionHandler.IntroductionScope scope) {
        }
    };
    JSExtractFunctionHandler.IntroductionScope actualScope = extractFunctionHandler.getIntroductionScope(myEditor, new ExtractedFunctionSignatureGenerator(), context, callback, "extractedFunction");
    Assert.assertEquals(ContainerUtil.getFirstItem(scopes), actualScope);
}
Also used : JSExtractFunctionHandler(com.intellij.lang.javascript.refactoring.extractMethod.JSExtractFunctionHandler) JSSignatureContext(com.intellij.lang.javascript.refactoring.extractMethod.JSSignatureContext) Pass(com.intellij.openapi.util.Pass) JSFunction(com.intellij.lang.javascript.psi.JSFunction) ExtractedFunctionSignatureGenerator(com.intellij.lang.javascript.refactoring.extractMethod.ExtractedFunctionSignatureGenerator)

Aggregations

JSFunction (com.intellij.lang.javascript.psi.JSFunction)1 ExtractedFunctionSignatureGenerator (com.intellij.lang.javascript.refactoring.extractMethod.ExtractedFunctionSignatureGenerator)1 JSExtractFunctionHandler (com.intellij.lang.javascript.refactoring.extractMethod.JSExtractFunctionHandler)1 JSSignatureContext (com.intellij.lang.javascript.refactoring.extractMethod.JSSignatureContext)1 Pass (com.intellij.openapi.util.Pass)1