aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_db/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_db/src')
-rw-r--r--crates/ra_db/src/input.rs12
-rw-r--r--crates/ra_db/src/lib.rs2
2 files changed, 13 insertions, 1 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};
diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs
index 32d7e09b9..84759c75a 100644
--- a/crates/ra_db/src/lib.rs
+++ b/crates/ra_db/src/lib.rs
@@ -13,7 +13,7 @@ pub use crate::{
13 cancellation::Canceled, 13 cancellation::Canceled,
14 input::{ 14 input::{
15 FilesDatabase, FileId, CrateId, SourceRoot, SourceRootId, CrateGraph, Dependency, 15 FilesDatabase, FileId, CrateId, SourceRoot, SourceRootId, CrateGraph, Dependency,
16 FileTextQuery, FileSourceRootQuery, SourceRootQuery, LocalRootsQuery, LibraryRootsQuery, CrateGraphQuery, 16 FileTextQuery, FileSourceRootQuery, SourceRootQuery, SourceRootCratesQuery, LocalRootsQuery, LibraryRootsQuery, CrateGraphQuery,
17 FileRelativePathQuery 17 FileRelativePathQuery
18 }, 18 },
19 loc2id::LocationIntener, 19 loc2id::LocationIntener,