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

Function getSourceFileDataCell

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

Source from the content-addressed store, hash-verified

2428}
2429
2430func getSourceFileDataCell[T any](file *SourceFile, key *SourceFileDataKey[T]) *sourceFileDataCell[T] {
2431 if key == nil || key.key == 0 {
2432 panic("invalid SourceFileDataKey; use NewSourceFileDataKey")
2433 }
2434
2435 file.dataMu.Lock()
2436 defer file.dataMu.Unlock()
2437
2438 if file.data == nil {
2439 file.data = make(map[sourceFileDataKey]any)
2440 }
2441 if cell, ok := file.data[key.key]; ok {
2442 return cell.(*sourceFileDataCell[T])
2443 }
2444 cell := &sourceFileDataCell[T]{}
2445 file.data[key.key] = cell
2446 return cell
2447}
2448
2449type CheckJsDirective struct {
2450 Enabled bool

Callers 1

Calls 4

panicFunction · 0.85
makeFunction · 0.50
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected