MCPcopy
hub / github.com/claude-code-best/claude-code / getServerForFile

Function getServerForFile

src/services/lsp/LSPServerManager.ts:194–209  ·  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

192 * Returns undefined if no server handles this file type.
193 */
194 function getServerForFile(filePath: string): LSPServerInstance | undefined {
195 const ext = path.extname(filePath).toLowerCase()
196 const serverNames = extensionMap.get(ext)
197
198 if (!serverNames || serverNames.length === 0) {
199 return undefined
200 }
201
202 // Use first server (can add priority later)
203 const serverName = serverNames[0]
204 if (!serverName) {
205 return undefined
206 }
207
208 return servers.get(serverName)
209 }
210
211 /**
212 * 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.65

Tested by

no test coverage detected