Skip to main content

ProjectDb

Struct ProjectDb 

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

Stateful incremental project database.

Caches parsed trees and lowered HIR per file, enabling efficient re-analysis when individual files change. Both the compiler (one-shot) and LSP (long-lived) use this as their project model.

Implementations§

Source§

impl ProjectDb

Source

pub fn new() -> ProjectDb

Create an empty project database.

Source

pub fn set_file(&mut self, path: &str, source: String) -> FileId

Add or replace a file. Performs full parse + lower + cache.

Source

pub fn update_file(&mut self, path: &str, source: String) -> FileId

Incrementally update a file. Re-parses, diffs knots by green-node identity, and only re-lowers changed knots.

Source

pub fn remove_file(&mut self, path: &str)

Remove a file from the database.

Source

pub fn file_id(&self, path: &str) -> Option<FileId>

Look up a file’s ID by path.

Source

pub fn file_path(&self, id: FileId) -> Option<&str>

Look up a file’s path by ID.

Source

pub fn file_ids(&self) -> impl Iterator<Item = FileId>

Iterate over all registered file IDs.

Source

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

Return file IDs in topological include order (included files before the files that include them), matching ink’s INCLUDE paste semantics.

Source

pub fn parse(&self, id: FileId) -> Option<&Parse>

Get the cached parse tree for a file.

Source

pub fn hir(&self, id: FileId) -> Option<&HirFile>

Get the cached HIR for a file.

Source

pub fn manifest(&self, id: FileId) -> Option<&SymbolManifest>

Get the cached symbol manifest for a file.

Source

pub fn source(&self, id: FileId) -> Option<&str>

Get the source text for a file.

Source

pub fn file_diagnostics(&self, id: FileId) -> Option<&[Diagnostic]>

Get per-file diagnostics (parse + lowering).

Source

pub fn suppressions(&self, id: FileId) -> Option<&Suppressions>

Get parsed suppression directives for a file.

Source

pub fn rebuild_include_graph(&mut self)

Rebuild include graph edges for all files.

Must be called after batch-loading files (e.g. workspace discovery) because set_file can only create edges to files already in the db. Files loaded before their include targets will have missing edges.

Source

pub fn find_cycle(&self) -> Option<Vec<FileId>>

Detect cycles in the include graph.

Returns the first cycle found as an ordered path of file IDs.

Source

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

Compute independent projects from include relationships.

Returns (root, members) pairs sorted by root FileId.

Source

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

Snapshot analysis inputs for a subset of files.

Like analysis_inputs() but filtered to the given set.

Source

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

Snapshot all analysis inputs for background analysis.

Returns (FileId, HirFile, SymbolManifest) tuples cloned out of the db, so the caller can run brink_analyzer::analyze() without holding the lock.

Source

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

Snapshot file metadata for diagnostic publishing.

Returns (FileId, path, source) tuples for all files in the db.

Trait Implementations§

Source§

impl Default for ProjectDb

Source§

fn default() -> ProjectDb

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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