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()]);
}
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());
}
}
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;
}
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();
}
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;
}
Aggregations