[][src]Struct tree_sitter::QueryCursor

pub struct QueryCursor(_);

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

Methods

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.

  1. Call matches to 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.
  2. Call captures to 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 matches<'a>(
    &mut self,
    query: &'a Query,
    node: Node<'a>,
    text_callback: impl FnMut(Node<'a>) -> &[u8] + 'a
) -> impl Iterator<Item = QueryMatch<'a>> + 'a
[src]

Iterate through the matches of a given query.

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

Iterate through the captures of a given query.

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]

Auto Trait Implementations

Blanket Implementations

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

impl<T> From<T> for 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.

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

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

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