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>

source

pub fn text(&self) -> &str

Get the underlying text. This includes text which isn’t in the Self::included_ranges.

source

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.

source

pub fn root_node(&self) -> Node<'_, Custom>

Get the root node.

source

pub fn walk(&self) -> TreeCursor<'_, Custom>

Create a TreeCursor starting at the root node.

source

pub fn included_ranges(&self) -> Vec<Range>

Get the included ranges used to parse the tree.

source

pub fn changed_ranges( &self, other: &Tree ) -> impl ExactSizeIterator<Item = Range>

Get the changed ranges. See tree_sitter::Tree::changed_ranges

source

pub fn language(&self) -> LanguageRef<'_>

Get the language used to parse the tree.

source

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

source

pub fn edit(&mut self, edit: &InputEdit)

Edit the tree. See tree_sitter::Tree::edit

Trait Implementations§

source§

impl<Custom: Debug> Debug for Tree<Custom>

source§

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

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

impl<'tree, Custom> TextProvider<&'tree str> for &'tree Tree<Custom>

§

type I = Once<&'tree str>

source§

fn text(&mut self, node: Node<'_>) -> Self::I

Auto Trait Implementations§

§

impl<Custom> Freeze for Tree<Custom>
where Custom: Freeze,

§

impl<Custom> RefUnwindSafe for Tree<Custom>
where Custom: RefUnwindSafe,

§

impl<Custom> Send for Tree<Custom>
where Custom: Send,

§

impl<Custom> Sync for Tree<Custom>
where Custom: Sync,

§

impl<Custom> Unpin for Tree<Custom>
where Custom: Unpin,

§

impl<Custom> UnwindSafe for Tree<Custom>
where Custom: UnwindSafe,

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.