Struct tree_sitter::QueryCursor
source · [−]pub struct QueryCursor { /* private fields */ }
Expand description
A stateful object for executing a Query
on a syntax Tree
.
Implementations
sourceimpl QueryCursor
impl QueryCursor
sourcepub fn new() -> Self
pub fn new() -> Self
Create a new cursor for executing a given query.
The cursor stores the state that is needed to iteratively search for matches.
sourcepub fn match_limit(&self) -> u32
pub fn match_limit(&self) -> u32
Return the maximum number of in-progress matches for this cursor.
sourcepub fn set_match_limit(&mut self, limit: u32)
pub fn set_match_limit(&mut self, limit: u32)
Set the maximum number of in-progress matches for this cursor. The limit must be > 0 and <= 65536.
sourcepub fn did_exceed_match_limit(&self) -> bool
pub fn did_exceed_match_limit(&self) -> bool
Check if, on its last execution, this cursor exceeded its maximum number of in-progress matches.
sourcepub fn matches<'a, 'tree: 'a, T: TextProvider<'a> + 'a>(
&'a mut self,
query: &'a Query,
node: Node<'tree>,
text_provider: T
) -> QueryMatches<'a, 'tree, T>ⓘNotable traits for QueryMatches<'a, 'tree, T>impl<'a, 'tree, T: TextProvider<'a>> Iterator for QueryMatches<'a, 'tree, T> type Item = QueryMatch<'a, 'tree>;
pub fn matches<'a, 'tree: 'a, T: TextProvider<'a> + 'a>(
&'a mut self,
query: &'a Query,
node: Node<'tree>,
text_provider: T
) -> QueryMatches<'a, 'tree, T>ⓘNotable traits for QueryMatches<'a, 'tree, T>impl<'a, 'tree, T: TextProvider<'a>> Iterator for QueryMatches<'a, 'tree, T> type Item = QueryMatch<'a, 'tree>;
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.
sourcepub fn captures<'a, 'tree: 'a, T: TextProvider<'a> + 'a>(
&'a mut self,
query: &'a Query,
node: Node<'tree>,
text_provider: T
) -> QueryCaptures<'a, 'tree, T>ⓘNotable traits for QueryCaptures<'a, 'tree, T>impl<'a, 'tree, T: TextProvider<'a>> Iterator for QueryCaptures<'a, 'tree, T> type Item = (QueryMatch<'a, 'tree>, usize);
pub fn captures<'a, 'tree: 'a, T: TextProvider<'a> + 'a>(
&'a mut self,
query: &'a Query,
node: Node<'tree>,
text_provider: T
) -> QueryCaptures<'a, 'tree, T>ⓘNotable traits for QueryCaptures<'a, 'tree, T>impl<'a, 'tree, T: TextProvider<'a>> Iterator for QueryCaptures<'a, 'tree, T> type Item = (QueryMatch<'a, 'tree>, usize);
Iterate over all of the individual captures in the order that they appear.
This is useful if you don’t care about which pattern matched, and just want a single, ordered sequence of captures.
sourcepub fn set_byte_range(&mut self, range: Range<usize>) -> &mut Self
pub fn set_byte_range(&mut self, range: Range<usize>) -> &mut Self
Set the range in which the query will be executed, in terms of byte offsets.
sourcepub fn set_point_range(&mut self, range: Range<Point>) -> &mut Self
pub fn set_point_range(&mut self, range: Range<Point>) -> &mut Self
Set the range in which the query will be executed, in terms of rows and columns.