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

Method _onData

src/lsp/client.js:187–205  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

185 }
186
187 _onData(data) {
188 this.buffer += data;
189 const { messages, remaining } = decodeMessages(this.buffer);
190 this.buffer = remaining;
191
192 for (const msg of messages) {
193 // Response to a request
194 if (msg.id && this.pending.has(msg.id)) {
195 const { resolve, reject } = this.pending.get(msg.id);
196 this.pending.delete(msg.id);
197 if (msg.error) reject(msg.error);
198 else resolve(msg.result);
199 }
200 // Notification (diagnostics)
201 if (msg.method === 'textDocument/publishDiagnostics') {
202 this.diagnostics.set(msg.params.uri, msg.params.diagnostics || []);
203 }
204 }
205 }
206}
207
208module.exports = { LSPClient, detectServer };

Callers 1

startMethod · 0.95

Calls 3

decodeMessagesFunction · 0.85
getMethod · 0.65
hasMethod · 0.45

Tested by

no test coverage detected