Class LanguageServerManager
-
- All Implemented Interfaces:
-
java.lang.AutoCloseable
public final class LanguageServerManager implements AutoCloseable
Lightweight, dependency-free LSP (Language Server Protocol) client.
Talks JSON-RPC 2.0 over stdio to a per-language server process (tsserver, pyright-langserver, rust-analyzer, ...), implementing just the methods needed for the coding domain's
diagnostics/symbols/referencestools — no lsp4j, no external JSON-RPC library.Servers are started lazily per language (first request wins), kept alive for reuse (incremental diagnostics), and reaped after IDLE_TIMEOUT_MS without requests to bound memory. A crashed server is restarted on the next request.
Only servers on the approved serverCommands allow-list can be launched; the agent can never supply an arbitrary executable. Servers only ever receive file contents (didOpen) and return structured data — they never execute project code.
Each server gets a dedicated coroutine reading stdout (the server pushes notifications like
textDocument/publishDiagnosticsat any time) plus a pending-response map keyed by JSON-RPC id. All protocol IO is sequential per server via a single writer mutex.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classLanguageServerManager.DiagnosticA single structured diagnostic.
public final classLanguageServerManager.SymbolInfoA code symbol definition.
public final classLanguageServerManager.ReferenceInfoA reference to a symbol.
public classLanguageServerManager.Companion
-
Field Summary
Fields Modifier and Type Field Description public final static LongIDLE_TIMEOUT_MSpublic final static LanguageServerManager.CompanionCompanion
-
Method Summary
Modifier and Type Method Description final List<LanguageServerManager.Diagnostic>diagnostics(String path)Get diagnostics for a file, starting a server for its language on demand. final List<LanguageServerManager.SymbolInfo>symbols(String pattern)Search for symbol definitions matching pattern (substring match on name). final List<LanguageServerManager.ReferenceInfo>references(String path, String symbol)Find references to symbol (exact name) in the given path. final Map<String, Boolean>availableServers()List which language servers are available (installed on PATH). Unitclose()Shut down all running servers. -
-
Method Detail
-
diagnostics
final List<LanguageServerManager.Diagnostic> diagnostics(String path)
Get diagnostics for a file, starting a server for its language on demand. Returns an empty list (with a message) when the language is unsupported or the server is unavailable — never throws.
-
symbols
final List<LanguageServerManager.SymbolInfo> symbols(String pattern)
Search for symbol definitions matching pattern (substring match on name). Uses workspace/symbol when available; falls back to documentSymbol per open document (best effort).
-
references
final List<LanguageServerManager.ReferenceInfo> references(String path, String symbol)
Find references to symbol (exact name) in the given path. Opens the file then issues textDocument/references.
-
availableServers
final Map<String, Boolean> availableServers()
List which language servers are available (installed on PATH).
-
-
-
-