boolean (PsiElement element) { if (element instanceof PsiBinaryExpression binOp) { if(ComparisonUtils.isComparisonOperation(binOp.getOperationTokenType())) { PsiExpression comparedWith = null; if(ExpressionUtils.isLiteral(binOp.getROperand())) { comparedWith = binOp.getLOperand(); } else if(ExpressionUtils.isLiteral(binOp.getLOperand())) { comparedWith = binOp.getROperand(); } comparedWith = PsiUtil.skipParenthesizedExprDown(comparedWith); if (isConstantOfType(comparedWith, PsiTypes.intType(), PsiTypes.longType())) { // like "if(DEBUG_LEVEL > 2)" return true; } if(comparedWith instanceof PsiBinaryExpression subOp) { if(subOp.getOperationTokenType().equals(JavaTokenType.AND)) { PsiExpression left = PsiUtil.skipParenthesizedExprDown(subOp.getLOperand()); PsiExpression right = PsiUtil.skipParenthesizedExprDown(subOp.getROperand()); if(isConstantOfType(left, PsiTypes.intType(), PsiTypes.longType()) || isConstantOfType(right, PsiTypes.intType(), PsiTypes.longType())) { // like "if((FLAGS & SOME_FLAG) != 0)" return true; } } } } } // like "if(DEBUG)" return isConstantOfType(element, PsiTypes.booleanType()); }