void (@NotNull ActionContext context, @NotNull PsiNewExpression newExpression, @NotNull ModPsiUpdater updater) { final PsiTypeParameter[] typeParameters = myPsiClass.getTypeParameters(); final PsiSubstitutor psiSubstitutor = inferTypeArguments(newExpression); final PsiJavaCodeReferenceElement reference = newExpression.getClassOrAnonymousClassReference(); LOG.assertTrue(reference != null, newExpression); final PsiReferenceParameterList parameterList = reference.getParameterList(); LOG.assertTrue(parameterList != null, newExpression); PsiElementFactory factory = JavaPsiFacade.getElementFactory(context.project()); PsiTypeElement[] elements = parameterList.getTypeParameterElements(); for (int i = elements.length - 1; i >= 0; i--) { PsiType typeArg = Objects.requireNonNull(psiSubstitutor.substitute(typeParameters[i])); PsiElement replaced = elements[i].replace(factory.createTypeElement(typeArg)); JavaCodeStyleManager.getInstance(context.project()).shortenClassReferences(replaced); } }