Struct yak_sitter::Tree
source · pub struct Tree<Custom = ()> {
pub custom: Custom,
/* private fields */
}
Expand description
Wrapper around tree_sitter::Tree which stores its text, filepath, and extra data that is accessible from any node. It also uses and is used by [tree_sitter_wrapper] wrapper classes.
Fields§
§custom: Custom
Custom data which you can access behind a shared reference from any Node
Implementations§
source§impl<Custom> Tree<Custom>
impl<Custom> Tree<Custom>
sourcepub fn text(&self) -> &str
pub fn text(&self) -> &str
Get the underlying text. This includes text which isn’t in the Self::included_ranges.
sourcepub fn path(&self) -> Option<&Path>
pub fn path(&self) -> Option<&Path>
Get the path the tree is associated with, if any.
The path may be virtual, it’s used for stable node comparison between trees.
sourcepub fn walk(&self) -> TreeCursor<'_, Custom>
pub fn walk(&self) -> TreeCursor<'_, Custom>
Create a TreeCursor starting at the root node.
sourcepub fn included_ranges(&self) -> Vec<Range>
pub fn included_ranges(&self) -> Vec<Range>
Get the included ranges used to parse the tree.
sourcepub fn changed_ranges(
&self,
other: &Tree
) -> impl ExactSizeIterator<Item = Range>
pub fn changed_ranges( &self, other: &Tree ) -> impl ExactSizeIterator<Item = Range>
Get the changed ranges. See tree_sitter::Tree::changed_ranges
sourcepub fn language(&self) -> LanguageRef<'_>
pub fn language(&self) -> LanguageRef<'_>
Get the language used to parse the tree.
sourcepub fn print_dot_graph(&self, file: &impl AsRawFd)
pub fn print_dot_graph(&self, file: &impl AsRawFd)
Print a dot graph of the tree to the given file. See tree_sitter::Tree::print_dot_graph
sourcepub fn edit(&mut self, edit: &InputEdit)
pub fn edit(&mut self, edit: &InputEdit)
Edit the tree. See tree_sitter::Tree::edit