MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / collectDiagnostics

Function collectDiagnostics

vscode-extension/src/extension.ts:198–219  ·  view source on GitHub ↗

Collect language-server diagnostics for a file (optionally only those touching `range`).

(uri: vscode.Uri, range?: vscode.Range)

Source from the content-addressed store, hash-verified

196
197/** Collect language-server diagnostics for a file (optionally only those touching `range`). */
198function collectDiagnostics(uri: vscode.Uri, range?: vscode.Range): { text: string; count: number } {
199 const all = vscode.languages.getDiagnostics(uri);
200 // Default to errors + warnings (skip hint/info noise). If a specific range is
201 // given (e.g. the lightbulb on one squiggle), include whatever sits in it.
202 let diags = all.filter(d =>
203 d.severity === vscode.DiagnosticSeverity.Error ||
204 d.severity === vscode.DiagnosticSeverity.Warning);
205 if (range) {
206 const inRange = all.filter(d => d.range.intersection(range) !== undefined);
207 diags = inRange.length > 0 ? inRange : diags;
208 }
209 if (diags.length === 0) return { text: '', count: 0 };
210 const lines = diags.slice(0, 50).map(d => {
211 const L = d.range.start.line + 1;
212 const C = d.range.start.character + 1;
213 const code = typeof d.code === 'object' && d.code ? (d.code as any).value : d.code;
214 const src = d.source ? ` (${d.source}${code != null ? ' ' + code : ''})` : '';
215 return `- L${L}:${C} [${severityLabel(d.severity)}] ${d.message}${src}`;
216 });
217 const more = diags.length > 50 ? `\n…and ${diags.length - 50} more` : '';
218 return { text: lines.join('\n') + more, count: diags.length };
219}
220
221/** Save the document (if open + dirty) so the agent reads current contents from disk. */
222async function saveIfOpen(uri: vscode.Uri): Promise<void> {

Callers 2

fixDiagnosticsFunction · 0.85
explainDiagnosticFunction · 0.85

Calls 1

severityLabelFunction · 0.85

Tested by

no test coverage detected