pub struct DocumentStore { /* private fields */ }Expand description
Tracks document state for LSP synchronization.
LSP requires:
- didOpen before didChange (document must be opened first)
- Version numbers must be monotonically increasing
- Full content sent with each change (TextDocumentSyncKind::Full)
This store ALSO records (mtime, size) at sync time so callers can detect
disk drift via is_stale_on_disk() and resync stale entries before
issuing pull-diagnostic requests against potentially stale server state.
Implementations§
Source§impl DocumentStore
impl DocumentStore
pub fn new() -> Self
Sourcepub fn open(&mut self, path: PathBuf) -> i32
pub fn open(&mut self, path: PathBuf) -> i32
Open a new document, recording the current on-disk metadata. Returns
the initial version (0). If the file’s metadata cannot be read, the
document is still tracked but mtime/size will be None, which
causes is_stale_on_disk() to conservatively report stale on the
next check (forcing a resync).
Sourcepub fn bump_version(&mut self, path: &Path) -> Option<i32>
pub fn bump_version(&mut self, path: &Path) -> Option<i32>
Bump the version for an already-open document and refresh the
recorded mtime/size from disk (the caller is presumed to be sending
a didChange with fresh content right after this call). Returns the
new version, or None if the document is not open.
Sourcepub fn entry(&self, path: &Path) -> Option<&DocumentEntry>
pub fn entry(&self, path: &Path) -> Option<&DocumentEntry>
Get the full document entry, or None if not open.
Sourcepub fn close(&mut self, path: &Path) -> Option<i32>
pub fn close(&mut self, path: &Path) -> Option<i32>
Close a document and remove from tracking. Returns the last known
version, or None if the document was not open.
Sourcepub fn open_documents(&self) -> Vec<&PathBuf>
pub fn open_documents(&self) -> Vec<&PathBuf>
Get all open document paths.
Sourcepub fn is_stale_on_disk(&self, path: &Path) -> bool
pub fn is_stale_on_disk(&self, path: &Path) -> bool
Returns true if the document is currently open AND its on-disk
metadata differs from what we recorded at the last sync. Use this
before issuing pull diagnostics to decide whether bump_version +
didChange is needed first.
Conservative semantics: returns true if the file used to have known metadata but cannot be read now (e.g. deleted or permission error), or if we never recorded metadata for the open entry.
Trait Implementations§
Source§impl Debug for DocumentStore
impl Debug for DocumentStore
Source§impl Default for DocumentStore
impl Default for DocumentStore
Source§fn default() -> DocumentStore
fn default() -> DocumentStore
Auto Trait Implementations§
impl Freeze for DocumentStore
impl RefUnwindSafe for DocumentStore
impl Send for DocumentStore
impl Sync for DocumentStore
impl Unpin for DocumentStore
impl UnsafeUnpin for DocumentStore
impl UnwindSafe for DocumentStore
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> 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