MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / ExtractQualifiedName

Method ExtractQualifiedName

parser/parser.cc:1502–1521  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1500}
1501
1502std::string ParserVisitor::ExtractQualifiedName(antlr4::ParserRuleContext* ctx,
1503 const Expr& e) {
1504 if (e == Expr{}) {
1505 return "";
1506 }
1507
1508 if (const auto* ident_expr = absl::get_if<IdentExpr>(&e.kind()); ident_expr) {
1509 return ident_expr->name();
1510 }
1511 if (const auto* select_expr = absl::get_if<SelectExpr>(&e.kind());
1512 select_expr) {
1513 std::string prefix = ExtractQualifiedName(ctx, select_expr->operand());
1514 if (!prefix.empty()) {
1515 return absl::StrCat(prefix, ".", select_expr->field());
1516 }
1517 }
1518 factory_.ReportError(factory_.GetSourceRange(e.id()),
1519 "expected a qualified name");
1520 return "";
1521}
1522
1523// Replacements for absl::StrReplaceAll for escaping standard whitespace
1524// characters.

Callers

nothing calls this directly

Calls 7

GetSourceRangeMethod · 0.80
kindMethod · 0.45
nameMethod · 0.45
emptyMethod · 0.45
fieldMethod · 0.45
ReportErrorMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected