pub struct QueryCursor { /* private fields */ }Implementations§
Source§impl QueryCursor
impl QueryCursor
Sourcepub const unsafe fn from_raw(ptr: *mut TSQueryCursor) -> Self
pub const unsafe fn from_raw(ptr: *mut TSQueryCursor) -> Self
Sourcepub fn into_raw(self) -> *mut TSQueryCursor
pub fn into_raw(self) -> *mut TSQueryCursor
Consumes the QueryCursor, returning a raw pointer to the underlying C structure.
Source§impl 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<'query, 'cursor: 'query, 'tree, T: TextProvider<I>, I: AsRef<[u8]>>(
&'cursor mut self,
query: &'query Query,
node: Node<'tree>,
text_provider: T,
) -> QueryMatches<'query, 'tree, T, I>
pub fn matches<'query, 'cursor: 'query, 'tree, T: TextProvider<I>, I: AsRef<[u8]>>( &'cursor mut self, query: &'query Query, node: Node<'tree>, text_provider: T, ) -> QueryMatches<'query, 'tree, T, I>
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.
Iterating over a QueryMatches object requires the StreamingIterator
or StreamingIteratorMut trait to be in scope. This can be done via
use tree_sitter::StreamingIterator or use tree_sitter::StreamingIteratorMut
Sourcepub fn matches_with_options<'query, 'cursor: 'query, 'tree, T: TextProvider<I>, I: AsRef<[u8]>>(
&'cursor mut self,
query: &'query Query,
node: Node<'tree>,
text_provider: T,
options: QueryCursorOptions<'_>,
) -> QueryMatches<'query, 'tree, T, I>
pub fn matches_with_options<'query, 'cursor: 'query, 'tree, T: TextProvider<I>, I: AsRef<[u8]>>( &'cursor mut self, query: &'query Query, node: Node<'tree>, text_provider: T, options: QueryCursorOptions<'_>, ) -> QueryMatches<'query, 'tree, T, I>
Iterate over all of the matches in the order that they were found, with options.
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<'query, 'cursor: 'query, 'tree, T: TextProvider<I>, I: AsRef<[u8]>>(
&'cursor mut self,
query: &'query Query,
node: Node<'tree>,
text_provider: T,
) -> QueryCaptures<'query, 'tree, T, I>
pub fn captures<'query, 'cursor: 'query, 'tree, T: TextProvider<I>, I: AsRef<[u8]>>( &'cursor mut self, query: &'query Query, node: Node<'tree>, text_provider: T, ) -> QueryCaptures<'query, 'tree, T, I>
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.
Iterating over a QueryCaptures object requires the StreamingIterator
or StreamingIteratorMut trait to be in scope. This can be done via
use tree_sitter::StreamingIterator or use tree_sitter::StreamingIteratorMut
Sourcepub fn captures_with_options<'query, 'cursor: 'query, 'tree, T: TextProvider<I>, I: AsRef<[u8]>>(
&'cursor mut self,
query: &'query Query,
node: Node<'tree>,
text_provider: T,
options: QueryCursorOptions<'_>,
) -> QueryCaptures<'query, 'tree, T, I>
pub fn captures_with_options<'query, 'cursor: 'query, 'tree, T: TextProvider<I>, I: AsRef<[u8]>>( &'cursor mut self, query: &'query Query, node: Node<'tree>, text_provider: T, options: QueryCursorOptions<'_>, ) -> QueryCaptures<'query, 'tree, T, I>
Iterate over all of the individual captures in the order that they appear, with options.
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.
Sourcepub fn set_containing_byte_range(&mut self, range: Range<usize>) -> &mut Self
pub fn set_containing_byte_range(&mut self, range: Range<usize>) -> &mut Self
Set the byte range within which all matches must be fully contained.
Set the range of bytes in which matches will be searched for. In contrast to
ts_query_cursor_set_byte_range, this will restrict the query cursor to only return
matches where all nodes are fully contained within the given range. Both functions
can be used together, e.g. to search for any matches that intersect line 5000, as
long as they are fully contained within lines 4500-5500
Sourcepub fn set_containing_point_range(&mut self, range: Range<Point>) -> &mut Self
pub fn set_containing_point_range(&mut self, range: Range<Point>) -> &mut Self
Set the point range within which all matches must be fully contained.
Set the range of bytes in which matches will be searched for. In contrast to
ts_query_cursor_set_point_range, this will restrict the query cursor to only return
matches where all nodes are fully contained within the given range. Both functions
can be used together, e.g. to search for any matches that intersect line 5000, as
long as they are fully contained within lines 4500-5500
Sourcepub fn set_max_start_depth(&mut self, max_start_depth: Option<u32>) -> &mut Self
pub fn set_max_start_depth(&mut self, max_start_depth: Option<u32>) -> &mut Self
Set the maximum start depth for a query cursor.
This prevents cursors from exploring children nodes at a certain depth. Note if a pattern includes many children, then they will still be checked.
The zero max start depth value can be used as a special behavior and it helps to destructure a subtree by staying on a node and using captures for interested parts. Note that the zero max start depth only limits a search depth for a pattern’s root node but other nodes that are parts of the pattern may be searched at any depth depending on what is defined by the pattern structure.
Set to None to remove the maximum start depth.
Trait Implementations§
Source§impl Default for QueryCursor
impl Default for QueryCursor
Source§impl Drop for QueryCursor
impl Drop for QueryCursor
impl Send for QueryCursor
impl Sync for QueryCursor
Auto Trait Implementations§
impl Freeze for QueryCursor
impl RefUnwindSafe for QueryCursor
impl Unpin for QueryCursor
impl UnwindSafe for QueryCursor
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more