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
impl SyntaxDocument
Sourcepub fn parse(
source_id: SourceId,
source: impl Into<Arc<str>>,
) -> Result<SyntaxParse, SyntaxParseError>
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.
Sourcepub const fn source_id(&self) -> SourceId
pub const fn source_id(&self) -> SourceId
Returns the source identifier supplied by the caller.
Sourcepub fn source_text(&self) -> &str
pub fn source_text(&self) -> &str
Returns the original source text.
Sourcepub fn source_span(&self) -> SourceSpan
pub fn source_span(&self) -> SourceSpan
Returns the span covering the complete source text.
Sourcepub fn text(&self, span: SourceSpan) -> Option<&str>
pub fn text(&self, span: SourceSpan) -> Option<&str>
Returns the source text covered by a span from this document.
Sourcepub fn line_column(&self, byte_offset: usize) -> Option<LineColumn>
pub fn line_column(&self, byte_offset: usize) -> Option<LineColumn>
Converts a byte offset in this document to a one-based line and column.
Sourcepub fn document_count(&self) -> usize
pub fn document_count(&self) -> usize
Returns the number of YAML documents in the stream.
Sourcepub fn comment_count(&self) -> usize
pub fn comment_count(&self) -> usize
Returns the number of comment tokens retained by the concrete syntax tree.
Sourcepub fn render_preserved(&self) -> String
pub fn render_preserved(&self) -> String
Renders the concrete syntax tree without semantic changes.
Trait Implementations§
Source§impl Clone for SyntaxDocument
impl Clone for SyntaxDocument
Source§fn clone(&self) -> SyntaxDocument
fn clone(&self) -> SyntaxDocument
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more