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 set_timeout_micros(&mut self, timeout: u64)
👎Deprecated since 0.25.0: Prefer using matches_with_options
or captures_with_options
and using a callback
pub fn set_timeout_micros(&mut self, timeout: u64)
matches_with_options
or captures_with_options
and using a callbackSet the maximum duration in microseconds that query execution should be allowed to take before halting.
If query execution takes longer than this, it will halt early, returning None.
Sourcepub fn timeout_micros(&self) -> u64
👎Deprecated since 0.25.0: Prefer using matches_with_options
or captures_with_options
and using a callback
pub fn timeout_micros(&self) -> u64
matches_with_options
or captures_with_options
and using a callbackGet the duration in microseconds that query execution is allowed to take.
This is set via set_timeout_micros
.
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_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 limit a search depth for a pattern’s root node but other nodes that are parts of the pattern may be searched at any depth what 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