PsiType (@NotNull PsiElement context, @NotNull PsiClassType baseType, int arrayDim, boolean raw, @NotNull PsiClass baseClass, @NotNull PsiClass inheritor) { Project project = baseClass.getProject(); PsiElementFactory factory = JavaPsiFacade.getElementFactory(project); if (!PsiResolveHelper.getInstance(project).isAccessible(inheritor, context, null)) { return null; } if (inheritor.getQualifiedName() == null && !baseClass.getManager().areElementsEquivalent(inheritor.getContainingFile(), context.getContainingFile().getOriginalFile())) { return null; } if (JavaCompletionUtil.isInExcludedPackage(inheritor, false)) return null; PsiSubstitutor superSubstitutor = TypeConversionUtil.getClassSubstitutor(baseClass, inheritor, PsiSubstitutor.EMPTY); if (superSubstitutor == null) return null; List<PsiType> typeArgs = raw ? null : getExpectedTypeArgs(context, inheritor, Arrays.asList(inheritor.getTypeParameters()), baseType); PsiClassType inheritorType = typeArgs == null || typeArgs.contains(null) ? factory.createType(inheritor, factory.createRawSubstitutor(inheritor)) : factory.createType(inheritor, typeArgs.toArray(PsiType.EMPTY_ARRAY)); PsiType result = PsiTypesUtil.createArrayType(inheritorType, arrayDim); return baseType.isAssignableFrom(result) ? result : null; }