PsiAssignmentExpression (@NotNull PsiAssignmentExpression assignmentExpression) { CommentTracker tracker = new CommentTracker(); final PsiJavaToken sign = assignmentExpression.getOperationSign(); final PsiExpression lhs = assignmentExpression.getLExpression(); final PsiExpression rhs = assignmentExpression.getRExpression(); final String operator = sign.getText(); final String newOperator = operator.substring(0, operator.length() - 1); final String lhsText = tracker.text(lhs); final String rhsText = (rhs == null) ? "" : tracker.text(rhs); final boolean parentheses = ParenthesesUtils.areParenthesesNeeded(sign, rhs); final String cast = getCastString(lhs, rhs); final StringBuilder newExpression = new StringBuilder(lhsText); newExpression.append('=').append(cast); if (!cast.isEmpty()) { newExpression.append('('); } newExpression.append(lhsText).append(newOperator); if (parentheses) { newExpression.append('(').append(rhsText).append(')'); } else { newExpression.append(rhsText); } if (!cast.isEmpty()) { newExpression.append(')'); } final Project project = assignmentExpression.getProject(); final PsiElement replacementExpression = tracker.replaceAndRestoreComments(assignmentExpression, newExpression.toString()); return (PsiAssignmentExpression)CodeStyleManager.getInstance(project).reformat(replacementExpression); }