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

Method visitStructMsg

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

Source from the content-addressed store, hash-verified

432}
433
434func (un *unparser) visitStructMsg(expr ast.Expr) error {
435 m := expr.AsStruct()
436 fields := m.Fields()
437 un.str.WriteString(un.maybeQuoteFunction(m.TypeName()))
438 un.str.WriteString("{")
439 for i, f := range fields {
440 field := f.AsStructField()
441 f := field.Name()
442 if field.IsOptional() {
443 un.str.WriteString("?")
444 }
445 un.str.WriteString(un.maybeQuoteField(f))
446 un.str.WriteString(": ")
447 v := field.Value()
448 err := un.visit(v)
449 if err != nil {
450 return err
451 }
452 if i < len(fields)-1 {
453 un.str.WriteString(", ")
454 }
455 }
456 un.str.WriteString("}")
457 return nil
458}
459
460func (un *unparser) visitStructMap(expr ast.Expr) error {
461 m := expr.AsMap()

Callers 1

visitMethod · 0.95

Calls 10

maybeQuoteFunctionMethod · 0.95
maybeQuoteFieldMethod · 0.95
visitMethod · 0.95
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