void (@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { final PsiPrefixExpression prefixExpression = (PsiPrefixExpression)element.getParent(); final PsiExpression operand = prefixExpression.getOperand(); if (operand == null) { return; } final PsiExpression parentExpression = (PsiExpression)prefixExpression.getParent(); final CommentTracker commentTracker = new CommentTracker(); @NonNls final StringBuilder newExpression = new StringBuilder(); if (parentExpression instanceof PsiAssignmentExpression assignmentExpression) { final PsiExpression lhs = assignmentExpression.getLExpression(); newExpression.append(commentTracker.text(lhs)); final IElementType tokenType = assignmentExpression.getOperationTokenType(); if (tokenType.equals(JavaTokenType.PLUSEQ)) { newExpression.append("-="); } else { newExpression.append("+="); } newExpression.append(commentTracker.text(operand)); } else if (parentExpression instanceof PsiPolyadicExpression polyadicExpression) { int lastOperatorIndex = -1; IElementType lastOperator = null; for (PsiElement child = polyadicExpression.getFirstChild(); child != null; child = child.getNextSibling()) { if (child == prefixExpression) { if (lastOperatorIndex == -1) { return; } newExpression.replace(lastOperatorIndex, lastOperatorIndex + 1, lastOperator == JavaTokenType.PLUS ? "-" : "+"); newExpression.append(commentTracker.text(operand)); continue; } if (PsiUtil.isJavaToken(child, JavaTokenType.PLUS)) { lastOperatorIndex = newExpression.length(); lastOperator = JavaTokenType.PLUS; } else if (PsiUtil.isJavaToken(child, JavaTokenType.MINUS)) { lastOperatorIndex = newExpression.length(); lastOperator = JavaTokenType.MINUS; } newExpression.append(commentTracker.text(child)); } if (lastOperatorIndex == -1) { return; } } PsiReplacementUtil.replaceExpression(parentExpression, newExpression.toString(), commentTracker); }