diff options
author | Aleksey Kladov <[email protected]> | 2018-11-28 13:25:56 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-11-28 13:25:56 +0000 |
commit | af7a0596f67cabe7031297cf474b761d863bd108 (patch) | |
tree | de4c214620f974b0aea58e4a55067e7f2e51fa5e /crates | |
parent | d30bbfda74346c5007174d8bda93e9583c166a4c (diff) |
remove useless test hooks
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_analysis/src/db.rs | 43 |
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 @@ | |||
1 | use std::sync::Arc; | 1 | use std::sync::Arc; |
2 | #[cfg(test)] | ||
3 | use parking_lot::Mutex; | ||
4 | use salsa::{self, Database}; | 2 | use salsa::{self, Database}; |
5 | use ra_db::{LocationIntener, BaseDatabase}; | 3 | use ra_db::{LocationIntener, BaseDatabase}; |
6 | use hir::{self, DefId, DefLoc, FnId, SourceItemId}; | 4 | use hir::{self, DefId, DefLoc, FnId, SourceItemId}; |
@@ -11,11 +9,6 @@ use crate::{ | |||
11 | 9 | ||
12 | #[derive(Debug)] | 10 | #[derive(Debug)] |
13 | pub(crate) struct RootDatabase { | 11 | pub(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 | ||
46 | impl Default for RootDatabase { | 28 | impl 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 { | |||
63 | impl salsa::ParallelDatabase for RootDatabase { | 44 | impl 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)] | ||
88 | impl 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 | |||
110 | salsa::database_storage! { | 67 | salsa::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 { |