pub struct Query { /* private fields */ }Implementations§
Source§impl Query
impl Query
Sourcepub fn new(
grammar: Grammar,
source: &str,
custom_predicate: impl FnMut(Pattern, UserPredicate<'_>) -> Result<(), InvalidPredicateError>,
) -> Result<Self, ParseError>
pub fn new( grammar: Grammar, source: &str, custom_predicate: impl FnMut(Pattern, UserPredicate<'_>) -> Result<(), InvalidPredicateError>, ) -> Result<Self, ParseError>
Create a new query from a string containing one or more S-expression patterns.
The query is associated with a particular grammar, and can only be run on syntax nodes parsed with that grammar. References to Queries can be shared between multiple threads.
pub fn capture_name(&self, capture_idx: Capture) -> &str
pub fn captures(&self) -> impl ExactSizeIterator<Item = (Capture, &str)>
pub fn num_captures(&self) -> u32
pub fn get_capture(&self, capture_name: &str) -> Option<Capture>
Sourcepub fn start_byte_for_pattern(&self, pattern: Pattern) -> usize
pub fn start_byte_for_pattern(&self, pattern: Pattern) -> usize
Get the byte offset where the given pattern starts in the query’s source.
Sourcepub fn pattern_count(&self) -> usize
pub fn pattern_count(&self) -> usize
Get the number of patterns in the query.
Sourcepub fn patterns(&self) -> impl ExactSizeIterator<Item = Pattern>
pub fn patterns(&self) -> impl ExactSizeIterator<Item = Pattern>
Get the number of patterns in the query.
Sourcepub fn disable_capture(&mut self, name: &str)
pub fn disable_capture(&mut self, name: &str)
Disable a certain capture within a query.
This prevents the capture from being returned in matches, and also avoids any resource usage associated with recording the capture. Currently, there is no way to undo this.
Trait Implementations§
Auto Trait Implementations§
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
Mutably borrows from an owned value. Read more