@Override public boolean isValid() { for (PsiType conjunct : myConjuncts) { if (!conjunct.isValid()) return false; } return true; }
@Override public boolean isValid() { for (PsiType type : myTypes) { if (!type.isValid()) return false; } return true; }
@Override public boolean isValid() { return myBound == null || myBound.isValid(); }
@Override public boolean isValid() { return myComponentType.isValid(); }
public static void ensureValidType(@NotNull PsiType type, @Nullable String customMessage) { if (!type.isValid()) { TimeoutUtil.sleep(1); // to see if processing in another thread suddenly makes the type valid again (which is a bug) if (type.isValid()) { LOG.error("PsiType resurrected: " + type + " of " + type.getClass() + " " + customMessage); return; } if (type instanceof PsiClassType) { try { PsiClass psiClass = ((PsiClassType)type).resolve(); // should throw exception if (psiClass != null) { ensureValid(psiClass); } } catch (PsiInvalidElementAccessException e) { throw customMessage == null? e : new RuntimeException(customMessage, e); } } throw new AssertionError("Invalid type: " + type + " of class " + type.getClass() + " " + customMessage); } }
/** * Returns the primitive type corresponding to a boxed class type. * * @param type the type to get the unboxed primitive type for. * @return the primitive type, or null if the type does not represent a boxed primitive type. */ @Nullable public static PsiPrimitiveType getUnboxedType(PsiType type) { if (!(type instanceof PsiClassType)) return null; LanguageLevel languageLevel = ((PsiClassType)type).getLanguageLevel(); if (!languageLevel.isAtLeast(LanguageLevel.JDK_1_5)) return null; assert type.isValid() : type; PsiClass psiClass = ((PsiClassType)type).resolve(); if (psiClass == null) return null; PsiPrimitiveType unboxed = ourQNameToUnboxed.get(psiClass.getQualifiedName()); PsiAnnotation[] annotations = type.getAnnotations(); if (unboxed != null && annotations.length > 0) { unboxed = new PsiPrimitiveType(unboxed.myName, annotations); } return unboxed; }
@NotNull public static MethodSignatureBackedByPsiMethod create(@NotNull PsiMethod method, @NotNull PsiSubstitutor substitutor, boolean isRaw) { PsiTypeParameter[] methodTypeParameters = method.getTypeParameters(); if (isRaw) { substitutor = JavaPsiFacade.getInstance(method.getProject()).getElementFactory().createRawSubstitutor(substitutor, methodTypeParameters); methodTypeParameters = PsiTypeParameter.EMPTY_ARRAY; } assert substitutor.isValid(); final PsiParameter[] parameters = method.getParameterList().getParameters(); PsiType[] parameterTypes = PsiType.createArray(parameters.length); for (int i = 0; i < parameterTypes.length; i++) { PsiParameter parameter = parameters[i]; PsiType type = parameter.getType(); parameterTypes[i] = isRaw ? TypeConversionUtil.erasure(substitutor.substitute(type)) : type; if (!parameterTypes[i].isValid()) { PsiUtil.ensureValidType(parameterTypes[i], "Method " + method + " of " + method.getClass() + "; param " + parameter + " of " + parameter.getClass()); } } return new MethodSignatureBackedByPsiMethod(method, substitutor, isRaw, parameterTypes, methodTypeParameters); } }
LOG.assertTrue(toPut == null || toPut.isValid(), toPut); substitutor = substitutor.put(typeParameter, toPut);