pub struct DocumentTracker { /* private fields */ }Expand description
Tracks document state across the workspace.
Implementations§
Source§impl DocumentTracker
impl DocumentTracker
Sourcepub fn with_limits(limits: ResourceLimits) -> Self
pub fn with_limits(limits: ResourceLimits) -> Self
Create a new document tracker with custom limits.
Sourcepub fn get(&self, path: &Path) -> Option<&DocumentState>
pub fn get(&self, path: &Path) -> Option<&DocumentState>
Get the state of an open document.
Sourcepub fn open(&mut self, path: PathBuf, content: String) -> Result<Uri>
pub fn open(&mut self, path: PathBuf, content: String) -> Result<Uri>
Open a document and track its state.
Returns the document URI for use in LSP requests.
§Errors
Returns an error if:
- Document limit is exceeded
- File size limit is exceeded
Sourcepub fn update(&mut self, path: &Path, content: String) -> Option<i32>
pub fn update(&mut self, path: &Path, content: String) -> Option<i32>
Update a document’s content and increment its version.
Returns None if the document is not open.
Sourcepub fn close(&mut self, path: &Path) -> Option<DocumentState>
pub fn close(&mut self, path: &Path) -> Option<DocumentState>
Close a document and remove it from tracking.
Returns the document state if it was open.
Sourcepub fn close_all(&mut self) -> Vec<DocumentState>
pub fn close_all(&mut self) -> Vec<DocumentState>
Close all documents.
Sourcepub async fn ensure_open(
&mut self,
path: &Path,
lsp_client: &LspClient,
) -> Result<Uri>
pub async fn ensure_open( &mut self, path: &Path, lsp_client: &LspClient, ) -> Result<Uri>
Ensure a document is open, opening it lazily if necessary.
If the document is already open, returns its URI immediately.
Otherwise, reads the file from disk, opens it in the tracker,
and sends a didOpen notification to the LSP server.
§Errors
Returns an error if:
- The file cannot be read from disk
- The
didOpennotification fails to send - Resource limits are exceeded
Trait Implementations§
Source§impl Debug for DocumentTracker
impl Debug for DocumentTracker
Auto Trait Implementations§
impl Freeze for DocumentTracker
impl !RefUnwindSafe for DocumentTracker
impl Send for DocumentTracker
impl Sync for DocumentTracker
impl Unpin for DocumentTracker
impl UnwindSafe for DocumentTracker
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
Mutably borrows from an owned value. Read more