Struct tree_sitter::Query [−][src]
A set of patterns that match nodes in a syntax tree.
Implementations
impl Query[src]
pub fn new(language: Language, source: &str) -> Result<Self, QueryError>[src]
Create a new query from a string containing one or more S-expression patterns.
The query is associated with a particular language, and can only be run on syntax nodes parsed with that language. References to Queries can be shared between multiple threads.
pub fn start_byte_for_pattern(&self, pattern_index: usize) -> usize[src]
Get the byte offset where the given pattern starts in the query’s source.
pub fn pattern_count(&self) -> usize[src]
Get the number of patterns in the query.
pub fn capture_names(&self) -> &[String][src]
Get the names of the captures used in the query.
pub fn property_predicates(&self, index: usize) -> &[(QueryProperty, bool)][src]
Get the properties that are checked for the given pattern index.
This includes predicates with the operators is? and is-not?.
pub fn property_settings(&self, index: usize) -> &[QueryProperty][src]
Get the properties that are set for the given pattern index.
This includes predicates with the operator set!.
pub fn general_predicates(&self, index: usize) -> &[QueryPredicate][src]
Get the other user-defined predicates associated with the given index.
This includes predicate with operators other than:
- match?
- eq?and `not-eq?
- is?and- is-not?
- set!
pub fn disable_capture(&mut self, name: &str)[src]
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.
pub fn disable_pattern(&mut self, index: usize)[src]
Disable a certain pattern within a query.
This prevents the pattern from matching, and also avoids any resource usage associated with the pattern.
pub fn step_is_definite(&self, byte_offset: usize) -> bool[src]
Check if a given step in a query is ‘definite’.
A query step is ‘definite’ if its parent pattern will be guaranteed to match successfully once it reaches the step.
Trait Implementations
impl Debug for Query[src]
impl Drop for Query[src]
impl PartialEq<Query> for Query[src]
impl Send for Query[src]
impl Sync for Query[src]
Auto Trait Implementations
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>,