use of com.intellij.lang.javascript.psi.ecmal4.JSClass 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.ecmal4.JSClass 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.ecmal4.JSClass in project intellij-plugins by JetBrains.
the class FlexNavigationTest method checkClassName.
private static void checkClassName(@Nullable String expectedClassName, @NotNull PsiElement element) {
if (expectedClassName == null)
return;
JSClass jsClass = PsiTreeUtil.getParentOfType(element, JSClass.class);
assertNotNull("Parent class not found", jsClass);
assertEquals(expectedClassName, jsClass.getName());
}
use of com.intellij.lang.javascript.psi.ecmal4.JSClass in project intellij-plugins by JetBrains.
the class FlexExtractSuperTest method performAction.
private void performAction(boolean classNotInterface, String from, final String extractedSuperName, int docCommentPolicy, JSExtractSuperProcessor.Mode mode, String[] members, String[] conflicts) {
JSClass sourceClass = JSTestUtils.findClassByQName(from, GlobalSearchScope.moduleScope(myModule));
final List<JSMemberInfo> memberInfos = FlexPullUpTest.getMemberInfos(members, sourceClass, false);
JSMemberInfo.sortByOffset(memberInfos);
JSMemberInfo[] infosArray = JSMemberInfo.getSelected(memberInfos, sourceClass, Conditions.alwaysTrue());
try {
final PsiElement finalSourceClass = sourceClass;
PsiDirectory dir = WriteCommandAction.runWriteCommandAction(null, (Computable<PsiDirectory>) () -> ActionScriptCreateClassOrInterfaceFix.findOrCreateDirectory(StringUtil.getPackageName(extractedSuperName), finalSourceClass));
new JSExtractSuperProcessor(sourceClass, infosArray, StringUtil.getShortName(extractedSuperName), StringUtil.getPackageName(extractedSuperName), docCommentPolicy, mode, classNotInterface, dir).run();
assertEquals("Conflicts expected:\n" + StringUtil.join(conflicts, "\n"), 0, conflicts.length);
myProject.getComponent(PostprocessReformattingAspect.class).doPostponedFormatting();
FileDocumentManager.getInstance().saveAllDocuments();
} catch (BaseRefactoringProcessor.ConflictsInTestsException e) {
assertNotNull("Conflicts not expected but found:" + e.getMessage(), conflicts);
assertSameElements(e.getMessages(), conflicts);
myDoCompare = false;
}
}
use of com.intellij.lang.javascript.psi.ecmal4.JSClass in project intellij-plugins by JetBrains.
the class FlexCssNavigationTest method testCssTypeReference1.
@JSTestOptions({ JSTestOption.WithCssSupportLoader, JSTestOption.WithFlexFacet, JSTestOption.WithGumboSdk })
public void testCssTypeReference1() throws Exception {
PsiElement[] elements = findTargetElements(getTestName(false) + ".css");
assertEquals(1, elements.length);
assertInstanceOf(elements[0], JSAttributeNameValuePair.class);
final JSClass jsClass = PsiTreeUtil.getParentOfType(elements[0], JSClass.class);
assertNotNull(jsClass);
assertEquals(jsClass.getQualifiedName(), "spark.components.Button");
}
Aggregations