diff options
author | Zac Pullar-Strecker <[email protected]> | 2020-08-24 10:19:53 +0100 |
---|---|---|
committer | Zac Pullar-Strecker <[email protected]> | 2020-08-24 10:20:13 +0100 |
commit | 7bbca7a1b3f9293d2f5cc5745199bc5f8396f2f0 (patch) | |
tree | bdb47765991cb973b2cd5481a088fac636bd326c /crates/ra_hir_expand/src/test_db.rs | |
parent | ca464650eeaca6195891199a93f4f76cf3e7e697 (diff) | |
parent | e65d48d1fb3d4d91d9dc1148a7a836ff5c9a3c87 (diff) |
Merge remote-tracking branch 'upstream/master' into 503-hover-doc-links
Diffstat (limited to 'crates/ra_hir_expand/src/test_db.rs')
-rw-r--r-- | crates/ra_hir_expand/src/test_db.rs | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/crates/ra_hir_expand/src/test_db.rs b/crates/ra_hir_expand/src/test_db.rs deleted file mode 100644 index 332fa556f..000000000 --- a/crates/ra_hir_expand/src/test_db.rs +++ /dev/null | |||
@@ -1,49 +0,0 @@ | |||
1 | //! Database used for testing `hir_expand`. | ||
2 | |||
3 | use std::{ | ||
4 | fmt, panic, | ||
5 | sync::{Arc, Mutex}, | ||
6 | }; | ||
7 | |||
8 | use ra_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate}; | ||
9 | use rustc_hash::FxHashSet; | ||
10 | |||
11 | #[salsa::database( | ||
12 | ra_db::SourceDatabaseExtStorage, | ||
13 | ra_db::SourceDatabaseStorage, | ||
14 | crate::db::AstDatabaseStorage | ||
15 | )] | ||
16 | #[derive(Default)] | ||
17 | pub struct TestDB { | ||
18 | storage: salsa::Storage<TestDB>, | ||
19 | events: Mutex<Option<Vec<salsa::Event>>>, | ||
20 | } | ||
21 | |||
22 | impl fmt::Debug for TestDB { | ||
23 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
24 | f.debug_struct("TestDB").finish() | ||
25 | } | ||
26 | } | ||
27 | |||
28 | impl salsa::Database for TestDB { | ||
29 | fn salsa_event(&self, event: salsa::Event) { | ||
30 | let mut events = self.events.lock().unwrap(); | ||
31 | if let Some(events) = &mut *events { | ||
32 | events.push(event); | ||
33 | } | ||
34 | } | ||
35 | } | ||
36 | |||
37 | impl panic::RefUnwindSafe for TestDB {} | ||
38 | |||
39 | impl FileLoader for TestDB { | ||
40 | fn file_text(&self, file_id: FileId) -> Arc<String> { | ||
41 | FileLoaderDelegate(self).file_text(file_id) | ||
42 | } | ||
43 | fn resolve_path(&self, anchor: FileId, path: &str) -> Option<FileId> { | ||
44 | FileLoaderDelegate(self).resolve_path(anchor, path) | ||
45 | } | ||
46 | fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>> { | ||
47 | FileLoaderDelegate(self).relevant_crates(file_id) | ||
48 | } | ||
49 | } | ||