MCPcopy Create free account
hub / github.com/codeaashu/claude-code / ensureServerStarted

Function ensureServerStarted

src/services/lsp/LSPServerManager.ts:215–236  ·  view source on GitHub ↗

* Ensure the appropriate LSP server is started for the given file. * Returns undefined if no server handles this file type. * * @throws {Error} If server fails to start

(
    filePath: string,
  )

Source from the content-addressed store, hash-verified

213 * @throws {Error} If server fails to start
214 */
215 async function ensureServerStarted(
216 filePath: string,
217 ): Promise<LSPServerInstance | undefined> {
218 const server = getServerForFile(filePath)
219 if (!server) return undefined
220
221 if (server.state === 'stopped' || server.state === 'error') {
222 try {
223 await server.start()
224 } catch (error) {
225 const err = error as Error
226 logError(
227 new Error(
228 `Failed to start LSP server for file ${filePath}: ${err.message}`,
229 ),
230 )
231 throw error
232 }
233 }
234
235 return server
236 }
237
238 /**
239 * Send a request to the appropriate LSP server for the given file.

Callers 2

sendRequestFunction · 0.85
openFileFunction · 0.85

Calls 3

getServerForFileFunction · 0.85
logErrorFunction · 0.50
startMethod · 0.45

Tested by

no test coverage detected