Boolean (@Nullable PsiExpression expression) { if (expression == null || m_ignoreExpressionsContainingConstants && containsReference(expression)) { return null; } if (expression instanceof PsiParenthesizedExpression parenthesizedExpression) { return evaluate(parenthesizedExpression.getExpression()); } if (expression instanceof PsiPolyadicExpression polyadicExpression) { final IElementType tokenType = polyadicExpression.getOperationTokenType(); if (tokenType.equals(JavaTokenType.OROR)) { for (PsiExpression operand : polyadicExpression.getOperands()) { if (SideEffectChecker.mayHaveSideEffects(operand)) { return null; } if (evaluate(operand) == Boolean.TRUE) { return Boolean.TRUE; } } } else if (tokenType.equals(JavaTokenType.ANDAND)) { for (PsiExpression operand : polyadicExpression.getOperands()) { if (SideEffectChecker.mayHaveSideEffects(operand)) { return null; } if (evaluate(operand) == Boolean.FALSE) { return Boolean.FALSE; } } } } else if (expression instanceof PsiPrefixExpression prefixExpression) { final IElementType tokenType = prefixExpression.getOperationTokenType(); if (JavaTokenType.EXCL.equals(tokenType)) { final PsiExpression operand = prefixExpression.getOperand(); final Boolean b = evaluate(operand); if (b == Boolean.FALSE) { return Boolean.TRUE; } else if (b == Boolean.TRUE) { return Boolean.FALSE; } } } else if (expression instanceof PsiAssignmentExpression assignmentExpression) { final IElementType tokenType = assignmentExpression.getOperationTokenType(); if (JavaTokenType.ANDEQ.equals(tokenType) || JavaTokenType.OREQ.equals(tokenType)) { return evaluate(assignmentExpression.getRExpression()); } } return (Boolean)ConstantExpressionUtil.computeCastTo(expression, PsiTypes.booleanType()); }