aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_db/src/input.rs
diff options
context:
space:
mode:
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};