aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
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_hir
parentae97cd59ff086e7efb6409f14c2f8ae8861596e4 (diff)
:arrow_up salsa
Diffstat (limited to 'crates/ra_hir')
-rw-r--r--crates/ra_hir/Cargo.toml2
-rw-r--r--crates/ra_hir/src/mock.rs50
2 files changed, 7 insertions, 45 deletions
diff --git a/crates/ra_hir/Cargo.toml b/crates/ra_hir/Cargo.toml
index 86937ccd8..3d802ade4 100644
--- a/crates/ra_hir/Cargo.toml
+++ b/crates/ra_hir/Cargo.toml
@@ -12,6 +12,8 @@ rustc-hash = "1.0"
12parking_lot = "0.7.0" 12parking_lot = "0.7.0"
13ena = "0.11" 13ena = "0.11"
14join_to_string = "0.1.3" 14join_to_string = "0.1.3"
15salsa = "0.10.0-alpha3"
16
15ra_syntax = { path = "../ra_syntax" } 17ra_syntax = { path = "../ra_syntax" }
16ra_arena = { path = "../ra_arena" } 18ra_arena = { path = "../ra_arena" }
17ra_db = { path = "../ra_db" } 19ra_db = { path = "../ra_db" }
diff --git a/crates/ra_hir/src/mock.rs b/crates/ra_hir/src/mock.rs
index 1a83a5c87..aa54336b8 100644
--- a/crates/ra_hir/src/mock.rs
+++ b/crates/ra_hir/src/mock.rs
@@ -12,6 +12,7 @@ use crate::{db, HirInterner};
12 12
13pub const WORKSPACE: SourceRootId = SourceRootId(0); 13pub const WORKSPACE: SourceRootId = SourceRootId(0);
14 14
15#[salsa::database(ra_db::FilesDatabase, ra_db::SyntaxDatabase, db::HirDatabase)]
15#[derive(Debug)] 16#[derive(Debug)]
16pub(crate) struct MockDatabase { 17pub(crate) struct MockDatabase {
17 events: Mutex<Option<Vec<salsa::Event<MockDatabase>>>>, 18 events: Mutex<Option<Vec<salsa::Event<MockDatabase>>>>,
@@ -181,8 +182,7 @@ impl MockDatabase {
181 pub(crate) fn log(&self, f: impl FnOnce()) -> Vec<salsa::Event<MockDatabase>> { 182 pub(crate) fn log(&self, f: impl FnOnce()) -> Vec<salsa::Event<MockDatabase>> {
182 *self.events.lock() = Some(Vec::new()); 183 *self.events.lock() = Some(Vec::new());
183 f(); 184 f();
184 let events = self.events.lock().take().unwrap(); 185 self.events.lock().take().unwrap()
185 events
186 } 186 }
187 187
188 pub(crate) fn log_executed(&self, f: impl FnOnce()) -> Vec<String> { 188 pub(crate) fn log_executed(&self, f: impl FnOnce()) -> Vec<String> {
@@ -192,51 +192,11 @@ impl MockDatabase {
192 .filter_map(|e| match e.kind { 192 .filter_map(|e| match e.kind {
193 // This pretty horrible, but `Debug` is the only way to inspect 193 // This pretty horrible, but `Debug` is the only way to inspect
194 // QueryDescriptor at the moment. 194 // QueryDescriptor at the moment.
195 salsa::EventKind::WillExecute { descriptor } => Some(format!("{:?}", descriptor)), 195 salsa::EventKind::WillExecute { database_key } => {
196 Some(format!("{:?}", database_key))
197 }
196 _ => None, 198 _ => None,
197 }) 199 })
198 .collect() 200 .collect()
199 } 201 }
200} 202}
201
202salsa::database_storage! {
203 pub(crate) struct MockDatabaseStorage for MockDatabase {
204 impl ra_db::FilesDatabase {
205 fn file_text() for ra_db::FileTextQuery;
206 fn file_relative_path() for ra_db::FileRelativePathQuery;
207 fn file_source_root() for ra_db::FileSourceRootQuery;
208 fn source_root() for ra_db::SourceRootQuery;
209 fn source_root_crates() for ra_db::SourceRootCratesQuery;
210 fn local_roots() for ra_db::LocalRootsQuery;
211 fn library_roots() for ra_db::LibraryRootsQuery;
212 fn crate_graph() for ra_db::CrateGraphQuery;
213 }
214 impl ra_db::SyntaxDatabase {
215 fn source_file() for ra_db::SourceFileQuery;
216 }
217 impl db::HirDatabase {
218 fn hir_source_file() for db::HirSourceFileQuery;
219 fn expand_macro_invocation() for db::ExpandMacroInvocationQuery;
220 fn module_tree() for db::ModuleTreeQuery;
221 fn fn_scopes() for db::FnScopesQuery;
222 fn file_items() for db::FileItemsQuery;
223 fn file_item() for db::FileItemQuery;
224 fn lower_module() for db::LowerModuleQuery;
225 fn lower_module_module() for db::LowerModuleModuleQuery;
226 fn lower_module_source_map() for db::LowerModuleSourceMapQuery;
227 fn item_map() for db::ItemMapQuery;
228 fn submodules() for db::SubmodulesQuery;
229 fn infer() for db::InferQuery;
230 fn type_for_def() for db::TypeForDefQuery;
231 fn type_for_field() for db::TypeForFieldQuery;
232 fn struct_data() for db::StructDataQuery;
233 fn enum_data() for db::EnumDataQuery;
234 fn impls_in_module() for db::ImplsInModuleQuery;
235 fn impls_in_crate() for db::ImplsInCrateQuery;
236 fn body_hir() for db::BodyHirQuery;
237 fn body_syntax_mapping() for db::BodySyntaxMappingQuery;
238 fn fn_signature() for db::FnSignatureQuery;
239 fn generic_params() for db::GenericParamsQuery;
240 }
241 }
242}