Skip to main content

Driver

Struct Driver 

Source
pub struct Driver { /* private fields */ }
Expand description

Pipeline orchestration wrapper around ProjectDb.

Implementations§

Source§

impl Driver

Source

pub fn new() -> Self

Create a new driver with an empty database.

Source

pub fn from_db(db: ProjectDb) -> Self

Create a driver from an existing database.

Source

pub fn set_analysis_options(&mut self, options: AnalysisOptions)

Set the analysis options (e.g. a registered host manifest + external check severity) used by analyze. An input write — dependent queries recompute on next read.

Source

pub fn db(&self) -> &ProjectDb

Borrow the underlying database.

Source

pub fn db_mut(&mut self) -> &mut ProjectDb

Mutably borrow the underlying database.

Salsa’s dependency tracking invalidates derived queries on input writes, so no manual cache invalidation happens here.

Source

pub fn into_db(self) -> ProjectDb

Consume the driver and return the underlying database.

Source

pub fn discover<F>( &mut self, entry: &str, read_file: F, ) -> Result<(), DiscoverError>
where F: FnMut(&str) -> Result<String, Error>,

Discover all files reachable via INCLUDEs from the entry point.

Source

pub fn discover_native( &mut self, tree: &dyn SourceTree, ) -> Result<(), DiscoverError>

Discover a native .brink project: enumerate tree (sorted, root-relative keys, scoped to tree’s own constructor-held root — issue #1371) and load every file — no INCLUDE BFS, since native has no INCLUDEs. tree must be constructed with the project’s source root (RealFs::new/GitRev::new) — see native_source_root to derive it from an entry path.

Source

pub fn analyze(&mut self) -> &AnalysisResult

Run cross-file analysis on all files (memoized by the db’s analysis query — an unchanged project returns the cached result).

Source

pub fn analyze_project(&self, file_ids: &[FileId]) -> AnalysisResult

Run analysis on a specific subset of files (one project). Not cached.

Module-aware and options-honoring (issue #1553): the pass runs with the db’s own ProjectDb::module_map and registered AnalysisOptions, so the DefinitionIds it mints key this db’s per-def queries and the declared dialect/types/lints reach it — the same contract analyze has. A bare brink_analyzer::analyze/analyze_with_options here was module-blind and dropped the options entirely, which for a native .brink project (whose module is its path, always declared) mints a different identity space than the db’s — see ProjectDb::module_map’s doc.

Stem-collision diagnostics (E085) are folded in from ProjectDb::module_map_diagnostics, scoped to file_ids, for the same reason: the analyzer is handed the finished map and cannot re-derive them.

Source

pub fn analysis_inputs_for( &self, file_ids: &[FileId], ) -> Vec<(FileId, HirFile, SymbolManifest)>

Snapshot analysis inputs for a subset of files.

Source

pub fn analysis_inputs(&self) -> Vec<(FileId, HirFile, SymbolManifest)>

Snapshot all analysis inputs.

Source

pub fn compute_projects(&self) -> Vec<(FileId, Vec<FileId>)>

Compute independent projects: ink files by INCLUDE reachability, native .brink files as one project (issue #1562). See brink_db::ProjectDb::compute_projects.

Source

pub fn file_ids_topo(&self, entry: FileId) -> Vec<FileId>

Return file IDs in topological include order.

Source

pub fn file_metadata(&self) -> Vec<(FileId, String, String)>

Snapshot file metadata for diagnostic publishing.

Source

pub fn collect_diagnostics( &self, analysis: &AnalysisResult, entry: Option<FileId>, ) -> DiagnosticReport

Collect all diagnostics (lowering + analysis), apply suppressions, partition.

Source

pub fn lir_inputs( &self, entry: FileId, ) -> (Vec<(FileId, &HirFile)>, HashMap<FileId, String>)

Prepare inputs for LIR lowering.

Returns HIR files in topological order and a path map for diagnostics.

Trait Implementations§

Source§

impl Default for Driver

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> 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> Lookup<T> for T

Source§

fn into_owned(self) -> T

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