pub struct MarkdownCursor<'a> { /* private fields */ }
Expand description

A stateful object for walking a MarkdownTree efficiently.

This exposes the same methdos as TreeCursor, but abstracts away the double block / inline structure of MarkdownTree.

Implementations§

source§

impl<'a> MarkdownCursor<'a>

source

pub fn node(&self) -> Node<'a>

Get the cursor’s current Node.

source

pub fn is_inline(&self) -> bool

Returns true if the current node is from the (inline language)inline_language

This information is needed to handle “tree-sitter internal” data like field_id correctly.

source

pub fn field_id(&self) -> Option<NonZeroU16>

Get the numerical field id of this tree cursor’s current node.

You will need to call is_inline to find out if the current node is an inline or block node.

See also field_name.

source

pub fn field_name(&self) -> Option<&'static str>

Get the field name of this tree cursor’s current node.

You will need to call is_inline to find out if the current node is an inline or block node.

source

pub fn goto_first_child(&mut self) -> bool

Move this cursor to the first child of its current node.

This returns true if the cursor successfully moved, and returns false if there were no children. If the cursor is currently at a node in the block tree and it has an associated inline tree, it will descend into the inline tree.

source

pub fn goto_parent(&mut self) -> bool

Move this cursor to the parent of its current node.

This returns true if the cursor successfully moved, and returns false if there was no parent node (the cursor was already on the root node). If the cursor moves to the root node of an inline tree, the it ascents to the associated node in the block tree.

source

pub fn goto_next_sibling(&mut self) -> bool

Move this cursor to the next sibling of its current node.

This returns true if the cursor successfully moved, and returns false if there was no next sibling node.

source

pub fn goto_first_child_for_byte(&mut self, index: usize) -> Option<usize>

Move this cursor to the first child of its current node that extends beyond the given byte offset.

This returns the index of the child node if one was found, and returns None if no such child was found. If the cursor is currently at a node in the block tree and it has an associated inline tree, it will descend into the inline tree.

source

pub fn goto_first_child_for_point(&mut self, index: Point) -> Option<usize>

Move this cursor to the first child of its current node that extends beyond the given point.

This returns the index of the child node if one was found, and returns None if no such child was found. If the cursor is currently at a node in the block tree and it has an associated inline tree, it will descend into the inline tree.

Auto Trait Implementations§

§

impl<'a> Freeze for MarkdownCursor<'a>

§

impl<'a> RefUnwindSafe for MarkdownCursor<'a>

§

impl<'a> Send for MarkdownCursor<'a>

§

impl<'a> Sync for MarkdownCursor<'a>

§

impl<'a> Unpin for MarkdownCursor<'a>

§

impl<'a> UnwindSafe for MarkdownCursor<'a>

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.