aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_db/src/input.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-01-25 12:16:50 +0000
committerAleksey Kladov <[email protected]>2019-01-25 12:16:50 +0000
commit8cf092d5de113fc218b84421a2db4449a370ccb6 (patch)
tree8fe4173465c56a0ce4dc68ee4b43ef8f7c1293de /crates/ra_db/src/input.rs
parentae97cd59ff086e7efb6409f14c2f8ae8861596e4 (diff)
:arrow_up salsa
Diffstat (limited to 'crates/ra_db/src/input.rs')
-rw-r--r--crates/ra_db/src/input.rs42
1 files changed, 0 insertions, 42 deletions
diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs
index 9825d52cf..275894252 100644
--- a/crates/ra_db/src/input.rs
+++ b/crates/ra_db/src/input.rs
@@ -5,11 +5,8 @@
5/// Note that neither this module, nor any other part of the analyzer's core do 5/// Note that neither this module, nor any other part of the analyzer's core do
6/// actual IO. See `vfs` and `project_model` in the `ra_lsp_server` crate for how 6/// actual IO. See `vfs` and `project_model` in the `ra_lsp_server` crate for how
7/// actual IO is done and lowered to input. 7/// actual IO is done and lowered to input.
8use std::sync::Arc;
9
10use relative_path::RelativePathBuf; 8use relative_path::RelativePathBuf;
11use rustc_hash::FxHashMap; 9use rustc_hash::FxHashMap;
12use salsa;
13 10
14use ra_syntax::SmolStr; 11use ra_syntax::SmolStr;
15use rustc_hash::FxHashSet; 12use rustc_hash::FxHashSet;
@@ -146,45 +143,6 @@ impl CrateGraph {
146 } 143 }
147} 144}
148 145
149#[salsa::query_group]
150pub trait FilesDatabase: salsa::Database {
151 /// Text of the file.
152 #[salsa::input]
153 fn file_text(&self, file_id: FileId) -> Arc<String>;
154 /// Path to a file, relative to the root of its source root.
155 #[salsa::input]
156 fn file_relative_path(&self, file_id: FileId) -> RelativePathBuf;
157 /// Source root of the file.
158 #[salsa::input]
159 fn file_source_root(&self, file_id: FileId) -> SourceRootId;
160 /// Contents of the source root.
161 #[salsa::input]
162 fn source_root(&self, id: SourceRootId) -> Arc<SourceRoot>;
163 fn source_root_crates(&self, id: SourceRootId) -> Arc<Vec<CrateId>>;
164 /// The set of "local" (that is, from the current workspace) roots.
165 /// Files in local roots are assumed to change frequently.
166 #[salsa::input]
167 fn local_roots(&self) -> Arc<Vec<SourceRootId>>;
168 /// The set of roots for crates.io libraries.
169 /// Files in libraries are assumed to never change.
170 #[salsa::input]
171 fn library_roots(&self) -> Arc<Vec<SourceRootId>>;
172 /// The crate graph.
173 #[salsa::input]
174 fn crate_graph(&self) -> Arc<CrateGraph>;
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
188#[cfg(test)] 146#[cfg(test)]
189mod tests { 147mod tests {
190 use super::{CrateGraph, FileId, SmolStr}; 148 use super::{CrateGraph, FileId, SmolStr};