Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions tools/branch_coverage_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ TEST(BranchCoverage, IncrementsCounters) {
EXPECT_TRUE(result.IsBool() && result.BoolOrDie() == true);

using Stats = BranchCoverage::NodeCoverageStats;
const NavigableAst& ast = coverage->ast();
const NavigableProtoAst& ast = coverage->ast();
auto root_node_stats = coverage->StatsForNode(ast.Root().expr()->id());

EXPECT_THAT(root_node_stats, MatchesNodeStats(Stats{/*is_boolean=*/true,
Expand All @@ -195,7 +195,7 @@ TEST(BranchCoverage, IncrementsCounters) {
/*boolean_false_count=*/0,
/*error_count=*/0}));

const AstNode* ternary;
const NavigableProtoAstNode* ternary;
for (const auto& node : ast.Root().DescendantsPreorder()) {
if (node.node_kind() == NodeKind::kCall &&
node.expr()->call_expr().function() == cel::builtin::kTernary) {
Expand All @@ -219,7 +219,7 @@ TEST(BranchCoverage, IncrementsCounters) {
/*boolean_false_count=*/0,
/*error_count=*/0}));

const AstNode* not_arg_expr;
const NavigableProtoAstNode* not_arg_expr;
for (const auto& node : ast.Root().DescendantsPreorder()) {
if (node.node_kind() == NodeKind::kCall &&
node.expr()->call_expr().function() == cel::builtin::kNot) {
Expand All @@ -237,7 +237,7 @@ TEST(BranchCoverage, IncrementsCounters) {
/*boolean_false_count=*/1,
/*error_count=*/0}));

const AstNode* div_expr;
const NavigableProtoAstNode* div_expr;
for (const auto& node : ast.Root().DescendantsPreorder()) {
if (node.node_kind() == NodeKind::kCall &&
node.expr()->call_expr().function() == cel::builtin::kDivide) {
Expand Down Expand Up @@ -306,7 +306,7 @@ TEST(BranchCoverage, AccumulatesAcrossRuns) {
<< result.DebugString();

using Stats = BranchCoverage::NodeCoverageStats;
const NavigableAst& ast = coverage->ast();
const NavigableProtoAst& ast = coverage->ast();
auto root_node_stats = coverage->StatsForNode(ast.Root().expr()->id());

EXPECT_THAT(root_node_stats, MatchesNodeStats(Stats{/*is_boolean=*/true,
Expand All @@ -315,7 +315,7 @@ TEST(BranchCoverage, AccumulatesAcrossRuns) {
/*boolean_false_count=*/1,
/*error_count=*/0}));

const AstNode* ternary;
const NavigableProtoAstNode* ternary;
for (const auto& node : ast.Root().DescendantsPreorder()) {
if (node.node_kind() == NodeKind::kCall &&
node.expr()->call_expr().function() == cel::builtin::kTernary) {
Expand Down Expand Up @@ -378,7 +378,7 @@ TEST(BranchCoverage, CountsErrors) {
EXPECT_TRUE(result.IsBool() && result.BoolOrDie() == false);

using Stats = BranchCoverage::NodeCoverageStats;
const NavigableAst& ast = coverage->ast();
const NavigableProtoAst& ast = coverage->ast();
auto root_node_stats = coverage->StatsForNode(ast.Root().expr()->id());

EXPECT_THAT(root_node_stats, MatchesNodeStats(Stats{/*is_boolean=*/true,
Expand All @@ -387,7 +387,7 @@ TEST(BranchCoverage, CountsErrors) {
/*boolean_false_count=*/1,
/*error_count=*/0}));

const AstNode* ternary;
const NavigableProtoAstNode* ternary;
for (const auto& node : ast.Root().DescendantsPreorder()) {
if (node.node_kind() == NodeKind::kCall &&
node.expr()->call_expr().function() == cel::builtin::kTernary) {
Expand All @@ -396,7 +396,7 @@ TEST(BranchCoverage, CountsErrors) {
}
}

const AstNode* div_expr;
const NavigableProtoAstNode* div_expr;
for (const auto& node : ast.Root().DescendantsPreorder()) {
if (node.node_kind() == NodeKind::kCall &&
node.expr()->call_expr().function() == cel::builtin::kDivide) {
Expand Down
9 changes: 5 additions & 4 deletions tools/cel_field_extractor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ namespace cel {

namespace {

bool IsComprehensionDefinedField(const cel::AstNode& node) {
const cel::AstNode* current_node = &node;
bool IsComprehensionDefinedField(const cel::NavigableProtoAstNode& node) {
const cel::NavigableProtoAstNode* current_node = &node;

while (current_node->parent() != nullptr) {
current_node = current_node->parent();
Expand Down Expand Up @@ -57,7 +57,7 @@ bool IsComprehensionDefinedField(const cel::AstNode& node) {

absl::flat_hash_set<std::string> ExtractFieldPaths(
const cel::expr::Expr& expr) {
NavigableAst ast = NavigableAst::Build(expr);
NavigableProtoAst ast = NavigableProtoAst::Build(expr);

absl::flat_hash_set<std::string> field_paths;
std::vector<std::string> fields_in_scope;
Expand All @@ -66,7 +66,8 @@ absl::flat_hash_set<std::string> ExtractFieldPaths(
// expression) always have only one operand, so its operand is visited
// next in the loop iteration (which results in the path being extended,
// completed, or discarded if uninteresting).
for (const cel::AstNode& node : ast.Root().DescendantsPreorder()) {
for (const cel::NavigableProtoAstNode& node :
ast.Root().DescendantsPreorder()) {
if (node.node_kind() == cel::NodeKind::kSelect) {
fields_in_scope.push_back(node.expr()->select_expr().field());
continue;
Expand Down
1 change: 1 addition & 0 deletions tools/navigable_ast.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ using ::cel::expr::Expr;
using ::google::api::expr::runtime::AstTraverse;
using ::google::api::expr::runtime::SourcePosition;

using AstNode = NavigableProtoAstNode;
using NavigableAstNodeData =
common_internal::NavigableAstNodeData<common_internal::ProtoAstTraits>;
using NavigableAstMetadata =
Expand Down
5 changes: 0 additions & 5 deletions tools/navigable_ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,6 @@ class NavigableProtoAst : public common_internal::NavigableAstBase<
using Base::Base;
};

// Type aliases for backwards compatibility.
// To be removed.
using AstNode = NavigableProtoAstNode;
using NavigableAst = NavigableProtoAst;

} // namespace cel

#endif // THIRD_PARTY_CEL_CPP_TOOLS_NAVIGABLE_AST_H_