MCPcopy Index your code
hub / github.com/microsoft/typescript-go / encodeFileReferences

Function encodeFileReferences

internal/api/encoder/encoder.go:694–710  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

692// into the structured data buffer. Returns the byte offset into the buffer, or
693// noStructuredData (0xFFFFFFFF) if the slice is empty.
694func 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

Callers 1

Calls 8

lenFunction · 0.85
msgpackWriteArrayHeaderFunction · 0.85
msgpackWriteUintFunction · 0.85
msgpackWriteStringFunction · 0.85
msgpackWriteBoolFunction · 0.85
UTF8ToUTF16Method · 0.80
PosMethod · 0.65
EndMethod · 0.65

Tested by

no test coverage detected