pub struct DiagnosticsStore { /* private fields */ }Expand description
Stores diagnostics from all LSP servers, keyed per (ServerKey, file).
Key design points (driven by the v0.16 LSP audit):
-
Per-server state. A single file can be served by multiple LSP servers (e.g., pyright + ty, or tsserver + ESLint). The cache key is
(ServerKey, PathBuf)so each server’s view is tracked independently. -
Empty publishes are kept. Earlier the store deleted entries on empty publishes, making “checked clean” indistinguishable from “never checked”. Now we preserve the entry with
epoch = ...so callers can answer the question honestly. -
LRU cap.
capacity(default 5000, configurable viaConfig::diagnostic_cache_size) bounds memory. Set to 0 to disable. On insert when at capacity, the least-recently-touched entry is evicted. Eviction is tracked so directory-mode callers can list those files asuncheckedrather than silently lose them.
Implementations§
Source§impl DiagnosticsStore
impl DiagnosticsStore
pub fn new() -> Self
pub fn with_capacity(capacity: usize) -> Self
Sourcepub fn set_capacity(&mut self, capacity: usize)
pub fn set_capacity(&mut self, capacity: usize)
Set or change the LRU cap. If the new cap is smaller than the current entry count, the oldest entries are evicted immediately to fit.
pub fn is_empty(&self) -> bool
Sourcepub fn publish(
&mut self,
server: ServerKey,
file: PathBuf,
diagnostics: Vec<StoredDiagnostic>,
)
pub fn publish( &mut self, server: ServerKey, file: PathBuf, diagnostics: Vec<StoredDiagnostic>, )
Replace diagnostics for a (server_kind, file) pair using the
server’s lifecycle root from the active manager. Empty diagnostics
are preserved as “checked clean” (NOT deleted as before).
Note: the (server, file) key uses ServerKey { kind, root } so
concurrent multi-workspace usage doesn’t collapse different roots.
Callers without the root (legacy push handler) should call
publish_with_kind which derives the key.
Sourcepub fn publish_with_result_id(
&mut self,
server: ServerKey,
file: PathBuf,
diagnostics: Vec<StoredDiagnostic>,
result_id: Option<String>,
)
pub fn publish_with_result_id( &mut self, server: ServerKey, file: PathBuf, diagnostics: Vec<StoredDiagnostic>, result_id: Option<String>, )
Replace diagnostics and record a pull resultId for the next
request. Empty diagnostics are preserved as “checked clean”.
Sourcepub fn publish_full(
&mut self,
server: ServerKey,
file: PathBuf,
diagnostics: Vec<StoredDiagnostic>,
result_id: Option<String>,
version: Option<i32>,
)
pub fn publish_full( &mut self, server: ServerKey, file: PathBuf, diagnostics: Vec<StoredDiagnostic>, result_id: Option<String>, version: Option<i32>, )
Replace diagnostics with full provenance (resultId + document version).
version should be the LSP version field from publishDiagnostics
when the server provided one, or None otherwise.
Sourcepub fn publish_with_kind(
&mut self,
kind: ServerKind,
file: PathBuf,
diagnostics: Vec<StoredDiagnostic>,
)
pub fn publish_with_kind( &mut self, kind: ServerKind, file: PathBuf, diagnostics: Vec<StoredDiagnostic>, )
Compatibility wrapper for the legacy push path that knows only the
ServerKind. Builds a ServerKey with an empty root, which is
adequate for the single-root-per-kind case the manager currently
uses for push diagnostics. Multi-root callers should use
publish directly with a real ServerKey.
Sourcepub fn for_file(&self, file: &Path) -> Vec<&StoredDiagnostic>
pub fn for_file(&self, file: &Path) -> Vec<&StoredDiagnostic>
Get all diagnostics for a specific file (across all servers). Updates LRU position for each touched entry.
Sourcepub fn entries_for_file(
&self,
file: &Path,
) -> Vec<(&ServerKey, &DiagnosticEntry)>
pub fn entries_for_file( &self, file: &Path, ) -> Vec<(&ServerKey, &DiagnosticEntry)>
Get the full per-server entry for a file. Useful when callers need to know epoch/resultId, not just the diagnostics array.
Sourcepub fn has_any_report_for_file(&self, file: &Path) -> bool
pub fn has_any_report_for_file(&self, file: &Path) -> bool
True if any server has reported (even an empty result) for this file.
Sourcepub fn has_report_for_server_file(
&self,
server: &ServerKey,
file: &Path,
) -> bool
pub fn has_report_for_server_file( &self, server: &ServerKey, file: &Path, ) -> bool
True if this exact server instance has reported (even an empty result) for this exact file.
Sourcepub fn has_publish_for_file_after(
&self,
server: &ServerKey,
file: &Path,
since: Instant,
) -> bool
pub fn has_publish_for_file_after( &self, server: &ServerKey, file: &Path, since: Instant, ) -> bool
True if this exact server instance published/replaced diagnostics for
this exact file after since. This is intentionally per (kind, root, file); a publish for another file must not prove freshness here.
Sourcepub fn for_directory(&self, dir: &Path) -> Vec<&StoredDiagnostic>
pub fn for_directory(&self, dir: &Path) -> Vec<&StoredDiagnostic>
Get all diagnostics for files under a directory.
Sourcepub fn all(&self) -> Vec<&StoredDiagnostic>
pub fn all(&self) -> Vec<&StoredDiagnostic>
All stored diagnostics, flattened.
Sourcepub fn error_warning_counts(&self) -> (usize, usize)
pub fn error_warning_counts(&self) -> (usize, usize)
Count of errors and warnings across the entire warm set (every file any server has published for). Allocation-free — used to refresh the agent status bar on each request drain without materializing a Vec.
Sourcepub fn clear_server(&mut self, server: ServerKind)
pub fn clear_server(&mut self, server: ServerKind)
Drop all entries for a server kind (e.g., on server crash/restart).
Prefer clear_for_server for real manager cleanup so peer roots of the
same kind are not wiped.
Sourcepub fn clear_for_server_file(&mut self, key: &ServerKey, file: &Path)
pub fn clear_for_server_file(&mut self, key: &ServerKey, file: &Path)
Drop one cached report for a specific server/file pair.
Sourcepub fn clear_for_file(&mut self, file: &Path) -> bool
pub fn clear_for_file(&mut self, file: &Path) -> bool
Drop every cached report for a file across all servers. Used when a file
is deleted/renamed away — its diagnostics would otherwise linger in the
warm set forever (no server republishes for a path that no longer
exists), inflating the error/warning counts surfaced in the status bar
and aft_inspect. Returns true if any entry was removed.
Sourcepub fn clear_for_server(&mut self, key: &ServerKey)
pub fn clear_for_server(&mut self, key: &ServerKey)
Drop all entries for a specific server instance.
Sourcepub fn clear_server_instance(&mut self, key: &ServerKey)
pub fn clear_server_instance(&mut self, key: &ServerKey)
Backward-compatible alias for tests/callers that already used the instance-scoped name.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DiagnosticsStore
impl RefUnwindSafe for DiagnosticsStore
impl Send for DiagnosticsStore
impl Sync for DiagnosticsStore
impl Unpin for DiagnosticsStore
impl UnsafeUnpin for DiagnosticsStore
impl UnwindSafe for DiagnosticsStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more