Tree

Struct Tree 

Source
#[repr(transparent)]
pub struct Tree<Root>(pub Tree, _) where Root: Node<'static>;

Tuple Fields§

§0: Tree

Implementations§

Source§

impl<Root> Tree<Root>
where Root: Node<'static>,

Source

pub fn wrap(tree: Tree) -> Tree<Root>

Convert a tree-sitter tree into a typed tree by specifying the correct root node type.

This will succeed even if Root is not the language’s root node, because root_node checks that the root node is the correct type.

Source

pub fn wrap_ref(tree: &Tree) -> &Tree<Root>

Version of wrap for an immutable reference.

Source

pub fn wrap_mut(tree: &mut Tree) -> &mut Tree<Root>

Version of wrap for a mutable reference.

Source

pub fn root_node( &self, ) -> Result<<Root as Node<'static>>::WithLifetime<'_>, IncorrectKind<'_>>

Get the root node of this tree.

Returns Err if the root is the wrong type, which may happen even if the language is correct if the entire tree is an error node.

Source

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

Create a cursor 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<Root>) -> impl ExactSizeIterator

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<Root> Clone for Tree<Root>
where Root: Clone + Node<'static>,

Source§

fn clone(&self) -> Tree<Root>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Root> Debug for Tree<Root>
where Root: Debug + Node<'static>,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Root> Freeze for Tree<Root>

§

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

§

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

§

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

§

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

§

impl<Root> UnwindSafe for Tree<Root>
where Root: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

Source§

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.