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

Method visitStructMsg

parser/unparser.go:396–420  ·  view source on GitHub ↗
(expr ast.Expr)

Source from the content-addressed store, hash-verified

394}
395
396func (un *unparser) visitStructMsg(expr ast.Expr) error {
397 m := expr.AsStruct()
398 fields := m.Fields()
399 un.str.WriteString(m.TypeName())
400 un.str.WriteString("{")
401 for i, f := range fields {
402 field := f.AsStructField()
403 f := field.Name()
404 if field.IsOptional() {
405 un.str.WriteString("?")
406 }
407 un.str.WriteString(maybeQuoteField(f))
408 un.str.WriteString(": ")
409 v := field.Value()
410 err := un.visit(v)
411 if err != nil {
412 return err
413 }
414 if i < len(fields)-1 {
415 un.str.WriteString(", ")
416 }
417 }
418 un.str.WriteString("}")
419 return nil
420}
421
422func (un *unparser) visitStructMap(expr ast.Expr) error {
423 m := expr.AsMap()

Callers 1

visitMethod · 0.95

Calls 9

visitMethod · 0.95
maybeQuoteFieldFunction · 0.85
AsStructMethod · 0.65
FieldsMethod · 0.65
TypeNameMethod · 0.65
AsStructFieldMethod · 0.65
NameMethod · 0.65
IsOptionalMethod · 0.65
ValueMethod · 0.65

Tested by

no test coverage detected