boolean (LighterAST tree, @Nullable LighterASTNode expr) { if (expr == null) return false; IElementType type = expr.getTokenType(); if (type == LITERAL_EXPRESSION) { IElementType child = tree.getChildren(expr).get(0).getTokenType(); return child == JavaTokenType.TRUE_KEYWORD || child == JavaTokenType.FALSE_KEYWORD; } if (type == POLYADIC_EXPRESSION || type == BINARY_EXPRESSION) { return LightTreeUtil.firstChildOfType(tree, expr, PsiBinaryExpression.BOOLEAN_OPERATION_TOKENS) != null; } if (type == PREFIX_EXPRESSION) { return tree.getChildren(expr).get(0).getTokenType() == JavaTokenType.EXCL; } if (type == PARENTH_EXPRESSION) { return isBooleanExpression(tree, findExpressionChild(expr, tree)); } if (type == CONDITIONAL_EXPRESSION) { List<LighterASTNode> children = LightTreeUtil.getChildrenOfType(tree, expr, ElementType.EXPRESSION_BIT_SET); return children.size() == 3 && (isBooleanExpression(tree, children.get(1)) || isBooleanExpression(tree, children.get(2))); } return false; }