aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_db/src/input.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-01-24 22:56:13 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-01-24 22:56:13 +0000
commitc42db0bbd750fae19a91f0a0354240ea6c3bafce (patch)
treebeb7030248280fd8c67eb2b2c9cc4b19c6074c17 /crates/ra_db/src/input.rs
parentb308375b82a33687f93468d75c7cc628b83a1351 (diff)
parent31d3a56b1865c33ef54e5d76e606965c87676695 (diff)
Merge #623
623: WIP: module id is not def id r=matklad a=matklad This achieves two things: * makes module_tree & item_map per crate, not per source_root * begins the refactoring to remove universal `DefId` in favor of having separate ids for each kind of `Def`. Currently, only modules get a differnt ID though. Co-authored-by: Aleksey Kladov <[email protected]>
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};