MCPcopy Create free account
hub / github.com/brimdata/super / formatType

Method formatType

sup/formatter.go:579–607  ·  view source on GitHub ↗

formatType builds typ as a type string with any needed typedefs for named types that have not been previously defined, or whose name is redefined to a different type. These typedefs use the embedded syntax (name=type-string). Typedefs handled by decorators are handled in decorate(). The routine re-e

(typ super.Type, isComponentType bool)

Source from the content-addressed store, hash-verified

577// The routine re-enters the type formatter with a fresh builder by
578// invoking push()/pop().
579func (f *Formatter) formatType(typ super.Type, isComponentType bool) {
580 if name := f.nameOf(typ); name != "" {
581 f.build(name)
582 return
583 }
584 if named, ok := typ.(*super.TypeNamed); ok {
585 needParens := isComponentType || super.IsUnionType(named.Type)
586 f.saveType(named)
587 if needParens {
588 f.build("(")
589 }
590 f.build(named.Name)
591 f.build("=")
592 f.formatType(named.Type, false)
593 if needParens {
594 f.build(")")
595 }
596 return
597 }
598 if typ.ID() < super.IDTypeComplex {
599 f.build(super.PrimitiveName(typ))
600 return
601 }
602 f.push()
603 f.formatTypeBody(typ, isComponentType)
604 s := f.builder.String()
605 f.pop()
606 f.build(s)
607}
608
609func (f *Formatter) formatTypeBody(typ super.Type, isComponentType bool) {
610 if name := f.nameOf(typ); name != "" {

Callers 5

decorateMethod · 0.95
formatRecordMethod · 0.95
formatTypeBodyMethod · 0.95
formatTypeRecordMethod · 0.95
formatTypeUnionMethod · 0.95

Calls 10

nameOfMethod · 0.95
buildMethod · 0.95
saveTypeMethod · 0.95
pushMethod · 0.95
formatTypeBodyMethod · 0.95
popMethod · 0.95
IsUnionTypeFunction · 0.92
PrimitiveNameFunction · 0.92
IDMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected