(typ super.Type, isComponentType bool)
| 607 | } |
| 608 | |
| 609 | func (f *Formatter) formatTypeBody(typ super.Type, isComponentType bool) { |
| 610 | if name := f.nameOf(typ); name != "" { |
| 611 | f.build(name) |
| 612 | return |
| 613 | } |
| 614 | switch typ := typ.(type) { |
| 615 | case *super.TypeNamed: |
| 616 | // Named types are handled differently above to determine the |
| 617 | // plain form vs embedded typedef. |
| 618 | panic("named type shouldn't be formatted") |
| 619 | case *super.TypeRecord: |
| 620 | f.formatTypeRecord(typ) |
| 621 | case *super.TypeArray: |
| 622 | f.build("[") |
| 623 | f.formatType(typ.Type, false) |
| 624 | f.build("]") |
| 625 | case *super.TypeSet: |
| 626 | f.build("|[") |
| 627 | f.formatType(typ.Type, false) |
| 628 | f.build("]|") |
| 629 | case *super.TypeMap: |
| 630 | f.build("|{") |
| 631 | f.formatType(typ.KeyType, false) |
| 632 | f.build(":") |
| 633 | f.formatType(typ.ValType, false) |
| 634 | f.build("}|") |
| 635 | case *super.TypeUnion: |
| 636 | f.formatTypeUnion(typ, isComponentType) |
| 637 | case *super.TypeEnum: |
| 638 | f.formatTypeEnum(typ) |
| 639 | case *super.TypeError: |
| 640 | f.build("error(") |
| 641 | formatType(&f.builder, make(map[string]*super.TypeNamed), typ.Type, false) |
| 642 | f.build(")") |
| 643 | case *super.TypeFusion: |
| 644 | f.build("fusion(") |
| 645 | formatType(&f.builder, make(map[string]*super.TypeNamed), typ.Type, false) |
| 646 | f.build(")") |
| 647 | case *super.TypeOfType: |
| 648 | formatType(&f.builder, make(map[string]*super.TypeNamed), typ, false) |
| 649 | default: |
| 650 | panic("unknown case in formatTypeBody: " + String(typ)) |
| 651 | } |
| 652 | } |
| 653 | |
| 654 | func (f *Formatter) formatTypeRecord(typ *super.TypeRecord) { |
| 655 | f.build("{") |
no test coverage detected