Skip to main content

Document

Struct Document 

Source
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

Source

pub fn new(uri: String, text: &str, pool: &ParserPool) -> Self

Create a new document by parsing the given source text.

Source

pub fn replace_full(&mut self, new_text: &str, pool: &ParserPool)

Apply a full-text replacement and re-parse.

Source

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.

Source

pub fn uri(&self) -> &str

Source

pub fn language(&self) -> Language

Source

pub fn tree(&self) -> Option<&Tree>

Source

pub fn injections(&self) -> &[InjectedRegion]

Get the injected PL/pgSQL regions (function bodies).

Source

pub fn text(&self) -> String

Get the full source text as a String.

Source

pub fn rope(&self) -> &Rope

Get the underlying rope.

Source

pub fn errors(&self) -> Vec<ParseError>

Collect all ERROR and MISSING nodes from the parse tree and injected regions.

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, 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.