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

Function EncodeSourceFile

internal/api/encoder/encoder.go:397–406  ·  view source on GitHub ↗

EncodeSourceFile encodes an entire source file AST into the binary format. Returns the encoded bytes and a NodeIndexTable mapping encoder indices to AST nodes.

(sourceFile *ast.SourceFile)

Source from the content-addressed store, hash-verified

395// EncodeSourceFile encodes an entire source file AST into the binary format.
396// Returns the encoded bytes and a NodeIndexTable mapping encoder indices to AST nodes.
397func EncodeSourceFile(sourceFile *ast.SourceFile) ([]byte, *NodeIndexTable, error) {
398 data, nodeTable, err := encodeTree(sourceFile.AsNode(), sourceFile)
399 if err != nil {
400 return nil, nil, err
401 }
402 nodeTable = ast.GetOrComputeSourceFileData(sourceFile, nodeIndexTableKey, func(*ast.SourceFile) *NodeIndexTable {
403 return nodeTable
404 })
405 return data, nodeTable, nil
406}
407
408// EncodeNode encodes an arbitrary AST node and its descendants into the binary format.
409// The sourceFile is needed to provide the source text for efficient string encoding.

Calls 3

encodeTreeFunction · 0.85
AsNodeMethod · 0.65