MCPcopy
hub / github.com/Doorman11991/smallcode / getDiagnostics

Method getDiagnostics

src/lsp/client.js:126–153  ·  view source on GitHub ↗
(filePath)

Source from the content-addressed store, hash-verified

124
125 // Get diagnostics for a file
126 async getDiagnostics(filePath) {
127 const uri = `file://${path.resolve(this.cwd, filePath).replace(/\\/g, '/')}`;
128
129 // Open the document to trigger diagnostics
130 const content = fs.readFileSync(path.resolve(this.cwd, filePath), 'utf-8');
131 this._notify('textDocument/didOpen', {
132 textDocument: { uri, languageId: this.serverInfo?.language || 'plaintext', version: 1, text: content },
133 });
134
135 // Wait for diagnostics (published via notification)
136 const diags = await new Promise((resolve) => {
137 const timeout = setTimeout(() => resolve(this.diagnostics.get(uri) || []), 5000);
138 const check = setInterval(() => {
139 const diags = this.diagnostics.get(uri);
140 if (diags && diags.length > 0) {
141 clearInterval(check);
142 clearTimeout(timeout);
143 resolve(diags);
144 }
145 }, 200);
146 });
147
148 // Close the document after reading diagnostics to prevent the language
149 // server from keeping it in memory indefinitely (Fix #20).
150 this._notify('textDocument/didClose', { textDocument: { uri } });
151
152 return diags;
153 }
154
155 // Format diagnostics as readable errors
156 formatDiagnostics(diagnostics) {

Callers

nothing calls this directly

Calls 2

_notifyMethod · 0.95
getMethod · 0.65

Tested by

no test coverage detected