Struct tree_sitter::QueryCursor[][src]

pub struct QueryCursor(_);

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

Implementations

impl 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<'a, T: AsRef<[u8]>>(
    &'a mut self,
    query: &'a Query,
    node: Node<'a>,
    text_callback: impl FnMut(Node<'a>) -> T + 'a
) -> impl Iterator<Item = QueryMatch<'a>> + '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<'a, T: AsRef<[u8]>>(
    &'a mut self,
    query: &'a Query,
    node: Node<'a>,
    text_callback: impl FnMut(Node<'a>) -> T + 'a
) -> QueryCaptures<'a, T>

Notable traits for QueryCaptures<'a, T>

impl<'a, T: AsRef<[u8]>> Iterator for QueryCaptures<'a, T> type Item = (QueryMatch<'a>, 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]

impl Send for QueryCursor[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

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

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

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.

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.