pub struct NotificationCache { /* private fields */ }Expand description
Cache for LSP server notifications.
Implementations§
Source§impl NotificationCache
impl NotificationCache
Sourcepub fn indexing_state(&self, server_id: &ServerId) -> IndexingState
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.
Sourcepub fn diagnostics(&self, uri: &Uri) -> Option<DiagnosticInfo>
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.
Sourcepub fn diagnostic_sources(&self, uri: &Uri) -> DiagnosticSources
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());Sourcepub fn has_diagnostics(&self, uri: &Uri) -> bool
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));Sourcepub fn availability(
&self,
uri: &Uri,
route: Option<&ServerId>,
) -> DiagnosticsAvailability
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);Sourcepub fn diagnostics_owner(&self, uri: &Uri) -> Option<&ServerId>
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.
Sourcepub const fn messages(&self) -> &VecDeque<ServerMessage>
pub const fn messages(&self) -> &VecDeque<ServerMessage>
All stored server messages.