void (@NotNull PsiClass aClass, String name) { if (aClass instanceof PsiAnonymousClass) return; if (name.equals(aClass.getName()) && myTypeParametersToCreate.isEmpty()) return; PsiElementFactory factory = JavaPsiFacade.getElementFactory(aClass.getProject()); int origCount = aClass.getTypeParameters().length; for (PsiReference reference : ReferencesSearch.search(aClass, aClass.getUseScope()).findAll()) { reference.handleElementRename(name); if (!myTypeParametersToCreate.isEmpty()) { if (reference.getElement() instanceof PsiJavaCodeReferenceElement refElement && !(refElement.getParent() instanceof PsiTypeElement typeElement && typeElement.getParent() instanceof PsiClassObjectAccessExpression)) { PsiReferenceParameterList list = PsiTreeUtil.getChildOfType(refElement, PsiReferenceParameterList.class); // Do not modify broken or already raw parameter lists if (list != null && list.getTypeArgumentCount() == origCount) { for (PsiTypeParameter parameter : myTypeParametersToCreate) { PsiTypeElement element = factory.createTypeElement(factory.createType(parameter)); list.add(element); } } } } } }