Search in sources :

Example 1 with JSClass

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);
}
Also used : JSCalleeMethodsTreeStructure(com.intellij.lang.javascript.hierarchy.call.JSCalleeMethodsTreeStructure) JSFunction(com.intellij.lang.javascript.psi.JSFunction) JSCallerMethodsTreeStructure(com.intellij.lang.javascript.hierarchy.call.JSCallerMethodsTreeStructure) JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass)

Example 2 with JSClass

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;
}
Also used : JSFunction(com.intellij.lang.javascript.psi.JSFunction) JSMethodHierarchyTreeStructure(com.intellij.lang.javascript.hierarchy.method.JSMethodHierarchyTreeStructure) HierarchyBrowserManager(com.intellij.ide.hierarchy.HierarchyBrowserManager) JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass)

Example 3 with JSClass

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());
}
Also used : JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass)

Example 4 with JSClass

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;
    }
}
Also used : PostprocessReformattingAspect(com.intellij.psi.impl.source.PostprocessReformattingAspect) BaseRefactoringProcessor(com.intellij.refactoring.BaseRefactoringProcessor) PsiDirectory(com.intellij.psi.PsiDirectory) JSExtractSuperProcessor(com.intellij.lang.javascript.refactoring.extractSuper.JSExtractSuperProcessor) JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass) JSMemberInfo(com.intellij.lang.javascript.refactoring.util.JSMemberInfo) PsiElement(com.intellij.psi.PsiElement)

Example 5 with JSClass

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");
}
Also used : JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass) PsiElement(com.intellij.psi.PsiElement) JSTestOptions(com.intellij.lang.javascript.JSTestOptions)

Aggregations

JSClass (com.intellij.lang.javascript.psi.ecmal4.JSClass)141 PsiElement (com.intellij.psi.PsiElement)65 Nullable (org.jetbrains.annotations.Nullable)27 MxmlJSClass (com.intellij.javascript.flex.mxml.MxmlJSClass)23 NotNull (org.jetbrains.annotations.NotNull)23 VirtualFile (com.intellij.openapi.vfs.VirtualFile)22 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)22 JSFunction (com.intellij.lang.javascript.psi.JSFunction)18 JSAttributeList (com.intellij.lang.javascript.psi.ecmal4.JSAttributeList)18 Module (com.intellij.openapi.module.Module)17 XmlFile (com.intellij.psi.xml.XmlFile)17 Project (com.intellij.openapi.project.Project)16 PsiFile (com.intellij.psi.PsiFile)16 JSQualifiedNamedElement (com.intellij.lang.javascript.psi.ecmal4.JSQualifiedNamedElement)15 ArrayList (java.util.ArrayList)14 PsiDirectory (com.intellij.psi.PsiDirectory)11 XmlTag (com.intellij.psi.xml.XmlTag)11 JSReferenceExpression (com.intellij.lang.javascript.psi.JSReferenceExpression)8 XmlElementDescriptor (com.intellij.xml.XmlElementDescriptor)8 XmlBackedJSClassImpl (com.intellij.lang.javascript.flex.XmlBackedJSClassImpl)7