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)
| 577 | // The routine re-enters the type formatter with a fresh builder by |
| 578 | // invoking push()/pop(). |
| 579 | func (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 | |
| 609 | func (f *Formatter) formatTypeBody(typ super.Type, isComponentType bool) { |
| 610 | if name := f.nameOf(typ); name != "" { |
no test coverage detected