Skip to main content

NotificationCache

Struct NotificationCache 

Source
pub struct NotificationCache { /* private fields */ }
Expand description

Cache for LSP server notifications.

Implementations§

Source§

impl NotificationCache

Source

pub fn new() -> Self

Create a new notification cache.

Source

pub fn indexing_state(&self, server_id: &ServerId) -> IndexingState

Current tracked workspace-indexing readiness for server_id.

Returns IndexingState::Unknown for a server no readiness signal has ever been observed for – see Self::observe_indexing_signal.

A Loading entry older than INDEXING_STALENESS_BOUND is read back as Unknown rather than Loading: this is the self-heal for a quiescent: true notification dropped by a full channel, or a server that stalled mid-index, applied at read time based on the signal’s own age so it can never be triggered by (and can never affect) any individual caller’s own wait – see Translator::wait_for_indexing_ready.

Source

pub fn diagnostics(&self, uri: &Uri) -> Option<DiagnosticInfo>

Get diagnostics for a document URI.

If the stored list was ever truncated by store_published_diagnostics’s MAX_DIAGNOSTICS_ENTRY_BYTES cap (#311), the diagnostics here are in severity order (ERROR first), not the original publish/file-position order – callers that assume file-position order should not rely on it after a cap-triggered truncation.

Looks up the pushed entry stored under exactly uri. A file reachable through symlinks may have its diagnostics spread over several published URIs, and a pull may have stored its own list next to them; use Self::diagnostic_sources to read the union.

Source

pub fn diagnostic_sources(&self, uri: &Uri) -> DiagnosticSources

Snapshot of every entry cached for the file uri names, to be merged after the cache lock is released.

Clones the entries (at most 8 pushed and 1 pulled, each bounded to 1 MiB) so the merge can run without the lock.

§Examples
use lsp_types::Uri;
use mcpls_core::bridge::NotificationCache;

let cache = NotificationCache::new();
let uri = Uri::from("file:///workspace/main.rs".to_owned());
let snapshot = cache.diagnostic_sources(&uri);
// Merge once the cache lock has been released.
assert!(snapshot.merge().is_none());
Source

pub fn has_diagnostics(&self, uri: &Uri) -> bool

Whether any diagnostics entry (possibly empty) is cached for the file uri names, under any of its published URIs.

§Examples
use lsp_types::Uri;
use mcpls_core::bridge::NotificationCache;

let cache = NotificationCache::new();
let uri = Uri::from("file:///workspace/main.rs".to_owned());
assert!(!cache.has_diagnostics(&uri));
Source

pub fn availability( &self, uri: &Uri, route: Option<&ServerId>, ) -> DiagnosticsAvailability

Whether the cache has an answer for the file uri names, read for the diagnostics server route.

An entry, or the memory that capacity eviction removed only clean entries of the file, is DiagnosticsAvailability::Published. Lost diagnostics, or no trace of the file although eviction forgot some of route’s files, is DiagnosticsAvailability::Evicted. Anything else is DiagnosticsAvailability::Pending: nothing was published since the server started.

§Examples
use lsp_types::Uri;
use mcpls_core::bridge::{DiagnosticsAvailability, NotificationCache};

let cache = NotificationCache::new();
let uri = Uri::from("file:///workspace/main.rs".to_owned());
assert_eq!(cache.availability(&uri, None), DiagnosticsAvailability::Pending);
Source

pub fn diagnostics_owner(&self, uri: &Uri) -> Option<&ServerId>

Server that published the currently cached diagnostics for uri, if any. Used to look up that server’s negotiated position encoding for a cache-only read that has no live LSP round trip of its own to resolve one from.

Source

pub const fn logs(&self) -> &VecDeque<LogEntry>

All stored log entries.

Source

pub const fn messages(&self) -> &VecDeque<ServerMessage>

All stored server messages.

Trait Implementations§

Source§

impl Debug for NotificationCache

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for NotificationCache

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<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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