Skip to main content

SyntaxDocument

Struct SyntaxDocument 

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

A loss-aware YAML document and its original source text.

The underlying concrete syntax tree is intentionally private so ComposeLens can maintain a stable API independently of its parser dependency. Rendering this initial representation emits the concrete syntax tree without normalization, interpolation, or environment access.

Implementations§

Source§

impl SyntaxDocument

Source

pub fn parse( source_id: SourceId, source: impl Into<Arc<str>>, ) -> Result<SyntaxParse, SyntaxParseError>

Parses YAML into a loss-aware document and structured diagnostics.

Recoverable YAML errors are returned in SyntaxParse::diagnostics while the syntax document remains available. Only sources too large for the concrete syntax tree produce a fatal error.

§Errors

Returns SyntaxParseError when the source exceeds the concrete syntax tree’s byte-offset capacity. Malformed YAML is recoverable and is reported through structured diagnostics.

Source

pub const fn source_id(&self) -> SourceId

Returns the source identifier supplied by the caller.

Source

pub fn source_text(&self) -> &str

Returns the original source text.

Source

pub fn source_span(&self) -> SourceSpan

Returns the span covering the complete source text.

Source

pub fn text(&self, span: SourceSpan) -> Option<&str>

Returns the source text covered by a span from this document.

Source

pub fn line_column(&self, byte_offset: usize) -> Option<LineColumn>

Converts a byte offset in this document to a one-based line and column.

Source

pub fn document_count(&self) -> usize

Returns the number of YAML documents in the stream.

Source

pub fn comment_count(&self) -> usize

Returns the number of comment tokens retained by the concrete syntax tree.

Source

pub fn render_preserved(&self) -> String

Renders the concrete syntax tree without semantic changes.

Trait Implementations§

Source§

impl Clone for SyntaxDocument

Source§

fn clone(&self) -> SyntaxDocument

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SyntaxDocument

Source§

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

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

impl Eq for SyntaxDocument

Source§

impl PartialEq for SyntaxDocument

Source§

fn eq(&self, other: &SyntaxDocument) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SyntaxDocument

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.