void (@NotNull Project project, @NotNull PsiElement startElement, @NotNull ModPsiUpdater updater) { final PsiExpression expression = (PsiExpression)startElement; final PsiType type = expression.getType(); if (type == null) { return; } final PsiPrimitiveType unboxedType = (PsiPrimitiveType)ExpectedTypeUtils.findExpectedType(expression, false, true); if (unboxedType == null) { return; } final CommentTracker commentTracker = new CommentTracker(); final String newExpressionText = buildNewExpressionText(expression, unboxedType, commentTracker); final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project); final PsiElementFactory factory = psiFacade.getElementFactory(); final PsiElement parent = expression.getParent(); final String expressionText = expression.getText(); if (parent instanceof PsiTypeCastExpression typeCastExpression) { PsiReplacementUtil.replaceExpression(typeCastExpression, newExpressionText, commentTracker); } else if (parent instanceof PsiPrefixExpression prefixExpression && !unboxedType.equalsToText("boolean")) { final IElementType tokenType = prefixExpression.getOperationTokenType(); if (JavaTokenType.PLUSPLUS.equals(tokenType)) { commentTracker.markUnchanged(expression); PsiReplacementUtil.replaceExpression(prefixExpression, expressionText + '=' + newExpressionText + "+1", commentTracker); } else if (JavaTokenType.MINUSMINUS.equals(tokenType)) { commentTracker.markUnchanged(expression); PsiReplacementUtil.replaceExpression(prefixExpression, expressionText + '=' + newExpressionText + "-1", commentTracker); } else { PsiReplacementUtil.replaceExpression(prefixExpression, prefixExpression.getOperationSign().getText() + newExpressionText, commentTracker); } } else if (parent instanceof PsiPostfixExpression postfixExpression) { final IElementType tokenType = postfixExpression.getOperationTokenType(); final PsiElement grandParent = postfixExpression.getParent(); if (grandParent instanceof PsiExpressionStatement) { if (JavaTokenType.PLUSPLUS.equals(tokenType)) { commentTracker.markUnchanged(expression); PsiReplacementUtil.replaceExpression(postfixExpression, expressionText + '=' + newExpressionText + "+1", commentTracker); } else if (JavaTokenType.MINUSMINUS.equals(tokenType)) { commentTracker.markUnchanged(expression); PsiReplacementUtil.replaceExpression(postfixExpression, expressionText + '=' + newExpressionText + "-1", commentTracker); } } else { final PsiElement element = postfixExpression.replace(postfixExpression.getOperand()); final PsiStatement statement = PsiTreeUtil.getParentOfType(element, PsiStatement.class); if (statement == null) { return; } final PsiStatement newStatement; if (JavaTokenType.PLUSPLUS.equals(tokenType)) { newStatement = factory.createStatementFromText(expressionText + '=' + newExpressionText + "+1;", statement); } else { newStatement = factory.createStatementFromText(expressionText + '=' + newExpressionText + "-1;", statement); } final PsiElement greatGrandParent = statement.getParent(); greatGrandParent.addAfter(newStatement, statement); } } else if (parent instanceof PsiAssignmentExpression assignmentExpression) { final PsiExpression lExpression = assignmentExpression.getLExpression(); if (expression.equals(lExpression)) { final PsiJavaToken operationSign = assignmentExpression.getOperationSign(); final String operationSignText = operationSign.getText(); final char sign = operationSignText.charAt(0); final PsiExpression rExpression = assignmentExpression.getRExpression(); if (rExpression == null) { return; } final String text = commentTracker.text(lExpression) + '=' + newExpressionText + sign + commentTracker.text(rExpression); final PsiExpression newExpression = factory.createExpressionFromText(text, assignmentExpression); commentTracker.replaceAndRestoreComments(assignmentExpression, newExpression); } else { PsiReplacementUtil.replaceExpression(expression, newExpressionText, commentTracker); } } else { PsiReplacementUtil.replaceExpression(expression, newExpressionText, commentTracker); } }