(data)
| 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 | |
| 208 | module.exports = { LSPClient, detectServer }; |
no test coverage detected