BooleanExpressionKind (PsiPolyadicExpression expression) { final IElementType sign = expression.getOperationTokenType(); if (!booleanTokens.contains(sign)) { return BooleanExpressionKind.UNKNOWN; } final PsiExpression[] operands = expression.getOperands(); boolean containsConstant = false; boolean stopCheckingSideEffects = false; boolean sideEffectMayBeRemoved = false; boolean reducedToConstant = false; for (PsiExpression operand : operands) { if (operand == null) { return BooleanExpressionKind.UNKNOWN; } final PsiType type = operand.getType(); if (type == null || !type.equals(PsiTypes.booleanType()) && !type.equalsToText(CommonClassNames.JAVA_LANG_BOOLEAN)) { return BooleanExpressionKind.UNKNOWN; } if (!stopCheckingSideEffects && SideEffectChecker.mayHaveSideEffects(operand)) { sideEffectMayBeRemoved = true; continue; } Boolean value = evaluate(operand); if (value != null) { containsConstant = true; if ((JavaTokenType.ANDAND.equals(sign) && !value) || (JavaTokenType.OROR.equals(sign) && value)) { stopCheckingSideEffects = true; reducedToConstant = true; } if ((JavaTokenType.AND.equals(sign) && !value) || (JavaTokenType.OR.equals(sign) && value)) { reducedToConstant = true; } } } if (containsConstant) { if (sideEffectMayBeRemoved && reducedToConstant) { return CodeBlockSurrounder.canSurround(expression) ? BooleanExpressionKind.USELESS_WITH_SIDE_EFFECTS : BooleanExpressionKind.UNKNOWN; } return BooleanExpressionKind.USELESS; } return BooleanExpressionKind.UNKNOWN; }