String (PsiExpression max, PsiExpression min, boolean plusOne, CommentTracker commentTracker) { max = PsiUtil.skipParenthesizedExprDown(max); if (max == null) { return null; } min = PsiUtil.skipParenthesizedExprDown(min); if (min == null) { return buildExpressionText(max, plusOne, commentTracker); } final Object minConstant = ExpressionUtils.computeConstantExpression(min); if (minConstant instanceof Number minNumber) { final int minValue = plusOne ? minNumber.intValue() - 1 : minNumber.intValue(); if (minValue == 0) { return buildExpressionText(max, false, commentTracker); } if (max instanceof PsiLiteralExpression) { final Object maxConstant = ExpressionUtils.computeConstantExpression(max); if (maxConstant instanceof Number number) { return String.valueOf(number.intValue() - minValue); } } final String maxText = buildExpressionText(max, false, commentTracker); return minValue > 0 ? maxText + '-' + minValue : maxText + '+' + -minValue; } // - 1 because of the increment inside the com.siyeh.ig.psiutils.CommentTracker.text(com.intellij.psi.PsiExpression, int) final String minText = commentTracker.text(min, ParenthesesUtils.ADDITIVE_PRECEDENCE - 1); final String maxText = buildExpressionText(max, plusOne, commentTracker); return maxText + '-' + minText; }