Skip to main content

DiagnosticsStore

Struct DiagnosticsStore 

Source
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):

  1. 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.

  2. 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.

  3. LRU cap. capacity (default 5000, configurable via Config::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 as unchecked rather than silently lose them.

Implementations§

Source§

impl DiagnosticsStore

Source

pub fn new() -> Self

Source

pub fn with_capacity(capacity: usize) -> Self

Source

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.

Source

pub fn len(&self) -> usize

Number of currently-tracked entries.

Source

pub fn is_empty(&self) -> bool

Source

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.

Source

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”.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn has_any_report_for_file(&self, file: &Path) -> bool

True if any server has reported (even an empty result) for this file.

Source

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.

Source

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.

Source

pub fn for_directory(&self, dir: &Path) -> Vec<&StoredDiagnostic>

Get all diagnostics for files under a directory.

Source

pub fn all(&self) -> Vec<&StoredDiagnostic>

All stored diagnostics, flattened.

Source

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.

Source

pub fn clear_for_server(&mut self, key: &ServerKey)

Drop all entries for a specific server instance.

Source

pub fn clear_server_instance(&mut self, key: &ServerKey)

Backward-compatible alias for tests/callers that already used the instance-scoped name.

Trait Implementations§

Source§

impl Default for DiagnosticsStore

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more