pub struct FileParser { /* private fields */ }Expand description
Core parsing engine. Handles language detection, parse tree caching, symbol table caching, and query pattern execution via tree-sitter.
Implementations§
Source§impl FileParser
impl FileParser
Sourcepub fn with_symbol_cache(symbol_cache: SharedSymbolCache) -> Self
pub fn with_symbol_cache(symbol_cache: SharedSymbolCache) -> Self
Create a new FileParser backed by a shared symbol cache.
Sourcepub fn with_symbol_cache_generation(
symbol_cache: SharedSymbolCache,
symbol_cache_generation: Option<u64>,
) -> Self
pub fn with_symbol_cache_generation( symbol_cache: SharedSymbolCache, symbol_cache_generation: Option<u64>, ) -> Self
Create a new FileParser backed by a shared symbol cache generation.
Sourcepub fn with_source_capture(self) -> Self
pub fn with_source_capture(self) -> Self
Outline batches retain source only until the matching tree is evicted; other parser consumers do not need a second resident copy of each file.
pub fn with_dynamic_languages(self, dynamic_languages: bool) -> Self
Sourcepub fn parse_source(
path: &Path,
source: &str,
lang: LangId,
) -> Result<Tree, AftError>
pub fn parse_source( path: &Path, source: &str, lang: LangId, ) -> Result<Tree, AftError>
Parses source with this thread’s retained parser for lang and
counts the parse for tests. Every FileParser used to own its own
per-language Parser, and most callers build a fresh FileParser per
request (the language provider does it per call), so each call paid a
parser allocation and grammar load before parsing.
Sourcepub fn symbol_cache_len(&self) -> usize
pub fn symbol_cache_len(&self) -> usize
Number of entries in the shared symbol cache.
Sourcepub fn symbol_cache(&self) -> SharedSymbolCache
pub fn symbol_cache(&self) -> SharedSymbolCache
Shared symbol cache backing this parser.
Sourcepub fn parse(&mut self, path: &Path) -> Result<(&Tree, LangId), AftError>
pub fn parse(&mut self, path: &Path) -> Result<(&Tree, LangId), AftError>
Parse a file, returning the tree and detected language. Uses cache if the file hasn’t been modified since last parse.
Sourcepub fn parse_source_text(
&mut self,
path: &Path,
source: &str,
) -> Result<(&Tree, LangId), AftError>
pub fn parse_source_text( &mut self, path: &Path, source: &str, ) -> Result<(&Tree, LangId), AftError>
Parse source, the text a caller already read from path, without
reading the file again. The tree cache is shared with
FileParser::parse: a cached tree is reused only when it was parsed
from the same text (same size and content hash), so the tree always
describes source.
Sourcepub fn parse_cloned(&mut self, path: &Path) -> Result<(Tree, LangId), AftError>
pub fn parse_cloned(&mut self, path: &Path) -> Result<(Tree, LangId), AftError>
Like FileParser::parse but returns an owned Tree clone.
Useful when the caller needs to hold the tree while also calling other mutable methods on this parser.
pub fn parse_snapshot(&mut self, path: &Path) -> Result<ParsedFile, AftError>
Sourcepub fn extract_symbols_from_snapshot(
&mut self,
path: &Path,
parsed: &ParsedFile,
) -> Result<Arc<Vec<Symbol>>, AftError>
pub fn extract_symbols_from_snapshot( &mut self, path: &Path, parsed: &ParsedFile, ) -> Result<Arc<Vec<Symbol>>, AftError>
Reuse a validated request snapshot rather than reopening its source.
Sourcepub fn cached_has_error(&self, path: &Path) -> Option<bool>
pub fn cached_has_error(&self, path: &Path) -> Option<bool>
The syntax verdict recorded with a still-fresh cache entry for path:
Some(true) when the file had syntax errors. None when there is no
entry, the entry has no verdict, or the file changed since.
Sourcepub fn cached_outline(&self, path: &Path) -> Option<CachedOutline>
pub fn cached_outline(&self, path: &Path) -> Option<CachedOutline>
Everything a multi-file outline stored for path, when the entry is
still fresh and carries outline facts. A miss means the caller parses.
Sourcepub fn store_outline_facts(
&self,
path: &Path,
parsed: &ParsedFile,
facts: Arc<OutlineParseFacts>,
)
pub fn store_outline_facts( &self, path: &Path, parsed: &ParsedFile, facts: Arc<OutlineParseFacts>, )
Attach outline facts derived from parsed to the cache entry for
path, only if that entry still describes the same content. The facts
are not persisted to disk, so attaching them does not mark the cache
as needing a write.
Sourcepub fn extract_rust_outline(
&mut self,
path: &Path,
) -> Result<(Arc<Vec<Symbol>>, Arc<Vec<RustModule>>), AftError>
pub fn extract_rust_outline( &mut self, path: &Path, ) -> Result<(Arc<Vec<Symbol>>, Arc<Vec<RustModule>>), AftError>
Module layout shares the symbol entry’s freshness and invalidation lifetime. Disk-loaded or manually inserted tables have no module layout: their first outline reads and parses once, then later fresh hits do neither.
Sourcepub fn extract_symbols(&mut self, path: &Path) -> Result<Vec<Symbol>, AftError>
pub fn extract_symbols(&mut self, path: &Path) -> Result<Vec<Symbol>, AftError>
Extract symbols from a file using language-specific query patterns.
Results are cached by (path, mtime) — subsequent calls for unchanged
files return the cached symbol table without re-parsing.
pub fn extract_symbols_with_cache_status( &mut self, path: &Path, ) -> Result<(Vec<Symbol>, bool), AftError>
Borrow the immutable cached table without copying every symbol string.
Sourcepub fn evict_parse_tree(&mut self, path: &Path)
pub fn evict_parse_tree(&mut self, path: &Path)
Drop one local parse tree while preserving its shared extracted symbols.
Whole-corpus prewarming visits each file once, so retaining finished trees only increases its peak memory. Other parsing operations keep the default tree-cache reuse behavior unless they explicitly call this method.
Sourcepub fn invalidate_symbols(&mut self, path: &Path)
pub fn invalidate_symbols(&mut self, path: &Path)
Invalidate cached symbols for a specific file (e.g., after an edit).
Auto Trait Implementations§
impl Forget for FileParser
impl Freeze for FileParser
impl Move for FileParser
impl RefUnwindSafe for FileParser
impl Send for FileParser
impl Sync for FileParser
impl Unpin for FileParser
impl UnsafeUnpin for FileParser
impl UnwindSafe for FileParser
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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> ⓘ
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> ⓘ
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