MCPcopy
hub / github.com/codeaashu/claude-code / call

Function call

src/tools/LSPTool/LSPTool.ts:224–414  ·  view source on GitHub ↗
(input: Input, _context)

Source from the content-addressed store, hash-verified

222 renderToolUseErrorMessage,
223 renderToolResultMessage,
224 async call(input: Input, _context) {
225 const absolutePath = expandPath(input.filePath)
226 const cwd = getCwd()
227
228 // Wait for initialization if it's still pending
229 // This prevents returning "no server available" before init completes
230 const status = getInitializationStatus()
231 if (status.status === 'pending') {
232 await waitForInitialization()
233 }
234
235 // Get the LSP server manager
236 const manager = getLspServerManager()
237 if (!manager) {
238 // Log this system-level failure for tracking
239 logError(
240 new Error('LSP server manager not initialized when tool was called'),
241 )
242
243 const output: Output = {
244 operation: input.operation,
245 result:
246 'LSP server manager not initialized. This may indicate a startup issue.',
247 filePath: input.filePath,
248 }
249 return {
250 data: output,
251 }
252 }
253
254 // Map operation to LSP method and prepare params
255 const { method, params } = getMethodAndParams(input, absolutePath)
256
257 try {
258 // Ensure file is open in LSP server before making requests
259 // Most LSP servers require textDocument/didOpen before operations
260 // Only read the file if it's not already open to avoid unnecessary I/O
261 if (!manager.isFileOpen(absolutePath)) {
262 const handle = await open(absolutePath, 'r')
263 try {
264 const stats = await handle.stat()
265 if (stats.size > MAX_LSP_FILE_SIZE_BYTES) {
266 const output: Output = {
267 operation: input.operation,
268 result: `File too large for LSP analysis (${Math.ceil(stats.size / 1_000_000)}MB exceeds 10MB limit)`,
269 filePath: input.filePath,
270 }
271 return { data: output }
272 }
273 const fileContent = await handle.readFile({ encoding: 'utf-8' })
274 await manager.openFile(absolutePath, fileContent)
275 } finally {
276 await handle.close()
277 }
278 }
279
280 // Send request to LSP server
281 let result = await manager.sendRequest(absolutePath, method, params)

Callers

nothing calls this directly

Calls 15

expandPathFunction · 0.85
getCwdFunction · 0.85
getInitializationStatusFunction · 0.85
waitForInitializationFunction · 0.85
getLspServerManagerFunction · 0.85
getMethodAndParamsFunction · 0.85
openFunction · 0.85
logForDebuggingFunction · 0.85
toLocationFunction · 0.85
formatResultFunction · 0.85
toErrorFunction · 0.85

Tested by

no test coverage detected