Skip to main content

PythonSource

Trait PythonSource 

Source
pub trait PythonSource:
    CodeUnitIndex
    + ImportAnalysisProvider
    + PythonSourceFactProvider {
    // 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 module_spellings(&self) -> Arc<PythonModuleSpellings> ⓘ;
    fn import_binder_of(&self, file: &ProjectFile) -> Arc<ImportBinder> ⓘ;
    fn export_index_of(&self, file: &ProjectFile) -> Arc<ExportIndex> ⓘ;
    fn prepared_syntax(
        &self,
        token: QueryToken<'_>,
        file: &ProjectFile,
    ) -> Option<Arc<PreparedSyntaxTree>>;
    fn visit_file_facts(
        &self,
        files: &[ProjectFile],
        keep_going: &dyn Fn() -> bool,
        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 module_spellings(&self) -> Arc<PythonModuleSpellings> ⓘ

Every workspace Python module’s project-root name, for resolving an absolute specifier written against a source root below the project root.

Memoized for the analyzer generation by the implementor: the product is path math over the workspace file listing, and every import whose specifier names no indexed module asks for it.

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, token: QueryToken<'_>, file: &ProjectFile, ) -> Option<Arc<PreparedSyntaxTree>>

The admitted active syntax for executable-body and use-site queries. Captured declaration properties are read from signature metadata. None is unavailable and does not authorize a declaration parser fallback. The token proves the request cache is live.

Source

fn visit_file_facts( &self, files: &[ProjectFile], keep_going: &dyn Fn() -> bool, 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§