diff options
author | Aleksey Kladov <[email protected]> | 2019-11-04 19:19:06 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-11-04 19:19:06 +0000 |
commit | 7649a8ebbe900f43cc9b8789c2942cfbadab8f1c (patch) | |
tree | 42418245aea7df068317b427cbdb3c50c3f53208 /crates | |
parent | 24894aca3162d654ee051f591a920ef1525d821f (diff) |
remove dead code
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_hir/src/mock.rs | 33 |
1 files changed, 7 insertions, 26 deletions
diff --git a/crates/ra_hir/src/mock.rs b/crates/ra_hir/src/mock.rs index 94aff93de..ff1f3fa75 100644 --- a/crates/ra_hir/src/mock.rs +++ b/crates/ra_hir/src/mock.rs | |||
@@ -9,7 +9,6 @@ use ra_db::{ | |||
9 | salsa, CrateId, FileId, FileLoader, FileLoaderDelegate, RelativePath, SourceDatabase, | 9 | salsa, CrateId, FileId, FileLoader, FileLoaderDelegate, RelativePath, SourceDatabase, |
10 | SourceRootId, | 10 | SourceRootId, |
11 | }; | 11 | }; |
12 | use rustc_hash::FxHashMap; | ||
13 | 12 | ||
14 | use crate::{db, debug::HirDebugHelper}; | 13 | use crate::{db, debug::HirDebugHelper}; |
15 | 14 | ||
@@ -28,9 +27,6 @@ pub const WORKSPACE: SourceRootId = SourceRootId(0); | |||
28 | pub struct MockDatabase { | 27 | pub struct MockDatabase { |
29 | events: Mutex<Option<Vec<salsa::Event<MockDatabase>>>>, | 28 | events: Mutex<Option<Vec<salsa::Event<MockDatabase>>>>, |
30 | runtime: salsa::Runtime<MockDatabase>, | 29 | runtime: salsa::Runtime<MockDatabase>, |
31 | files: FxHashMap<String, FileId>, | ||
32 | crate_names: Arc<FxHashMap<CrateId, String>>, | ||
33 | file_paths: Arc<FxHashMap<FileId, String>>, | ||
34 | } | 30 | } |
35 | 31 | ||
36 | impl panic::RefUnwindSafe for MockDatabase {} | 32 | impl panic::RefUnwindSafe for MockDatabase {} |
@@ -51,24 +47,18 @@ impl FileLoader for MockDatabase { | |||
51 | } | 47 | } |
52 | } | 48 | } |
53 | 49 | ||
50 | // FIXME: improve `WithFixture` to bring useful hir debugging back | ||
54 | impl HirDebugHelper for MockDatabase { | 51 | impl HirDebugHelper for MockDatabase { |
55 | fn crate_name(&self, krate: CrateId) -> Option<String> { | 52 | fn crate_name(&self, _krate: CrateId) -> Option<String> { |
56 | self.crate_names.get(&krate).cloned() | 53 | None |
57 | } | 54 | } |
58 | 55 | ||
59 | fn file_path(&self, file_id: FileId) -> Option<String> { | 56 | fn file_path(&self, _file_id: FileId) -> Option<String> { |
60 | self.file_paths.get(&file_id).cloned() | 57 | None |
61 | } | 58 | } |
62 | } | 59 | } |
63 | 60 | ||
64 | impl MockDatabase { | 61 | impl MockDatabase { |
65 | pub fn file_id_of(&self, path: &str) -> FileId { | ||
66 | match self.files.get(path) { | ||
67 | Some(it) => *it, | ||
68 | None => panic!("unknown file: {:?}\nexisting files:\n{:#?}", path, self.files), | ||
69 | } | ||
70 | } | ||
71 | |||
72 | pub fn diagnostics(&self) -> String { | 62 | pub fn diagnostics(&self) -> String { |
73 | let mut buf = String::new(); | 63 | let mut buf = String::new(); |
74 | let crate_graph = self.crate_graph(); | 64 | let crate_graph = self.crate_graph(); |
@@ -104,13 +94,8 @@ impl salsa::Database for MockDatabase { | |||
104 | 94 | ||
105 | impl Default for MockDatabase { | 95 | impl Default for MockDatabase { |
106 | fn default() -> MockDatabase { | 96 | fn default() -> MockDatabase { |
107 | let mut db = MockDatabase { | 97 | let mut db = |
108 | events: Default::default(), | 98 | MockDatabase { events: Default::default(), runtime: salsa::Runtime::default() }; |
109 | runtime: salsa::Runtime::default(), | ||
110 | files: FxHashMap::default(), | ||
111 | crate_names: Default::default(), | ||
112 | file_paths: Default::default(), | ||
113 | }; | ||
114 | db.set_crate_graph(Default::default()); | 99 | db.set_crate_graph(Default::default()); |
115 | db | 100 | db |
116 | } | 101 | } |
@@ -121,10 +106,6 @@ impl salsa::ParallelDatabase for MockDatabase { | |||
121 | salsa::Snapshot::new(MockDatabase { | 106 | salsa::Snapshot::new(MockDatabase { |
122 | events: Default::default(), | 107 | events: Default::default(), |
123 | runtime: self.runtime.snapshot(self), | 108 | runtime: self.runtime.snapshot(self), |
124 | // only the root database can be used to get file_id by path. | ||
125 | files: FxHashMap::default(), | ||
126 | file_paths: Arc::clone(&self.file_paths), | ||
127 | crate_names: Arc::clone(&self.crate_names), | ||
128 | }) | 109 | }) |
129 | } | 110 | } |
130 | } | 111 | } |