Skip to main content

DocumentStore

Struct DocumentStore 

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

Tracks document state for LSP synchronization.

LSP requires:

  1. didOpen before didChange (document must be opened first)
  2. Version numbers must be monotonically increasing
  3. 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

Source

pub fn new() -> Self

Source

pub fn is_open(&self, path: &Path) -> bool

Check if a document is already opened (tracked).

Source

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

Source

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.

Source

pub fn version(&self, path: &Path) -> Option<i32>

Get current version, or None if not open.

Source

pub fn entry(&self, path: &Path) -> Option<&DocumentEntry>

Get the full document entry, or None if not open.

Source

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.

Source

pub fn open_documents(&self) -> Vec<&PathBuf>

Get all open document paths.

Source

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

Source§

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

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

impl Default for DocumentStore

Source§

fn default() -> DocumentStore

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