Skip to main content

FileParser

Struct FileParser 

Source
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

Source

pub fn new() -> Self

Create a new FileParser with an empty parse cache.

Source

pub fn with_symbol_cache(symbol_cache: SharedSymbolCache) -> Self

Create a new FileParser backed by a shared symbol cache.

Source

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.

Source

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.

Source

pub fn with_dynamic_languages(self, dynamic_languages: bool) -> Self

Source

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.

Source

pub fn symbol_cache_len(&self) -> usize

Number of entries in the shared symbol cache.

Source

pub fn symbol_cache(&self) -> SharedSymbolCache

Shared symbol cache backing this parser.

Source

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.

Source

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.

Source

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.

Source

pub fn parse_snapshot(&mut self, path: &Path) -> Result<ParsedFile, AftError>

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn extract_symbols_with_cache_status( &mut self, path: &Path, ) -> Result<(Vec<Symbol>, bool), AftError>

Source

pub fn extract_symbols_shared( &mut self, path: &Path, ) -> Result<Arc<Vec<Symbol>>, AftError>

Borrow the immutable cached table without copying every symbol string.

Source

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.

Source

pub fn invalidate_symbols(&mut self, path: &Path)

Invalidate cached symbols for a specific file (e.g., after an edit).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more