void (@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { final PsiNewExpression expression = tryCast(element.getParent(), PsiNewExpression.class); if (expression == null) return; final PsiExpressionList args = expression.getArgumentList(); if (args == null) return; final PsiExpression[] params = args.getExpressions(); if (!(params.length == 1 || params.length == 2)) return; PsiMethodCallExpression resolvedExpression = getMethodCallExpression(params[0]); if (resolvedExpression == null) return; final PsiElement qualifier = resolvedExpression.getMethodExpression().getQualifier(); if (qualifier == null) return; CommentTracker ct = new CommentTracker(); String newText = ct.text(qualifier) + ".toString(" + (params.length == 2 ? ct.text(params[1]) : "") + ")"; PsiElement parent = tryCast(PsiUtil.skipParenthesizedExprUp(resolvedExpression.getParent()), PsiLocalVariable.class); if (parent != null) ct.delete(parent); ct.replaceAndRestoreComments(expression, newText); }