pub struct Document { /* private fields */ }Expand description
A parsed SQL or PL/pgSQL document with incremental edit support.
Maintains the source text, the primary parse tree, and any injected PL/pgSQL regions found within CREATE FUNCTION bodies.
Implementations§
Source§impl Document
impl Document
Sourcepub fn new(uri: String, text: &str, pool: &ParserPool) -> Self
pub fn new(uri: String, text: &str, pool: &ParserPool) -> Self
Create a new document by parsing the given source text.
Sourcepub fn replace_full(&mut self, new_text: &str, pool: &ParserPool)
pub fn replace_full(&mut self, new_text: &str, pool: &ParserPool)
Apply a full-text replacement and re-parse.
Sourcepub fn apply_edit(
&mut self,
start_line: usize,
start_col: usize,
end_line: usize,
end_col: usize,
new_text: &str,
pool: &ParserPool,
)
pub fn apply_edit( &mut self, start_line: usize, start_col: usize, end_line: usize, end_col: usize, new_text: &str, pool: &ParserPool, )
Apply an incremental edit (LSP-style line/col range) and re-parse.
start_line/start_col and end_line/end_col are 0-based.
new_text is the replacement text for the range.
pub fn uri(&self) -> &str
pub fn language(&self) -> Language
pub fn tree(&self) -> Option<&Tree>
Sourcepub fn injections(&self) -> &[InjectedRegion]
pub fn injections(&self) -> &[InjectedRegion]
Get the injected PL/pgSQL regions (function bodies).
Sourcepub fn end_position(&self) -> (usize, usize)
pub fn end_position(&self) -> (usize, usize)
Get the LSP position of the end of the document as a 0-based (line, utf16_col) pair.
Sourcepub fn errors(&self) -> Vec<ParseError>
pub fn errors(&self) -> Vec<ParseError>
Collect all ERROR and MISSING nodes from the parse tree and injected regions.
Auto Trait Implementations§
impl Freeze for Document
impl RefUnwindSafe for Document
impl Send for Document
impl Sync for Document
impl Unpin for Document
impl UnsafeUnpin for Document
impl UnwindSafe for Document
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