(indent int, typ *super.TypeMap, bytes scode.Bytes, known bool)
| 519 | } |
| 520 | |
| 521 | func (f *Formatter) formatMap(indent int, typ *super.TypeMap, bytes scode.Bytes, known bool) bool { |
| 522 | empty := true |
| 523 | f.build("|{") |
| 524 | indent += f.tab |
| 525 | sep := f.newline |
| 526 | keyElems := newElemBuilder(typ.KeyType) |
| 527 | valElems := newElemBuilder(typ.ValType) |
| 528 | for it := bytes.Iter(); !it.Done(); { |
| 529 | keyBytes := it.Next() |
| 530 | empty = false |
| 531 | f.build(sep) |
| 532 | f.indent(indent, "") |
| 533 | var keyType super.Type |
| 534 | keyType, keyBytes = keyElems.add(keyBytes) |
| 535 | f.formatValue(indent, keyType, keyBytes, known, true) |
| 536 | if super.TypeUnder(keyType) == super.TypeIP && len(keyBytes) == 16 { |
| 537 | // To avoid ambiguity, whitespace must separate an IPv6 |
| 538 | // map key from the colon that follows it. |
| 539 | f.build(" ") |
| 540 | } |
| 541 | f.build(":") |
| 542 | if f.tab > 0 { |
| 543 | f.build(" ") |
| 544 | } |
| 545 | valType, valBytes := valElems.add(it.Next()) |
| 546 | f.formatValue(indent, valType, valBytes, known, true) |
| 547 | sep = "," + f.newline |
| 548 | } |
| 549 | f.build(f.newline) |
| 550 | f.indent(indent-f.tab, "}|") |
| 551 | if keyElems.needsDecoration() || valElems.needsDecoration() { |
| 552 | f.decorate(typ, true) |
| 553 | } |
| 554 | return empty |
| 555 | } |
| 556 | |
| 557 | func (f *Formatter) indent(tab int, s string) { |
| 558 | for range tab { |
no test coverage detected