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

Function GetOrComputeSourceFileData

internal/ast/ast.go:2422–2428  ·  view source on GitHub ↗
(file *SourceFile, key *SourceFileDataKey[T], compute func(*SourceFile) T)

Source from the content-addressed store, hash-verified

2420}
2421
2422func GetOrComputeSourceFileData[T any](file *SourceFile, key *SourceFileDataKey[T], compute func(*SourceFile) T) T {
2423 cell := getSourceFileDataCell(file, key)
2424 cell.once.Do(func() {
2425 cell.value = compute(file)
2426 })
2427 return cell.value
2428}
2429
2430func getSourceFileDataCell[T any](file *SourceFile, key *SourceFileDataKey[T]) *sourceFileDataCell[T] {
2431 if key == nil || key.key == 0 {

Callers 2

GetNodeIndexTableFunction · 0.92
EncodeSourceFileFunction · 0.92

Calls 2

getSourceFileDataCellFunction · 0.85
computeFunction · 0.85

Tested by

no test coverage detected