pub struct MarkdownTree { /* private fields */ }Expand description
Wraps a tree-sitter parser configured for markdown. Supports incremental re-parsing after edits.
Implementations§
Source§impl MarkdownTree
impl MarkdownTree
Sourcepub fn set_source(&mut self, source: &str)
pub fn set_source(&mut self, source: &str)
Replace the entire source and re-parse from scratch.
Sourcepub fn edit(
&mut self,
start_byte: usize,
old_end_byte: usize,
new_text: &str,
start_point: Point,
old_end_point: Point,
)
pub fn edit( &mut self, start_byte: usize, old_end_byte: usize, new_text: &str, start_point: Point, old_end_point: Point, )
Apply an edit and incrementally re-parse.
start_byte / old_end_byte / new_end_byte describe the edit in byte offsets.
Points describe the same edit in row/column coordinates.
§Panics
Panics if start_byte or old_end_byte are not on UTF-8 char boundaries.
Sourcepub fn sexp(&self) -> Option<String>
pub fn sexp(&self) -> Option<String>
Get the S-expression representation of the parse tree (for debugging).
Sourcepub fn walk_blocks<F>(&self, visitor: F)
pub fn walk_blocks<F>(&self, visitor: F)
Walk the top-level blocks of the document, calling the visitor for each.
Sourcepub fn block_at_byte(&self, byte_offset: usize) -> Option<BlockInfo>
pub fn block_at_byte(&self, byte_offset: usize) -> Option<BlockInfo>
Find the block node at the given byte offset.
Sourcepub fn node_at_byte(&self, byte_offset: usize) -> Option<NodeInfo>
pub fn node_at_byte(&self, byte_offset: usize) -> Option<NodeInfo>
Find the innermost node at the given byte offset.
Auto Trait Implementations§
impl Freeze for MarkdownTree
impl RefUnwindSafe for MarkdownTree
impl Send for MarkdownTree
impl Sync for MarkdownTree
impl Unpin for MarkdownTree
impl UnsafeUnpin for MarkdownTree
impl UnwindSafe for MarkdownTree
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