pub struct QueryManager { /* private fields */ }Expand description
Manages tree-sitter queries for extracting code entities.
Implementations§
Source§impl QueryManager
impl QueryManager
Sourcepub fn new(
language: SupportedLanguage,
query_source: &str,
) -> Result<Self, ParserError>
pub fn new( language: SupportedLanguage, query_source: &str, ) -> Result<Self, ParserError>
Create a new query manager from SCM query source.
Sourcepub fn from_file(
language: SupportedLanguage,
path: &Path,
) -> Result<Self, ParserError>
pub fn from_file( language: SupportedLanguage, path: &Path, ) -> Result<Self, ParserError>
Load query from a file path.
Sourcepub fn from_queries_dir(
language: SupportedLanguage,
queries_dir: &Path,
) -> Result<Self, ParserError>
pub fn from_queries_dir( language: SupportedLanguage, queries_dir: &Path, ) -> Result<Self, ParserError>
Load query from the default queries directory.
Looks for {language}-tags.scm in the queries directory and
concatenates any overlay files from overlays/{language}-*.scm.
Sourcepub fn from_embedded(language: SupportedLanguage) -> Result<Self, ParserError>
pub fn from_embedded(language: SupportedLanguage) -> Result<Self, ParserError>
Load query from embedded queries (compiled into the binary).
This is the preferred method for production use as it doesn’t require external query files.
Sourcepub fn language(&self) -> SupportedLanguage
pub fn language(&self) -> SupportedLanguage
Get the language this query is for.
Sourcepub fn capture_names(&self) -> &[&str]
pub fn capture_names(&self) -> &[&str]
Get the capture names defined in this query.
Sourcepub fn capture_index(&self, name: &str) -> Option<u32>
pub fn capture_index(&self, name: &str) -> Option<u32>
Get the capture index for a capture name.
Auto Trait Implementations§
impl Freeze for QueryManager
impl RefUnwindSafe for QueryManager
impl Send for QueryManager
impl Sync for QueryManager
impl Unpin for QueryManager
impl UnwindSafe for QueryManager
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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