MCPcopy Create free account
hub / github.com/anomalyco/opencode / waitForDocumentDiagnostics

Function waitForDocumentDiagnostics

packages/opencode/src/lsp/client.ts:499–519  ·  view source on GitHub ↗
(request: { path: string; version: number; after?: number })

Source from the content-addressed store, hash-verified

497 }
498
499 async function waitForDocumentDiagnostics(request: { path: string; version: number; after?: number }) {
500 const startedAt = request.after ?? Date.now()
501 const pushWait = waitForFreshPush({
502 path: request.path,
503 version: request.version,
504 after: startedAt,
505 timeout: DIAGNOSTICS_DOCUMENT_WAIT_TIMEOUT_MS,
506 })
507
508 while (Date.now() - startedAt < DIAGNOSTICS_DOCUMENT_WAIT_TIMEOUT_MS) {
509 const result = await requestDocumentDiagnostics(request.path)
510 if (result.matched) return
511 const remaining = DIAGNOSTICS_DOCUMENT_WAIT_TIMEOUT_MS - (Date.now() - startedAt)
512 if (remaining <= 0) return
513 const next = await Promise.race([
514 pushWait.then((ready) => (ready ? "push" : ("timeout" as const))),
515 waitForRegistrationChange(remaining).then((changed) => (changed ? "registration" : ("timeout" as const))),
516 ])
517 if (next !== "registration") return
518 }
519 }
520
521 async function waitForFullDiagnostics(request: { path: string; version: number; after?: number }) {
522 const startedAt = request.after ?? Date.now()

Callers 1

waitForDiagnosticsFunction · 0.85

Calls 3

waitForFreshPushFunction · 0.85

Tested by

no test coverage detected