aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_db/src/input.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-01-23 20:14:13 +0000
committerAleksey Kladov <[email protected]>2019-01-24 10:29:19 +0000
commit3ab1519cb27b927074ed7fbbb18a856e6e7fabb8 (patch)
tree692c7a256604e188d38890966290bd1637d7dd60 /crates/ra_db/src/input.rs
parentcfb085ded8d61d7b744d0a83ecbb3da254f6ab9f (diff)
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
Diffstat (limited to 'crates/ra_db/src/input.rs')
-rw-r--r--crates/ra_db/src/input.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs
index b5d63e820..9825d52cf 100644
--- a/crates/ra_db/src/input.rs
+++ b/crates/ra_db/src/input.rs
@@ -160,6 +160,7 @@ pub trait FilesDatabase: salsa::Database {
160 /// Contents of the source root. 160 /// Contents of the source root.
161 #[salsa::input] 161 #[salsa::input]
162 fn source_root(&self, id: SourceRootId) -> Arc<SourceRoot>; 162 fn source_root(&self, id: SourceRootId) -> Arc<SourceRoot>;
163 fn source_root_crates(&self, id: SourceRootId) -> Arc<Vec<CrateId>>;
163 /// The set of "local" (that is, from the current workspace) roots. 164 /// The set of "local" (that is, from the current workspace) roots.
164 /// Files in local roots are assumed to change frequently. 165 /// Files in local roots are assumed to change frequently.
165 #[salsa::input] 166 #[salsa::input]
@@ -173,6 +174,17 @@ pub trait FilesDatabase: salsa::Database {
173 fn crate_graph(&self) -> Arc<CrateGraph>; 174 fn crate_graph(&self) -> Arc<CrateGraph>;
174} 175}
175 176
177fn source_root_crates(db: &impl FilesDatabase, id: SourceRootId) -> Arc<Vec<CrateId>> {
178 let root = db.source_root(id);
179 let graph = db.crate_graph();
180 let res = root
181 .files
182 .values()
183 .filter_map(|&it| graph.crate_id_for_crate_root(it))
184 .collect::<Vec<_>>();
185 Arc::new(res)
186}
187
176#[cfg(test)] 188#[cfg(test)]
177mod tests { 189mod tests {
178 use super::{CrateGraph, FileId, SmolStr}; 190 use super::{CrateGraph, FileId, SmolStr};