* Send a request to the appropriate LSP server for the given file. * Returns undefined if no server handles this file type. * * @throws {Error} If server fails to start or request fails
(
filePath: string,
method: string,
params: unknown,
)
| 242 | * @throws {Error} If server fails to start or request fails |
| 243 | */ |
| 244 | async function sendRequest<T>( |
| 245 | filePath: string, |
| 246 | method: string, |
| 247 | params: unknown, |
| 248 | ): Promise<T | undefined> { |
| 249 | const server = await ensureServerStarted(filePath) |
| 250 | if (!server) return undefined |
| 251 | |
| 252 | try { |
| 253 | return await server.sendRequest<T>(method, params) |
| 254 | } catch (error) { |
| 255 | const err = error as Error |
| 256 | logError( |
| 257 | new Error( |
| 258 | `LSP request failed for file ${filePath}, method '${method}': ${err.message}`, |
| 259 | ), |
| 260 | ) |
| 261 | throw error |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | // Return public interface |
| 266 | function getAllServers(): Map<string, LSPServerInstance> { |
nothing calls this directly
no test coverage detected