pub struct ParserPool { /* private fields */ }Expand description
Pool of tree-sitter parsers and compiled queries, one per language.
Parsers and queries are lazily created on first use and reused for subsequent operations. This avoids the overhead of creating new parsers/compiling queries for each file.
Implementations§
Source§impl ParserPool
impl ParserPool
Sourcepub fn get_or_create_query(&mut self, lang: SupportedLanguage) -> Option<&Query>
pub fn get_or_create_query(&mut self, lang: SupportedLanguage) -> Option<&Query>
Get or create a compiled highlight query for the given language.
Queries are cached to avoid recompilation overhead on each use. This is particularly important for injection processing (e.g., Svelte) where multiple queries are needed per file.
Sourcepub fn get_or_create(&mut self, ext: &str) -> Option<&mut Parser>
pub fn get_or_create(&mut self, ext: &str) -> Option<&mut Parser>
Get or create a parser for the given file extension.
Returns None if the extension is not supported by tree-sitter.
Sourcepub fn supports_extension(ext: &str) -> bool
pub fn supports_extension(ext: &str) -> bool
Check if tree-sitter supports the given file extension.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ParserPool
impl RefUnwindSafe for ParserPool
impl Send for ParserPool
impl Sync for ParserPool
impl Unpin for ParserPool
impl UnsafeUnpin for ParserPool
impl UnwindSafe for ParserPool
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