From 7e3e8e17b0252443ce149ff608b5ac539e2cec44 Mon Sep 17 00:00:00 2001 From: Jonathan Tatum Date: Thu, 4 Sep 2025 09:46:47 -0700 Subject: [PATCH] Remove back-compatibility aliases for old names for NavigableProtoAst. PiperOrigin-RevId: 803064724 --- tools/branch_coverage_test.cc | 18 +++++++++--------- tools/cel_field_extractor.cc | 9 +++++---- tools/navigable_ast.cc | 1 + tools/navigable_ast.h | 5 ----- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/tools/branch_coverage_test.cc b/tools/branch_coverage_test.cc index 9af40605c..3a7a1c0a2 100644 --- a/tools/branch_coverage_test.cc +++ b/tools/branch_coverage_test.cc @@ -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, @@ -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) { @@ -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) { @@ -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) { @@ -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, @@ -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) { @@ -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, @@ -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) { @@ -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) { diff --git a/tools/cel_field_extractor.cc b/tools/cel_field_extractor.cc index a0407565b..50207c3cf 100644 --- a/tools/cel_field_extractor.cc +++ b/tools/cel_field_extractor.cc @@ -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(); @@ -57,7 +57,7 @@ bool IsComprehensionDefinedField(const cel::AstNode& node) { absl::flat_hash_set ExtractFieldPaths( const cel::expr::Expr& expr) { - NavigableAst ast = NavigableAst::Build(expr); + NavigableProtoAst ast = NavigableProtoAst::Build(expr); absl::flat_hash_set field_paths; std::vector fields_in_scope; @@ -66,7 +66,8 @@ absl::flat_hash_set 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; diff --git a/tools/navigable_ast.cc b/tools/navigable_ast.cc index 4ff9b9f06..0de2d86c6 100644 --- a/tools/navigable_ast.cc +++ b/tools/navigable_ast.cc @@ -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; using NavigableAstMetadata = diff --git a/tools/navigable_ast.h b/tools/navigable_ast.h index 5bf013cae..1ebf6883c 100644 --- a/tools/navigable_ast.h +++ b/tools/navigable_ast.h @@ -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_