ThreeState (PsiPolyadicExpression polyadicExpression, int operandIndex) { if (operandIndex == 0) return ThreeState.YES; IElementType tokenType = polyadicExpression.getOperationTokenType(); if (tokenType != JavaTokenType.ANDAND && tokenType != JavaTokenType.OROR) return ThreeState.UNSURE; PsiExpression[] operands = polyadicExpression.getOperands(); if (operandIndex < 0 || operandIndex >= operands.length) { throw new IndexOutOfBoundsException("operandIndex = "+operandIndex); } if (Arrays.stream(operands, 0, operandIndex + 1).allMatch(expression -> isSideEffectFree(expression, false))) { return ThreeState.YES; } boolean and = polyadicExpression.getOperationTokenType() == JavaTokenType.ANDAND; PsiExpression lastOperand = operands[operandIndex]; if (areConditionsNecessaryFor(Arrays.copyOf(operands, operandIndex), lastOperand, !and)) { return ThreeState.NO; } return ThreeState.UNSURE; }