PsiClassType (@NotNull PsiClass psiClass, PsiType @NotNull ... psiTypes) { final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(psiClass.getProject()); final PsiTypeParameter[] classTypeParameters = psiClass.getTypeParameters(); final int substituteTypesCount = psiTypes.length; if (classTypeParameters.length >= substituteTypesCount) { PsiSubstitutor newSubstitutor = PsiSubstitutor.EMPTY; final int fromIndex = classTypeParameters.length - substituteTypesCount; for (int i = 0; i < fromIndex; i++) { newSubstitutor = newSubstitutor.put(classTypeParameters[i], elementFactory.createType(classTypeParameters[i])); } for (int i = fromIndex; i < classTypeParameters.length; i++) { newSubstitutor = newSubstitutor.put(classTypeParameters[i], psiTypes[i - fromIndex]); } return elementFactory.createType(psiClass, newSubstitutor); } return elementFactory.createType(psiClass); }