aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/db.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_analysis/src/db.rs')
-rw-r--r--crates/ra_analysis/src/db.rs43
1 files changed, 0 insertions, 43 deletions
diff --git a/crates/ra_analysis/src/db.rs b/crates/ra_analysis/src/db.rs
index 7fc3fe31b..df2ef293d 100644
--- a/crates/ra_analysis/src/db.rs
+++ b/crates/ra_analysis/src/db.rs
@@ -1,6 +1,4 @@
1use std::sync::Arc; 1use std::sync::Arc;
2#[cfg(test)]
3use parking_lot::Mutex;
4use salsa::{self, Database}; 2use salsa::{self, Database};
5use ra_db::{LocationIntener, BaseDatabase}; 3use ra_db::{LocationIntener, BaseDatabase};
6use hir::{self, DefId, DefLoc, FnId, SourceItemId}; 4use hir::{self, DefId, DefLoc, FnId, SourceItemId};
@@ -11,11 +9,6 @@ use crate::{
11 9
12#[derive(Debug)] 10#[derive(Debug)]
13pub(crate) struct RootDatabase { 11pub(crate) struct RootDatabase {
14 #[cfg(test)]
15 events: Mutex<Option<Vec<salsa::Event<RootDatabase>>>>,
16 #[cfg(not(test))]
17 events: (),
18
19 runtime: salsa::Runtime<RootDatabase>, 12 runtime: salsa::Runtime<RootDatabase>,
20 id_maps: Arc<IdMaps>, 13 id_maps: Arc<IdMaps>,
21} 14}
@@ -30,23 +23,11 @@ impl salsa::Database for RootDatabase {
30 fn salsa_runtime(&self) -> &salsa::Runtime<RootDatabase> { 23 fn salsa_runtime(&self) -> &salsa::Runtime<RootDatabase> {
31 &self.runtime 24 &self.runtime
32 } 25 }
33
34 #[allow(unused)]
35 fn salsa_event(&self, event: impl Fn() -> salsa::Event<RootDatabase>) {
36 #[cfg(test)]
37 {
38 let mut events = self.events.lock();
39 if let Some(events) = &mut *events {
40 events.push(event());
41 }
42 }
43 }
44} 26}
45 27
46impl Default for RootDatabase { 28impl Default for RootDatabase {
47 fn default() -> RootDatabase { 29 fn default() -> RootDatabase {
48 let mut db = RootDatabase { 30 let mut db = RootDatabase {
49 events: Default::default(),
50 runtime: salsa::Runtime::default(), 31 runtime: salsa::Runtime::default(),
51 id_maps: Default::default(), 32 id_maps: Default::default(),
52 }; 33 };
@@ -63,7 +44,6 @@ impl Default for RootDatabase {
63impl salsa::ParallelDatabase for RootDatabase { 44impl salsa::ParallelDatabase for RootDatabase {
64 fn snapshot(&self) -> salsa::Snapshot<RootDatabase> { 45 fn snapshot(&self) -> salsa::Snapshot<RootDatabase> {
65 salsa::Snapshot::new(RootDatabase { 46 salsa::Snapshot::new(RootDatabase {
66 events: Default::default(),
67 runtime: self.runtime.snapshot(self), 47 runtime: self.runtime.snapshot(self),
68 id_maps: self.id_maps.clone(), 48 id_maps: self.id_maps.clone(),
69 }) 49 })
@@ -84,29 +64,6 @@ impl AsRef<LocationIntener<hir::SourceItemId, FnId>> for RootDatabase {
84 } 64 }
85} 65}
86 66
87#[cfg(test)]
88impl RootDatabase {
89 pub(crate) fn log(&self, f: impl FnOnce()) -> Vec<salsa::Event<RootDatabase>> {
90 *self.events.lock() = Some(Vec::new());
91 f();
92 let events = self.events.lock().take().unwrap();
93 events
94 }
95
96 pub(crate) fn log_executed(&self, f: impl FnOnce()) -> Vec<String> {
97 let events = self.log(f);
98 events
99 .into_iter()
100 .filter_map(|e| match e.kind {
101 // This pretty horrible, but `Debug` is the only way to inspect
102 // QueryDescriptor at the moment.
103 salsa::EventKind::WillExecute { descriptor } => Some(format!("{:?}", descriptor)),
104 _ => None,
105 })
106 .collect()
107 }
108}
109
110salsa::database_storage! { 67salsa::database_storage! {
111 pub(crate) struct RootDatabaseStorage for RootDatabase { 68 pub(crate) struct RootDatabaseStorage for RootDatabase {
112 impl ra_db::FilesDatabase { 69 impl ra_db::FilesDatabase {