mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
Change ids strategy
this is a part of larghish hir refactoring which aims to * replace per-source-root module trees with per crate trees * switch from a monotyped DedId to type-specific ids
This commit is contained in:
parent
cfb085ded8
commit
3ab1519cb2
26 changed files with 365 additions and 430 deletions
|
@ -160,6 +160,7 @@ pub trait FilesDatabase: salsa::Database {
|
|||
/// Contents of the source root.
|
||||
#[salsa::input]
|
||||
fn source_root(&self, id: SourceRootId) -> Arc<SourceRoot>;
|
||||
fn source_root_crates(&self, id: SourceRootId) -> Arc<Vec<CrateId>>;
|
||||
/// The set of "local" (that is, from the current workspace) roots.
|
||||
/// Files in local roots are assumed to change frequently.
|
||||
#[salsa::input]
|
||||
|
@ -173,6 +174,17 @@ pub trait FilesDatabase: salsa::Database {
|
|||
fn crate_graph(&self) -> Arc<CrateGraph>;
|
||||
}
|
||||
|
||||
fn source_root_crates(db: &impl FilesDatabase, id: SourceRootId) -> Arc<Vec<CrateId>> {
|
||||
let root = db.source_root(id);
|
||||
let graph = db.crate_graph();
|
||||
let res = root
|
||||
.files
|
||||
.values()
|
||||
.filter_map(|&it| graph.crate_id_for_crate_root(it))
|
||||
.collect::<Vec<_>>();
|
||||
Arc::new(res)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{CrateGraph, FileId, SmolStr};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue