MCPcopy Create free account
hub / github.com/microsoft/typescript-go / nodeHandleFrom

Method nodeHandleFrom

internal/api/session.go:99–105  ·  view source on GitHub ↗

nodeHandleFrom creates an index-based node handle (index.kind.path), building a node index table for the file on-demand if needed.

(node *ast.Node)

Source from the content-addressed store, hash-verified

97// nodeHandleFrom creates an index-based node handle (index.kind.path), building a node index table
98// for the file on-demand if needed.
99func (sd *snapshotData) nodeHandleFrom(node *ast.Node) NodeHandle {
100 sourceFile := ast.GetSourceFileOfNode(node)
101 path := sourceFile.Path()
102 table := encoder.GetNodeIndexTable(sourceFile)
103 idx := table.GetIndex(node)
104 return NodeHandle(fmt.Sprintf("%d.%d.%s", idx, node.Kind, path))
105}
106
107// getOrCreateProjectRegistry returns the registry for the given project, creating it if needed.
108func (sd *snapshotData) getOrCreateProjectRegistry(projectID ProjectID) *projectRegistryData {

Calls 5

GetSourceFileOfNodeFunction · 0.92
GetNodeIndexTableFunction · 0.92
GetIndexMethod · 0.80
NodeHandleTypeAlias · 0.70
PathMethod · 0.65

Tested by

no test coverage detected