Struct tree_sitter::QueryCursor [−][src]
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 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]
&'a mut self,
query: &'a Query,
node: Node<'a>,
text_callback: impl FnMut(Node<'a>) -> T + 'a
) -> impl Iterator<Item = QueryMatch<'a>> + 'a
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]
&'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);
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
Auto Trait Implementations
impl RefUnwindSafe for QueryCursor
impl !Sync for QueryCursor
impl Unpin for QueryCursor
impl UnwindSafe for QueryCursor
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,