use of com.intellij.lang.javascript.refactoring.extractMethod.JSSignatureContext 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);
}
Aggregations