MCPcopy Create free account
hub / github.com/freecodexyz/free-code / getServerForFile

Function getServerForFile

src/services/lsp/LSPServerManager.ts:192–207  ·  view source on GitHub ↗

* Get the LSP server instance for a given file path. * If multiple servers handle the same extension, returns the first registered server. * Returns undefined if no server handles this file type.

(filePath: string)

Source from the content-addressed store, hash-verified

190 * Returns undefined if no server handles this file type.
191 */
192 function getServerForFile(filePath: string): LSPServerInstance | undefined {
193 const ext = path.extname(filePath).toLowerCase()
194 const serverNames = extensionMap.get(ext)
195
196 if (!serverNames || serverNames.length === 0) {
197 return undefined
198 }
199
200 // Use first server (can add priority later)
201 const serverName = serverNames[0]
202 if (!serverName) {
203 return undefined
204 }
205
206 return servers.get(serverName)
207 }
208
209 /**
210 * Ensure the appropriate LSP server is started for the given file.

Callers 4

ensureServerStartedFunction · 0.85
changeFileFunction · 0.85
saveFileFunction · 0.85
closeFileFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected