Search in sources :

Example 16 with PsiClassType

use of com.intellij.psi.PsiClassType in project intellij-community by JetBrains.

the class GrThrowsClauseImpl method getReferenceElements.

@Override
@NotNull
public PsiJavaCodeReferenceElement[] getReferenceElements() {
    PsiClassType[] types = getReferencedTypes();
    if (types.length == 0)
        return PsiJavaCodeReferenceElement.EMPTY_ARRAY;
    PsiManagerEx manager = getManager();
    List<PsiJavaCodeReferenceElement> result = ContainerUtil.newArrayList();
    for (PsiClassType type : types) {
        PsiClassType.ClassResolveResult resolveResult = type.resolveGenerics();
        PsiClass resolved = resolveResult.getElement();
        if (resolved != null) {
            result.add(new LightClassReference(manager, type.getCanonicalText(), resolved, resolveResult.getSubstitutor()));
        }
    }
    return result.toArray(new PsiJavaCodeReferenceElement[result.size()]);
}
Also used : PsiClassType(com.intellij.psi.PsiClassType) LightClassReference(com.intellij.psi.impl.light.LightClassReference) PsiJavaCodeReferenceElement(com.intellij.psi.PsiJavaCodeReferenceElement) PsiClass(com.intellij.psi.PsiClass) PsiManagerEx(com.intellij.psi.impl.PsiManagerEx) NotNull(org.jetbrains.annotations.NotNull)

Example 17 with PsiClassType

use of com.intellij.psi.PsiClassType in project android by JetBrains.

the class CallgraphBuilder method addInvokeExprWithThisRef.

public void addInvokeExprWithThisRef(GraphNode node, PsiType thisBaseType, PsiCFGMethod method) {
    if (!method.isAbstract()) {
        addToCallGraph(node, method);
    } else {
        PsiClassType classType = null;
        PsiCFGClass cfgClass = null;
        if (thisBaseType instanceof PsiClassType) {
            classType = (PsiClassType) thisBaseType;
            cfgClass = mScene.getPsiCFGClass(classType.resolve());
        } else {
            PsiCFGDebugUtil.LOG.warning("PsiType of ThisRef is not a PsiClassType :" + thisBaseType.getClass().getSimpleName());
            return;
        }
        if (cfgClass == null) {
            PsiCFGDebugUtil.LOG.warning("PsiType of ThisRef cannot be resolved to cfgClass :" + thisBaseType.getClass().getSimpleName());
        }
        ArrayList<PsiCFGMethod> methodsList = Lists.newArrayList();
        recursivelyQueryConcreteMethodFromChildrenWithCache(methodsList, cfgClass, method.getSignature());
    }
}
Also used : PsiCFGMethod(com.android.tools.idea.experimental.codeanalysis.datastructs.PsiCFGMethod) PsiClassType(com.intellij.psi.PsiClassType) PsiCFGClass(com.android.tools.idea.experimental.codeanalysis.datastructs.PsiCFGClass)

Example 18 with PsiClassType

use of com.intellij.psi.PsiClassType in project intellij-plugins by JetBrains.

the class CfmlExpressionTypeCalculator method checkAndReturnNumeric.

@Nullable
private static PsiType checkAndReturnNumeric(@NotNull CfmlExpression leftOperand, @NotNull CfmlExpression rightOperand) {
    PsiType rightType = rightOperand.getPsiType();
    if (rightType == null) {
        return null;
    }
    PsiType leftType = leftOperand.getPsiType();
    if (leftType == null) {
        return null;
    }
    if (isNumericType(leftType) && isNumericType(rightType)) {
        PsiClassType boxedType = ((PsiPrimitiveType) unboxAndBalanceTypes(leftType, rightType)).getBoxedType(leftOperand.getManager(), leftOperand.getResolveScope());
        return boxedType;
    }
    return null;
}
Also used : PsiClassType(com.intellij.psi.PsiClassType) PsiPrimitiveType(com.intellij.psi.PsiPrimitiveType) PsiType(com.intellij.psi.PsiType) Nullable(org.jetbrains.annotations.Nullable)

Example 19 with PsiClassType

use of com.intellij.psi.PsiClassType in project android-parcelable-intellij-plugin by mcharmas.

the class PsiUtils method getNonGenericType.

public static String getNonGenericType(PsiType type) {
    if (type instanceof PsiClassType) {
        PsiClassType pct = (PsiClassType) type;
        final PsiClass psiClass = pct.resolve();
        return psiClass != null ? psiClass.getQualifiedName() : null;
    }
    return type.getCanonicalText();
}
Also used : PsiClassType(com.intellij.psi.PsiClassType) PsiClass(com.intellij.psi.PsiClass)

Example 20 with PsiClassType

use of com.intellij.psi.PsiClassType in project android-parcelable-intellij-plugin by mcharmas.

the class PsiUtils method isTypedClass.

/**
     * Checks that the given type is an implementer of the given canonicalName with the given typed parameters
     *
     * @param type                what we're checking against
     * @param canonicalName       the type must extend/implement this generic
     * @param canonicalParamNames the type that the generic(s) must be (in this order)
     * @return
     */
public static boolean isTypedClass(PsiType type, String canonicalName, String... canonicalParamNames) {
    PsiClass parameterClass = PsiTypesUtil.getPsiClass(type);
    if (parameterClass == null) {
        return false;
    }
    // This is a safe cast, for if parameterClass != null, the type was checked in PsiTypesUtil#getPsiClass(...)
    PsiClassType pct = (PsiClassType) type;
    // Main class name doesn't match; exit early
    if (!canonicalName.equals(parameterClass.getQualifiedName())) {
        return false;
    }
    List<PsiType> psiTypes = new ArrayList<PsiType>(pct.resolveGenerics().getSubstitutor().getSubstitutionMap().values());
    for (int i = 0; i < canonicalParamNames.length; i++) {
        if (!isOfType(psiTypes.get(i), canonicalParamNames[i])) {
            return false;
        }
    }
    // Passed all screenings; must be a match!
    return true;
}
Also used : PsiClassType(com.intellij.psi.PsiClassType) PsiClass(com.intellij.psi.PsiClass) ArrayList(java.util.ArrayList) PsiType(com.intellij.psi.PsiType)

Aggregations

PsiClassType (com.intellij.psi.PsiClassType)39 PsiType (com.intellij.psi.PsiType)20 PsiClass (com.intellij.psi.PsiClass)16 PsiElement (com.intellij.psi.PsiElement)10 NotNull (org.jetbrains.annotations.NotNull)5 Nullable (org.jetbrains.annotations.Nullable)4 UExpression (org.jetbrains.uast.UExpression)4 Location (com.android.tools.klint.detector.api.Location)3 PsiPrimitiveType (com.intellij.psi.PsiPrimitiveType)3 ArrayList (java.util.ArrayList)3 AbstractResourceRepository (com.android.ide.common.res2.AbstractResourceRepository)2 ResourceItem (com.android.ide.common.res2.ResourceItem)2 ResourceUrl (com.android.ide.common.resources.ResourceUrl)2 PsiCFGClass (com.android.tools.idea.experimental.codeanalysis.datastructs.PsiCFGClass)2 PsiCFGMethod (com.android.tools.idea.experimental.codeanalysis.datastructs.PsiCFGMethod)2 JavaEvaluator (com.android.tools.klint.client.api.JavaEvaluator)2 LintClient (com.android.tools.klint.client.api.LintClient)2 Project (com.intellij.openapi.project.Project)2 PsiArrayType (com.intellij.psi.PsiArrayType)2 PsiField (com.intellij.psi.PsiField)2