void (@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { final PsiExpression expression; if (element instanceof PsiExpression) { expression = (PsiExpression)element; } else { expression = (PsiExpression)element.getParent().getParent(); } CommentTracker commentTracker = new CommentTracker(); final String expressionText; if (removeToString) { final PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)expression; final PsiReferenceExpression methodExpression = methodCallExpression.getMethodExpression(); final PsiExpression qualifier = methodExpression.getQualifierExpression(); if (qualifier == null) { return; } expressionText = commentTracker.text(qualifier); } else { expressionText = commentTracker.text(expression); } @NonNls final String newExpressionText; if (deepString) { newExpressionText = "java.util.Arrays.deepToString(" + expressionText + ')'; } else { newExpressionText = "java.util.Arrays.toString(" + expressionText + ')'; } final PsiElement parent = expression.getParent(); if (parent instanceof PsiExpressionList) { final PsiElement grandParent = parent.getParent(); if (grandParent instanceof PsiMethodCallExpression methodCallExpression) { final PsiReferenceExpression methodExpression = methodCallExpression.getMethodExpression(); if ("valueOf".equals(methodExpression.getReferenceName())) { PsiReplacementUtil.replaceExpressionAndShorten(methodCallExpression, newExpressionText, commentTracker); return; } } } PsiReplacementUtil.replaceExpressionAndShorten(expression, newExpressionText, commentTracker); }