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
impl ProjectDb
Sourcepub fn set_file(&mut self, path: &str, source: String) -> FileId
pub fn set_file(&mut self, path: &str, source: String) -> FileId
Add or replace a file. Performs full parse + lower + cache.
Sourcepub fn update_file(&mut self, path: &str, source: String) -> FileId
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.
Sourcepub fn remove_file(&mut self, path: &str)
pub fn remove_file(&mut self, path: &str)
Remove a file from the database.
Sourcepub fn file_ids_topo(&self, entry: FileId) -> Vec<FileId>
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.
Sourcepub fn manifest(&self, id: FileId) -> Option<&SymbolManifest>
pub fn manifest(&self, id: FileId) -> Option<&SymbolManifest>
Get the cached symbol manifest for a file.
Sourcepub fn file_diagnostics(&self, id: FileId) -> Option<&[Diagnostic]>
pub fn file_diagnostics(&self, id: FileId) -> Option<&[Diagnostic]>
Get per-file diagnostics (parse + lowering).
Sourcepub fn suppressions(&self, id: FileId) -> Option<&Suppressions>
pub fn suppressions(&self, id: FileId) -> Option<&Suppressions>
Get parsed suppression directives for a file.
Sourcepub fn rebuild_include_graph(&mut self)
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.
Sourcepub fn find_cycle(&self) -> Option<Vec<FileId>>
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.
Sourcepub fn compute_projects(&self) -> Vec<(FileId, Vec<FileId>)>
pub fn compute_projects(&self) -> Vec<(FileId, Vec<FileId>)>
Compute independent projects from include relationships.
Returns (root, members) pairs sorted by root FileId.
Sourcepub fn analysis_inputs_for(
&self,
file_ids: &[FileId],
) -> Vec<(FileId, HirFile, SymbolManifest)>
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.
Sourcepub fn analysis_inputs(&self) -> Vec<(FileId, HirFile, SymbolManifest)>
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.