Пример #1
0
 @Nullable
 public static PsiType getLeastUpperBoundNullable(
     @NotNull Iterable<PsiType> collection, @NotNull PsiManager manager) {
   Iterator<PsiType> iterator = collection.iterator();
   if (!iterator.hasNext()) return null;
   PsiType result = iterator.next();
   while (iterator.hasNext()) {
     result = getLeastUpperBoundNullable(result, iterator.next(), manager);
   }
   return result;
 }
        private boolean hasTypeParametersToInfer(PsiClassType classType) {
          final PsiClassType.ClassResolveResult resolveResult = classType.resolveGenerics();
          PsiClass aClass = resolveResult.getElement();
          if (aClass == null) return false;

          final Iterable<PsiTypeParameter> iterable =
              com.intellij.psi.util.PsiUtil.typeParametersIterable(aClass);
          if (!iterable.iterator().hasNext()) {
            return false;
          }

          for (PsiTypeParameter parameter : iterable) {
            PsiType type = resolveResult.getSubstitutor().substitute(parameter);
            if (type != null) {
              if (!(type instanceof PsiWildcardType)
                  || ((PsiWildcardType) type).getBound() != null) {
                return false;
              }
            }
          }
          return true;
        }