Struct tree_sitter::QueryCursor[][src]

pub struct QueryCursor(_);
Expand description

A stateful object for executing a Query on a syntax Tree.

Implementations

impl<'a> QueryCursor[src]

pub fn new() -> Self[src]

Create a new cursor for executing a given query.

The cursor stores the state that is needed to iteratively search for matches.

pub fn did_exceed_match_limit(&self) -> bool[src]

Check if, on its last execution, this cursor exceeded its maximum number of in-progress matches.

pub fn matches<'tree: 'a, T: AsRef<[u8]>>(
    &'a mut self,
    query: &'a Query,
    node: Node<'tree>,
    text_callback: impl FnMut(Node<'tree>) -> T + 'a
) -> impl Iterator<Item = QueryMatch<'tree>> + 'a
[src]

Iterate over all of the matches in the order that they were found.

Each match contains the index of the pattern that matched, and a list of captures. Because multiple patterns can match the same set of nodes, one match may contain captures that appear before some of the captures from a previous match.

pub fn captures<'tree, T: AsRef<[u8]>>(
    &'a mut self,
    query: &'a Query,
    node: Node<'tree>,
    text_callback: impl FnMut(Node<'tree>) -> T + 'a
) -> QueryCaptures<'a, 'tree, T>

Notable traits for QueryCaptures<'a, 'tree, T>

impl<'a, 'tree: 'a, T: AsRef<[u8]>> Iterator for QueryCaptures<'a, 'tree, T> type Item = (QueryMatch<'tree>, usize);
[src]

Iterate over all of the individual captures in the order that they appear.

This is useful if don’t care about which pattern matched, and just want a single, ordered sequence of captures.

pub fn set_byte_range(&mut self, start: usize, end: usize) -> &mut Self[src]

Set the range in which the query will be executed, in terms of byte offsets.

pub fn set_point_range(&mut self, start: Point, end: Point) -> &mut Self[src]

Set the range in which the query will be executed, in terms of rows and columns.

Trait Implementations

impl Drop for QueryCursor[src]

fn drop(&mut self)[src]

Executes the destructor for this type. Read more

impl Send for QueryCursor[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.