pub struct Tree(/* private fields */);
Expand description
A tree that represents the syntactic structure of a source code file.
Implementations§
Source§impl Tree
impl Tree
Sourcepub fn root_node_with_offset(
&self,
offset_bytes: usize,
offset_extent: Point,
) -> Node<'_>
pub fn root_node_with_offset( &self, offset_bytes: usize, offset_extent: Point, ) -> Node<'_>
Get the root node of the syntax tree, but with its position shifted forward by the given offset.
Sourcepub fn language(&self) -> LanguageRef<'_>
pub fn language(&self) -> LanguageRef<'_>
Get the language that was used to parse the syntax tree.
Sourcepub fn edit(&mut self, edit: &InputEdit)
pub fn edit(&mut self, edit: &InputEdit)
Edit the syntax tree to keep it in sync with source code that has been edited.
You must describe the edit both in terms of byte offsets and in terms of row/column coordinates.
Sourcepub fn walk(&self) -> TreeCursor<'_>
pub fn walk(&self) -> TreeCursor<'_>
Create a new TreeCursor
starting from the root of the tree.
Sourcepub fn changed_ranges(
&self,
other: &Self,
) -> impl ExactSizeIterator<Item = Range>
pub fn changed_ranges( &self, other: &Self, ) -> impl ExactSizeIterator<Item = Range>
Compare this old edited syntax tree to a new syntax tree representing the same document, returning a sequence of ranges whose syntactic structure has changed.
For this to work correctly, this syntax tree must have been edited such
that its ranges match up to the new tree. Generally, you’ll want to
call this method right after calling one of the Parser::parse
functions. Call it on the old tree that was passed to parse, and
pass the new tree that was returned from parse
.
Sourcepub fn included_ranges(&self) -> Vec<Range>
pub fn included_ranges(&self) -> Vec<Range>
Get the included ranges that were used to parse the syntax tree.
Sourcepub fn print_dot_graph(&self, file: &impl AsRawFd)
pub fn print_dot_graph(&self, file: &impl AsRawFd)
Print a graph of the tree to the given file descriptor.
The graph is formatted in the DOT language. You may want to pipe this
graph directly to a dot(1)
process in order to generate SVG
output.
Trait Implementations§
impl Send for Tree
impl Sync for Tree
Auto Trait Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)