MCPcopy Index your code
hub / github.com/anomalyco/opencode / requestDiagnostics

Function requestDiagnostics

packages/opencode/src/lsp/client.ts:382–410  ·  view source on GitHub ↗
(
    filePath: string,
    requests: Promise<DiagnosticRequestResult>[],
    done: (results: DiagnosticRequestResult[]) => boolean,
  )

Source from the content-addressed store, hash-verified

380 results.some((result) => (result.byFile.get(filePath)?.length ?? 0) > 0)
381
382 async function requestDiagnostics(
383 filePath: string,
384 requests: Promise<DiagnosticRequestResult>[],
385 done: (results: DiagnosticRequestResult[]) => boolean,
386 ) {
387 if (!requests.length) return { handled: false, matched: false }
388
389 const results: DiagnosticRequestResult[] = []
390 return new Promise<{ handled: boolean; matched: boolean }>((resolve) => {
391 let pending = requests.length
392 let resolved = false
393 const finish = (merged: { handled: boolean; matched: boolean }, force = false) => {
394 if (resolved) return
395 if (!force && !done(results)) return
396 resolved = true
397 resolve(merged)
398 }
399
400 for (const request of requests) {
401 request.then((result) => {
402 results.push(result)
403 pending -= 1
404 const merged = mergeResults(filePath, results)
405 finish(merged)
406 if (pending === 0) finish(merged, true)
407 })
408 }
409 })
410 }
411
412 // LATENCY-CRITICAL: dispatch identifier pulls in parallel and unblock once one
413 // batch already produced diagnostics for the current file. Let slower pulls keep

Callers 1

Calls 3

mergeResultsFunction · 0.85
pushMethod · 0.80
finishFunction · 0.70

Tested by

no test coverage detected