boolean ( PsiBinaryExpression maskExpression, PsiExpression constantExpression) { final IElementType tokenType = maskExpression.getOperationTokenType(); final Object constantValue = ConstantExpressionUtil.computeCastTo(constantExpression, PsiTypes.longType()); if (constantValue == null) { return false; } final long constantLongValue = ((Long)constantValue).longValue(); final PsiExpression maskRhs = maskExpression.getROperand(); final PsiExpression maskLhs = maskExpression.getLOperand(); final long constantMaskValue; if (PsiUtil.isConstantExpression(maskRhs)) { final Object rhsValue = ConstantExpressionUtil.computeCastTo(maskRhs, PsiTypes.longType()); if (rhsValue == null) { return false; // Might indeed be the case with "null" literal // whoes constant value evaluates to null. Check out (a|null) case. } constantMaskValue = ((Long)rhsValue).longValue(); } else { final Object lhsValue = ConstantExpressionUtil.computeCastTo(maskLhs, PsiTypes.longType()); if (lhsValue == null) { return false; } constantMaskValue = ((Long)lhsValue).longValue(); } if (tokenType.equals(JavaTokenType.OR)) { if ((constantMaskValue | constantLongValue) != constantLongValue) { return true; } } if (tokenType.equals(JavaTokenType.AND)) { if ((constantMaskValue | constantLongValue) != constantMaskValue) { return true; } } return false; }