void (@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { PsiLocalVariable variable = getVariable(element); if (variable == null) return; PsiExpression initializer = variable.getInitializer(); if (initializer == null) return; PsiClassType type = ObjectUtils.tryCast(variable.getType(), PsiClassType.class); if (type == null) return; String typeParameters = ""; if (myCollectionName.equals(CommonClassNames.JAVA_UTIL_HASH_MAP)) { PsiType keyParameter = PsiUtil.substituteTypeParameter(type, CommonClassNames.JAVA_UTIL_MAP, 0, false); PsiType valueParameter = PsiUtil.substituteTypeParameter(type, CommonClassNames.JAVA_UTIL_MAP, 1, false); if (keyParameter != null && valueParameter != null) { typeParameters = "<"+keyParameter.getCanonicalText()+","+valueParameter.getCanonicalText()+">"; } } else { PsiType elementParameter = PsiUtil.substituteTypeParameter(type, CommonClassNames.JAVA_LANG_ITERABLE, 0, false); if (elementParameter != null) { typeParameters = "<" + elementParameter.getCanonicalText() + ">"; } } CommentTracker ct = new CommentTracker(); PsiElement replacement = ct.replaceAndRestoreComments(initializer, "new " + myCollectionName + typeParameters + "(" + ct.text(initializer) + ")"); RemoveRedundantTypeArgumentsUtil.removeRedundantTypeArguments(replacement); updater.highlight(replacement); }