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

Method GetChecker

internal/project/checkerpool.go:123–143  ·  view source on GitHub ↗
(ctx context.Context, file *ast.SourceFile)

Source from the content-addressed store, hash-verified

121}
122
123func (p *checkerPool) GetChecker(ctx context.Context, file *ast.SourceFile) (*checker.Checker, func()) {
124 lifetime := core.GetCheckerLifetime(ctx)
125 requestID := core.GetRequestID(ctx)
126
127 // Request affinity is cleaned up via context.AfterFunc when the request
128 // context is done. If the context can never be canceled (ctx.Done() == nil,
129 // e.g. context.Background()), that cleanup would never run and
130 // requestAssociations would grow unboundedly, so disable affinity entirely.
131 if ctx.Done() == nil {
132 requestID = ""
133 }
134
135 switch lifetime {
136 case core.CheckerLifetimeDiagnostics:
137 return p.getDiagnosticsChecker(ctx, requestID)
138 case core.CheckerLifetimeAPI:
139 return p.getPersistentChecker()
140 default:
141 return p.getQueryChecker(ctx, requestID, file)
142 }
143}
144
145// tryReacquireForRequest checks whether the given request already has an
146// associated checker. If so, it either returns the checker directly (still held)

Callers

nothing calls this directly

Calls 5

getDiagnosticsCheckerMethod · 0.95
getPersistentCheckerMethod · 0.95
getQueryCheckerMethod · 0.95
GetCheckerLifetimeFunction · 0.92
GetRequestIDFunction · 0.92

Tested by

no test coverage detected