use of com.intellij.lang.javascript.psi.JSFunction in project intellij-plugins by JetBrains.
the class FlexHierarchyTest method doJSCallHierarchyTest.
private void doJSCallHierarchyTest(final String hierarchyType, final String classFqn, final String methodName, final String scope, final String... fileNames) throws Exception {
doHierarchyTest(() -> {
final JSClass jsClass = (JSClass) JSDialectSpecificHandlersFactory.forLanguage(JavaScriptSupportLoader.ECMA_SCRIPT_L4).getClassResolver().findClassByQName(classFqn, GlobalSearchScope.moduleScope(myModule));
assert jsClass != null;
final JSFunction jsFunction = jsClass.findFunctionByName(methodName);
assert jsFunction != null;
if (CallHierarchyBrowserBase.CALLEE_TYPE.equals(hierarchyType)) {
return new JSCalleeMethodsTreeStructure(myProject, jsFunction, scope);
} else if (CallHierarchyBrowserBase.CALLER_TYPE.equals(hierarchyType)) {
return new JSCallerMethodsTreeStructure(myProject, jsFunction, scope);
}
throw new IllegalArgumentException("Wrong hierarchy type: " + hierarchyType);
}, fileNames);
}
use of com.intellij.lang.javascript.psi.JSFunction in project intellij-plugins by JetBrains.
the class FlexHierarchyTest method doJSMethodHierarchyTest.
private void doJSMethodHierarchyTest(final String classFqn, final String methodName, final boolean hideClassesWhereMethodNotImplemented, final String... fileNames) throws Exception {
final HierarchyBrowserManager.State state = HierarchyBrowserManager.getInstance(myProject).getState();
final boolean oldState = state.HIDE_CLASSES_WHERE_METHOD_NOT_IMPLEMENTED;
state.HIDE_CLASSES_WHERE_METHOD_NOT_IMPLEMENTED = hideClassesWhereMethodNotImplemented;
doHierarchyTest(() -> {
final JSClass jsClass = (JSClass) JSDialectSpecificHandlersFactory.forLanguage(JavaScriptSupportLoader.ECMA_SCRIPT_L4).getClassResolver().findClassByQName(classFqn, GlobalSearchScope.moduleScope(myModule));
assert jsClass != null;
final JSFunction jsFunction = jsClass.findFunctionByName(methodName);
assert jsFunction != null;
return new JSMethodHierarchyTreeStructure(myProject, jsFunction);
}, fileNames);
state.HIDE_CLASSES_WHERE_METHOD_NOT_IMPLEMENTED = oldState;
}
use of com.intellij.lang.javascript.psi.JSFunction in project intellij-plugins by JetBrains.
the class ActionScriptCompletionInTextFieldTest method testChangeSignatureReturnType.
@JSTestOptions({ JSTestOption.WithFlexSdk })
public void testChangeSignatureReturnType() throws Exception {
configureByFiles(null, BASE_PATH + getTestName(false) + "_2.js2");
JSFunction function = createFakeFunction();
JSExpressionCodeFragment fragment = JSChangeSignatureDialog.createReturnTypeCodeFragment(new JSMethodDescriptor(function, false).getReturnType(), function, JavaScriptSupportLoader.ECMA_SCRIPT_L4);
String[] included = new String[] { "Z111", "Z222", "int", "String", "uint", "Number", "EventDispatcher", "void", "*" };
String[] excluded = ArrayUtil.mergeArrays(DEFALUT_VALUES, "public", "function", "while");
checkTextFieldCompletion(fragment, included, excluded, "Z111", BASE_PATH + getTestName(false) + ".txt");
}
use of com.intellij.lang.javascript.psi.JSFunction in project intellij-plugins by JetBrains.
the class ActionScriptResolveTest method testResolveInClass.
public void testResolveInClass() throws Exception {
String fileText = "class A { function get aaa() {} function foo() {\n" + " var aaa = a<ref>aa;\n}" + "}";
JSReferenceExpression ref = (JSReferenceExpression) configureByFileText(fileText, "sample.js2");
assertTrue(ref.resolve() instanceof JSFunction);
}
use of com.intellij.lang.javascript.psi.JSFunction in project intellij-plugins by JetBrains.
the class FlexResolveHelper method importClass.
public boolean importClass(final PsiScopeProcessor processor, final PsiNamedElement file) {
// there is no need to process package stuff at function level
if (file instanceof JSFunction)
return true;
if (file instanceof XmlBackedJSClassImpl) {
if (!processInlineComponentsInScope((XmlBackedJSClassImpl) file, inlineComponent -> processor.execute(inlineComponent, ResolveState.initial()))) {
return false;
}
}
final String packageQualifierText = JSResolveUtil.findPackageStatementQualifier(file);
final Project project = file.getProject();
GlobalSearchScope scope = JSResolveUtil.getResolveScope(file);
final MxmlAndFxgFilesProcessor filesProcessor = new MxmlAndFxgFilesProcessor() {
final PsiManager manager = PsiManager.getInstance(project);
public void addDependency(final PsiDirectory directory) {
}
public boolean processFile(final VirtualFile file, final VirtualFile root) {
final PsiFile xmlFile = manager.findFile(file);
if (!(xmlFile instanceof XmlFile))
return true;
return processor.execute(XmlBackedJSClassFactory.getXmlBackedClass((XmlFile) xmlFile), ResolveState.initial());
}
};
PsiFile containingFile = file.getContainingFile();
boolean completion = containingFile.getOriginalFile() != containingFile;
if (completion) {
return processAllMxmlAndFxgFiles(scope, project, filesProcessor, null);
} else {
if (packageQualifierText != null && packageQualifierText.length() > 0) {
if (!processMxmlAndFxgFilesInPackage(scope, project, packageQualifierText, filesProcessor))
return false;
}
return processMxmlAndFxgFilesInPackage(scope, project, "", filesProcessor);
}
}
Aggregations