encodeFileReferences encodes a slice of FileReferences as a msgpack array of tuples into the structured data buffer. Returns the byte offset into the buffer, or noStructuredData (0xFFFFFFFF) if the slice is empty.
(refs []*ast.FileReference, positionMap *ast.PositionMap, buf *[]byte)
| 692 | // into the structured data buffer. Returns the byte offset into the buffer, or |
| 693 | // noStructuredData (0xFFFFFFFF) if the slice is empty. |
| 694 | func encodeFileReferences(refs []*ast.FileReference, positionMap *ast.PositionMap, buf *[]byte) uint32 { |
| 695 | if len(refs) == 0 { |
| 696 | return noStructuredData |
| 697 | } |
| 698 | offset := uint32(len(*buf)) |
| 699 | *buf = msgpackWriteArrayHeader(*buf, len(refs)) |
| 700 | for _, ref := range refs { |
| 701 | // Each entry is a 5-element tuple: [pos, end, fileName, resolutionMode, preserve] |
| 702 | *buf = msgpackWriteArrayHeader(*buf, 5) |
| 703 | *buf = msgpackWriteUint(*buf, uint32(positionMap.UTF8ToUTF16(ref.Pos()))) |
| 704 | *buf = msgpackWriteUint(*buf, uint32(positionMap.UTF8ToUTF16(ref.End()))) |
| 705 | *buf = msgpackWriteString(*buf, ref.FileName) |
| 706 | *buf = msgpackWriteUint(*buf, uint32(ref.ResolutionMode)) |
| 707 | *buf = msgpackWriteBool(*buf, ref.Preserve) |
| 708 | } |
| 709 | return offset |
| 710 | } |
| 711 | |
| 712 | // encodeNodeIndexArray encodes a slice of LiteralLikeNodes as a msgpack array of |
| 713 | // uint node indices. Returns the byte offset into the buffer, or noStructuredData |
no test coverage detected