diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-25 12:34:10 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-25 12:34:10 +0000 |
commit | 021e691997efc35c983808ee3470a060a3ec3e96 (patch) | |
tree | a3f49352542d3c6803e318cd2f155cc4543062c5 /crates/ra_db/src/input.rs | |
parent | 04ce89313369a1606b057b3be1368d72b8a5cd63 (diff) | |
parent | 08c12e424d5d3fb4e11f081a07b9c265dc7a96b6 (diff) |
Merge #639
639: Update salsa r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_db/src/input.rs')
-rw-r--r-- | crates/ra_db/src/input.rs | 42 |
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. |
8 | use std::sync::Arc; | ||
9 | |||
10 | use relative_path::RelativePathBuf; | 8 | use relative_path::RelativePathBuf; |
11 | use rustc_hash::FxHashMap; | 9 | use rustc_hash::FxHashMap; |
12 | use salsa; | ||
13 | 10 | ||
14 | use ra_syntax::SmolStr; | 11 | use ra_syntax::SmolStr; |
15 | use rustc_hash::FxHashSet; | 12 | use rustc_hash::FxHashSet; |
@@ -146,45 +143,6 @@ impl CrateGraph { | |||
146 | } | 143 | } |
147 | } | 144 | } |
148 | 145 | ||
149 | #[salsa::query_group] | ||
150 | pub 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 | |||
177 | fn 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)] |
189 | mod tests { | 147 | mod tests { |
190 | use super::{CrateGraph, FileId, SmolStr}; | 148 | use super::{CrateGraph, FileId, SmolStr}; |