pub struct TreeCursor<'cursor>(/* private fields */);
Expand description
A stateful object for walking a syntax Tree
efficiently.
Implementations§
Source§impl<'a> TreeCursor<'a>
impl<'a> TreeCursor<'a>
Sourcepub const unsafe fn from_raw(raw: TSTreeCursor) -> Self
pub const unsafe fn from_raw(raw: TSTreeCursor) -> Self
Sourcepub fn into_raw(self) -> TSTreeCursor
pub fn into_raw(self) -> TSTreeCursor
Consumes the TreeCursor
, returning a raw pointer to the underlying C structure.
Source§impl<'cursor> TreeCursor<'cursor>
impl<'cursor> TreeCursor<'cursor>
Sourcepub fn field_id(&self) -> Option<NonZeroU16>
pub fn field_id(&self) -> Option<NonZeroU16>
Get the numerical field id of this tree cursor’s current node.
See also field_name
.
Sourcepub fn field_name(&self) -> Option<&'static str>
pub fn field_name(&self) -> Option<&'static str>
Get the field name of this tree cursor’s current node.
Sourcepub fn depth(&self) -> u32
pub fn depth(&self) -> u32
Get the depth of the cursor’s current node relative to the original node that the cursor was constructed with.
Sourcepub fn descendant_index(&self) -> usize
pub fn descendant_index(&self) -> usize
Get the index of the cursor’s current node out of all of the descendants of the original node that the cursor was constructed with
Sourcepub fn goto_first_child(&mut self) -> bool
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.
Sourcepub fn goto_last_child(&mut self) -> bool
pub fn goto_last_child(&mut self) -> bool
Move this cursor to the last child of its current node.
This returns true
if the cursor successfully moved, and returns
false
if there were no children.
Note that this function may be slower than
goto_first_child
because it needs to
iterate through all the children to compute the child’s position.
Sourcepub fn goto_parent(&mut self) -> bool
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).
Sourcepub fn goto_next_sibling(&mut self) -> bool
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.
Sourcepub fn goto_descendant(&mut self, descendant_index: usize)
pub fn goto_descendant(&mut self, descendant_index: usize)
Move the cursor to the node that is the nth descendant of the original node that the cursor was constructed with, where zero represents the original node itself.
Sourcepub fn goto_previous_sibling(&mut self) -> bool
pub fn goto_previous_sibling(&mut self) -> bool
Move this cursor to the previous sibling of its current node.
This returns true
if the cursor successfully moved, and returns
false
if there was no previous sibling node.
Note, that this function may be slower than
goto_next_sibling
due to how node
positions are stored. In the worst case, this will need to iterate
through all the children upto the previous sibling node to recalculate
its position.
Sourcepub fn goto_first_child_for_byte(&mut self, index: usize) -> Option<usize>
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.
Sourcepub fn goto_first_child_for_point(&mut self, point: Point) -> Option<usize>
pub fn goto_first_child_for_point(&mut self, point: Point) -> 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.
Trait Implementations§
Source§impl Clone for TreeCursor<'_>
impl Clone for TreeCursor<'_>
Source§impl Drop for TreeCursor<'_>
impl Drop for TreeCursor<'_>
impl Send for TreeCursor<'_>
impl Sync for TreeCursor<'_>
Auto Trait Implementations§
impl<'cursor> Freeze for TreeCursor<'cursor>
impl<'cursor> RefUnwindSafe for TreeCursor<'cursor>
impl<'cursor> Unpin for TreeCursor<'cursor>
impl<'cursor> UnwindSafe for TreeCursor<'cursor>
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
)