List<TypeParameterInfoView> (@NotNull JavaCodeFragmentFactory factory, @NotNull List<? extends PsiTypeParameter> classTypeParameters, @NotNull List<? extends PsiTypeElement> typeElements) { final TypeParameterNameSuggester suggester = new TypeParameterNameSuggester(classTypeParameters); List<TypeParameterInfoView> result = new ArrayList<>(); int listIndex = 0; for (PsiTypeElement typeElement : typeElements) { if (listIndex < classTypeParameters.size()) { final PsiTypeParameter typeParameter = classTypeParameters.get(listIndex); if (isAssignable(typeParameter, typeElement.getType())) { result.add(new TypeParameterInfoView(new Existing(listIndex++), null, null)); continue; } } final PsiType defaultType = typeElement.getType(); final String suggestedName; PsiClassType boundType = null; if (defaultType instanceof PsiClassType) { suggestedName = suggester.suggest((PsiClassType)defaultType); final PsiClass resolved = ((PsiClassType)defaultType).resolve(); if (resolved != null) { final PsiReferenceList extendsList = resolved.getExtendsList(); if (extendsList != null) { final PsiClassType[] types = extendsList.getReferencedTypes(); if (types.length == 1) { boundType = types[0]; } } } } else { suggestedName = suggester.suggestUnusedName("T"); } final PsiTypeCodeFragment boundFragment = CommonJavaRefactoringUtil.createTableCodeFragment(boundType, typeElement, factory, true); result.add(new TypeParameterInfoView(new New(suggestedName, defaultType, null), boundFragment, boundType == null ? factory.createTypeCodeFragment(suggestedName, typeElement, true) : CommonJavaRefactoringUtil .createTableCodeFragment(boundType, typeElement, factory, false))); } return result; }