Integer (@NotNull PsiPolyadicExpression polyadic, PsiReferenceExpression reference) { final PsiExpression[] operands = polyadic.getOperands(); final IElementType tokenType = polyadic.getOperationTokenType(); int afterRemovalOpCountDiff = 0; int referenceIndex = -1; boolean leftPartBoxed = false; boolean hasLeftPart = false; boolean isPlus = polyadic.getOperationTokenType() == JavaTokenType.PLUS; for (int i = 0; i < operands.length; i++) { PsiExpression operand = PsiUtil.skipParenthesizedExprDown(operands[i]); if (operand == null) return null; // Assume all polyadic expressions are left associative, so handle left side if (operand == reference) { referenceIndex = i; break; } hasLeftPart = true; final PsiType operandType = operand.getType(); if (isPlus && TypeUtils.isJavaLangString(operandType)) { return afterRemovalOpCountDiff; // everything else will be string } if (!(operandType instanceof PsiPrimitiveType)) { if (NullabilityUtil.getExpressionNullability(operand, true) != Nullability.NOT_NULL) return null; leftPartBoxed = true; } } if (hasLeftPart) { afterRemovalOpCountDiff += getBinOpImpact(leftPartBoxed, tokenType); } int nextOperandIndex = referenceIndex + 1; if (nextOperandIndex < operands.length) { final PsiExpression next = operands[nextOperandIndex]; if (ExpressionUtils.isNullLiteral(next)) return null; afterRemovalOpCountDiff += getBinOpImpact(!(next.getType() instanceof PsiPrimitiveType), tokenType); } return afterRemovalOpCountDiff; }