Search in sources :

Example 6 with JSClass

use of com.intellij.lang.javascript.psi.ecmal4.JSClass in project intellij-plugins by JetBrains.

the class ActionScriptResolveTest method testResolve26.

@JSTestOptions({ JSTestOption.WithIndex })
public void testResolve26() throws Exception {
    String fileText = "dynamic class Object {}\n" + "package {\n" + "\timport flash.display.Sprite;\n" + "\tpublic class DoubleInterfaceResolve extends Sprite {\n" + "\t}\n" + "}\n" + "import flash.display.Sprite;\n" + "class FooView extends Sprite {\n" + "}\n" + "\n" + "interface ItfA {\n" + "    function f():It<ref>fB;\n" + "}\n" + "interface ItfB {}";
    PsiReference ref = configureByFileText(fileText, "sample.js2");
    PsiElement resolved = ref.resolve();
    assertTrue(resolved instanceof JSClass);
}
Also used : PsiReference(com.intellij.psi.PsiReference) JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass) PsiElement(com.intellij.psi.PsiElement) JSTestOptions(com.intellij.lang.javascript.JSTestOptions)

Example 7 with JSClass

use of com.intellij.lang.javascript.psi.ecmal4.JSClass in project intellij-plugins by JetBrains.

the class ActionScriptResolveTest method checkResolvedToClass.

private static void checkResolvedToClass(final ResolveResult[] resolveResults) {
    assertEquals(1, resolveResults.length);
    final PsiElement realElement = getElement(resolveResults[0]);
    assertTrue(realElement instanceof JSClass);
    assertEquals("B", ((JSClass) realElement).getName());
}
Also used : JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass) PsiElement(com.intellij.psi.PsiElement)

Example 8 with JSClass

use of com.intellij.lang.javascript.psi.ecmal4.JSClass in project intellij-plugins by JetBrains.

the class ActionScriptTypeEvaluator method evaluateNewExpressionTypes.

@Override
protected void evaluateNewExpressionTypes(JSNewExpression newExpression, @NotNull JSEvaluateContext.JSEvaluationPlace place) {
    JSExpression methodExpr = newExpression.getMethodExpression();
    if (methodExpr != null) {
        if (methodExpr instanceof JSArrayLiteralExpression) {
            JSTypeSource source = JSTypeSourceFactory.createTypeSource(methodExpr);
            JSType type = JSNamedType.createType(VECTOR_CLASS_NAME, source, JSContext.INSTANCE);
            PsiElement arrayInitializingType = newExpression.getArrayInitializingType();
            if (arrayInitializingType != null) {
                JSType argType = JSTypeUtils.createType(JSImportHandlingUtil.resolveTypeName(arrayInitializingType.getText(), newExpression), source);
                type = new JSGenericTypeImpl(source, type, argType);
            }
            addType(type, methodExpr);
        } else {
            JSType type = JSAnyType.get(methodExpr, false);
            if (methodExpr instanceof JSReferenceExpression) {
                PsiElement resolve = ((JSReferenceExpression) methodExpr).resolve();
                if (JSResolveUtil.isConstructorFunction(resolve) && resolve.getParent() instanceof JSClass) {
                    resolve = resolve.getParent();
                }
                if (resolve instanceof JSClass || resolve == null) {
                    JSType typeFromText = JSTypeUtils.createType(methodExpr.getText(), JSTypeSourceFactory.createTypeSource(methodExpr, false));
                    if (typeFromText != null)
                        type = typeFromText;
                }
            }
            addType(type, methodExpr);
        }
    }
}
Also used : JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass) PsiElement(com.intellij.psi.PsiElement)

Example 9 with JSClass

use of com.intellij.lang.javascript.psi.ecmal4.JSClass in project intellij-plugins by JetBrains.

the class ActionScriptTypeHelper method isAssignableToNamedType.

@Override
public boolean isAssignableToNamedType(@NotNull JSTypeImpl lOpType, @NotNull JSType rOpType, @Nullable ProcessingContext processingContext) {
    //noinspection unchecked
    Map<Key, Object> cachesMap = processingContext != null ? (Map<Key, Object>) processingContext.get(this) : null;
    PsiElement type = ourResolvedTypeKey.get(cachesMap);
    JSClass clazz = null;
    if (type == null) {
        type = lOpType.resolveClass();
        ourResolvedTypeKey.set(cachesMap, type != null ? type : PsiUtilCore.NULL_PSI_ELEMENT);
    } else if (type == PsiUtilCore.NULL_PSI_ELEMENT) {
        type = null;
    }
    if (type instanceof JSClass)
        clazz = (JSClass) type;
    JSClass jsClass = rOpType.resolveClass();
    if (jsClass == null && rOpType instanceof JSTypeImpl || rOpType instanceof JSSpecialNamedTypeImpl) {
        return areNamedTypesAssignable(lOpType, (JSNamedType) rOpType, processingContext);
    }
    if (jsClass != null && clazz != null) {
        return JSInheritanceUtil.isParentClass(jsClass, clazz, false, jsClass);
    }
    if (clazz == null) {
        return false;
    }
    return true;
}
Also used : JSTypeImpl(com.intellij.lang.javascript.psi.types.JSTypeImpl) JSSpecialNamedTypeImpl(com.intellij.lang.javascript.psi.types.JSSpecialNamedTypeImpl) JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass) Key(com.intellij.openapi.util.Key) PsiElement(com.intellij.psi.PsiElement)

Example 10 with JSClass

use of com.intellij.lang.javascript.psi.ecmal4.JSClass in project intellij-plugins by JetBrains.

the class FlexMoveClassProcessor method findUsages.

@NotNull
@Override
protected UsageInfo[] findUsages() {
    Collection<UsageInfo> result = Collections.synchronizedCollection(new ArrayList<UsageInfo>());
    result.addAll(Arrays.asList(super.findUsages()));
    for (JSQualifiedNamedElement element : myElements) {
        if (element instanceof JSClass) {
            JSRefactoringUtil.addConstructorUsages((JSClass) element, result);
        }
        TextOccurrencesUtil.findNonCodeUsages(element, element.getQualifiedName(), mySearchInComments, mySearchInNonJavaFiles, StringUtil.getQualifiedName(myTargetPackage, element.getName()), result);
    }
    return result.toArray(new UsageInfo[result.size()]);
}
Also used : JSQualifiedNamedElement(com.intellij.lang.javascript.psi.ecmal4.JSQualifiedNamedElement) JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass) NotNull(org.jetbrains.annotations.NotNull)

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