/** * LSP Client Wrapper * * Provides TypeScript wrapper for Language Server Protocol operations. * Supports semantic code understanding (goToDefinition, findReferences, etc.) * * @module core/lsp/lsp-client */ export interface LSPPosition { line: number; character: number; } export interface LSPLocation { uri: string; range: { start: LSPPosition; end: LSPPosition; }; } export interface LSPDefinitionResult { location: LSPLocation; success: boolean; } export interface LSPReferencesResult { locations: LSPLocation[]; success: boolean; } export interface LSPHoverResult { contents: string; range?: { start: LSPPosition; end: LSPPosition; }; success: boolean; } export interface LSPSymbolInformation { name: string; kind: number; location: LSPLocation; containerName?: string; } export interface LSPDocumentSymbolsResult { symbols: LSPSymbolInformation[]; success: boolean; } export interface LSPWorkspaceSymbolsResult { symbols: LSPSymbolInformation[]; success: boolean; } export interface LSPServerConfig { command: string; args: string[]; rootPath: string; /** Request timeout in milliseconds (default: 60000) */ timeoutMs?: number; } /** * LSP Client for semantic code analysis */ export declare class LSPClient { private serverProcess; private requestId; private config; private initialized; private responseHandlers; private buffer; /** Track opened documents to avoid redundant didOpen + 500ms delays */ private openedDocuments; /** Track if workspace has been indexed (first query triggers this) */ private workspaceIndexed; /** Request timeout in milliseconds */ private readonly timeoutMs; constructor(config: LSPServerConfig); /** * Initialize the LSP server */ initialize(): Promise; /** * Warm up the LSP server by triggering workspace indexing * This prevents the first real query from timing out * v1.0.197: Added for session-start warm-up */ warmup(entryFiles?: string[]): Promise; /** * Find default entry files for warm-up when none specified * Searches common patterns and falls back to recursive search */ private findDefaultEntryFiles; /** * Check if workspace has been indexed */ isWarmedUp(): boolean; /** * Handle messages from LSP server */ private handleServerMessage; /** * Handle parsed LSP message * * Handles three message types: * 1. Responses to our requests (has id matching our responseHandlers) * 2. Server-initiated requests (has method + id, needs response) * 3. Server-initiated notifications (has method, no id) * * Missing server-request handling was causing C#, Python, Java servers * to hang or return empty results (same as Claude Code issue #16360). */ private handleMessage; /** * Handle server-initiated requests that require a response. * * Many LSP servers (csharp-ls, pyright, jdtls) send requests during * initialization that MUST be answered or the server hangs/crashes: * - workspace/configuration: Server asks for settings * - client/registerCapability: Dynamic capability registration * - window/workDoneProgress/create: Progress token registration * - window/showMessageRequest: User-facing message with actions */ private handleServerRequest; /** * Send a response to a server-initiated request */ private sendResponse; /** Track timeouts so we can clear them on response */ private timeouts; /** * Send request to LSP server */ private sendRequest; /** * Send shutdown request per LSP spec (shutdown is a request, not notification). * Uses a dedicated method to bypass the normal timeout handling since * we've already cleared timeouts during shutdown. */ private sendShutdownRequest; /** * Send notification to LSP server (no response expected) */ private sendNotification; /** * Go to definition for a symbol at given position */ goToDefinition(filePath: string, line: number, character: number): Promise; /** * Find all references to a symbol at given position */ findReferences(filePath: string, line: number, character: number): Promise; /** * Get hover information for a symbol at given position */ hover(filePath: string, line: number, character: number): Promise; /** * Get all symbols in a document */ documentSymbols(filePath: string): Promise; /** * Flatten hierarchical document symbols into flat list */ private flattenSymbols; /** * Search for symbols across workspace */ workspaceSymbols(query: string): Promise; /** * Open a document in the LSP server * Tracks already-opened documents to avoid redundant 500ms delays * v1.0.197: Performance fix - skip delay for already-open documents */ private openDocument; /** * Close a document in the LSP server * v1.0.197: Added to prevent memory leaks */ private closeDocument; /** * Get language ID for LSP */ private getLanguageId; /** * Shutdown and cleanup LSP server * v1.0.197: Now properly closes all open documents to prevent memory leaks */ shutdown(): Promise; } /** * Detect available LSP servers for a project * * Supports 10 languages: TypeScript, Python, Go, Rust, Java, C#, Kotlin, Swift, PHP, Ruby * For each language, tries multiple server implementations in priority order. */ export declare function detectLSPServers(projectRoot: string): Promise; //# sourceMappingURL=lsp-client.d.ts.map