Skip to main content

PythonSource

Trait PythonSource 

Source
pub trait PythonSource: CodeUnitIndex + ImportAnalysisProvider {
    // Required methods
    fn path_module_fqn(&self, module_fq: &str) -> Option<Vec<CodeUnit>>;
    fn path_module_fqns_batch(
        &self,
        module_fqs: &[String],
    ) -> Vec<Option<Vec<CodeUnit>>>;
    fn definition_fqn(&self, fqn: &str) -> Vec<CodeUnit>;
    fn import_binder_of(&self, file: &ProjectFile) -> Arc<ImportBinder> ;
    fn export_index_of(&self, file: &ProjectFile) -> Arc<ExportIndex> ;
    fn prepared_syntax(
        &self,
        file: &ProjectFile,
    ) -> Option<Arc<PreparedSyntaxTree>>;
    fn visit_file_facts(
        &self,
        files: &[ProjectFile],
        visit: &mut dyn FnMut(&ProjectFile, Option<&dyn IndexedFileFacts>),
    );
}
Expand description

The analyzer-resident products Python’s language logic resolves through, on top of the two core capability traits it reads declarations and imports with. The analyzer is the only implementor and every method forwards to one of its own accessors, so the cells stay where they are and no free function can reach past this surface.

The usage index is deliberately absent: PythonUsageIndex::build and everything it calls take this trait, so the build cannot re-enter the memo it is filling. Code that runs once the index exists takes PythonUsageSource.

Required Methods§

Source

fn path_module_fqn(&self, module_fq: &str) -> Option<Vec<CodeUnit>>

Path-derived module units for module_fq; None when the store could not answer the path-symbol query at all.

Source

fn path_module_fqns_batch( &self, module_fqs: &[String], ) -> Vec<Option<Vec<CodeUnit>>>

Self::path_module_fqn for a whole batch, resolved in one store transaction.

Source

fn definition_fqn(&self, fqn: &str) -> Vec<CodeUnit>

Source

fn import_binder_of(&self, file: &ProjectFile) -> Arc<ImportBinder>

Shared by handle: both products are immutable for the analyzer generation that cached them, and callers ask for them once per receiver type, annotation or export name, so deep-cloning the whole map out of the cache on every hit was pure waste.

Source

fn export_index_of(&self, file: &ProjectFile) -> Arc<ExportIndex>

Source

fn prepared_syntax(&self, file: &ProjectFile) -> Option<Arc<PreparedSyntaxTree>>

The parsed tree and its source backing for file, from the analyzer’s query read cache.

A caller that needs a syntax node for an already-indexed declaration must reach it through here rather than re-parsing: indexed_source hands out an owned copy of the whole file, and building a Parser per declaration reparses text the analyzer has already parsed. None when the analyzer holds no prepared tree, which is what keeps the re-parsing path alive as a fallback.

Source

fn visit_file_facts( &self, files: &[ProjectFile], visit: &mut dyn FnMut(&ProjectFile, Option<&dyn IndexedFileFacts>), )

Every file’s indexed facts, visited in the analyzer’s own bulk-read batches. None marks a file the index carries no record for.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§