pub struct LspManager { /* private fields */ }Expand description
Session-scoped registry of configured language servers and the live
connections spawned so far — the crate::tools::WriteObserver this
module installs (LspDiagnosticsObserver) is a thin wrapper around a
shared Arc<LspManager>; crate::agent::build_tool_context keeps its
own Arc clone too, so crate::Agent’s Drop impl can reach
Self::kill_all_sync regardless of how many observer clones exist.
Implementations§
Source§impl LspManager
impl LspManager
Sourcepub fn new(
root: PathBuf,
specs: Vec<(String, LspServerSpec)>,
timeout: Duration,
max_diagnostics: usize,
) -> Self
pub fn new( root: PathBuf, specs: Vec<(String, LspServerSpec)>, timeout: Duration, max_diagnostics: usize, ) -> Self
Build a manager over specs (name -> server definition), rooted at
root (used as the LSP rootUri and the containment floor every
touched path is checked against via crate::safe_path::contained).
Sourcepub async fn diagnostics_after_write(&self, path: &Path) -> Option<String>
pub async fn diagnostics_after_write(&self, path: &Path) -> Option<String>
D1: the write-path diagnostics hook — spawns (or reuses) the
configured server for path’s extension, if any, sends
didOpen/didChange with the file’s CURRENT on-disk content (the
caller — LspDiagnosticsObserver::after_write — only calls this
once the write has completed, so this always reads the FINAL bytes,
which for [capabilities.formatters] also on means the FORMATTED
content, not the model’s pre-format draft — see the observer
ordering crate::agent::build_tool_context installs), and waits
(bounded by self.timeout) for that file’s diagnostics. Never
fails the caller: every error (no configured server, spawn
failure, protocol error, timeout) degrades to None, logged once
via tracing::warn!.
Sourcepub fn kill_all_sync(&self)
pub fn kill_all_sync(&self)
Real, synchronous, provable kill of every server this manager has
spawned so far — called from impl Drop for crate::Agent (a
non-async context, hence the sync signature). A no-op for any
server already exited.
Sourcepub async fn shutdown_all(&self)
pub async fn shutdown_all(&self)
Graceful async shutdown of every server this manager has spawned —
shutdown/exit handshake per server, kill_all_sync-equivalent
backstop applied per-client by LspClient::shutdown itself. Use
this on a clean-exit path that can afford to .await; use
Self::kill_all_sync from Drop.
Sourcepub fn running_server_count(&self) -> usize
pub fn running_server_count(&self) -> usize
Test/observability hook: how many servers are currently live.