MCPcopy Create free account
hub / github.com/cel-expr/cel-go / extractStructName

Method extractStructName

parser/pratt_parser.go:688–704  ·  view source on GitHub ↗

extractStructName converts a chain of pre-parsed AST nodes representing field selections, such as "a.b.Msg", into a qualified struct type name.

(expr ast.Expr)

Source from the content-addressed store, hash-verified

686// extractStructName converts a chain of pre-parsed AST nodes representing field selections,
687// such as "a.b.Msg", into a qualified struct type name.
688func (p *prattParserWorker) extractStructName(expr ast.Expr) (string, bool) {
689 var name string
690 for expr != nil && expr.Kind() == ast.SelectKind {
691 sel := expr.AsSelect()
692 if sel.IsTestOnly() {
693 return "", false
694 }
695 p.helper.deleteID(expr.ID())
696 name = "." + sel.FieldName() + name
697 expr = sel.Operand()
698 }
699 if expr == nil || expr.Kind() != ast.IdentKind {
700 return "", false
701 }
702 p.helper.deleteID(expr.ID())
703 return expr.AsIdent() + name, true
704}
705
706func (p *prattParserWorker) parseStruct(objID int64, structName string) ast.Expr {
707 p.nextToken() // consumes {

Callers 1

Calls 8

deleteIDMethod · 0.80
KindMethod · 0.65
AsSelectMethod · 0.65
IsTestOnlyMethod · 0.65
IDMethod · 0.65
FieldNameMethod · 0.65
OperandMethod · 0.65
AsIdentMethod · 0.65

Tested by

no test coverage detected