aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_expand/src/test_db.rs
diff options
context:
space:
mode:
authorZac Pullar-Strecker <[email protected]>2020-08-24 10:19:53 +0100
committerZac Pullar-Strecker <[email protected]>2020-08-24 10:20:13 +0100
commit7bbca7a1b3f9293d2f5cc5745199bc5f8396f2f0 (patch)
treebdb47765991cb973b2cd5481a088fac636bd326c /crates/ra_hir_expand/src/test_db.rs
parentca464650eeaca6195891199a93f4f76cf3e7e697 (diff)
parente65d48d1fb3d4d91d9dc1148a7a836ff5c9a3c87 (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.rs49
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
3use std::{
4 fmt, panic,
5 sync::{Arc, Mutex},
6};
7
8use ra_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate};
9use rustc_hash::FxHashSet;
10
11#[salsa::database(
12 ra_db::SourceDatabaseExtStorage,
13 ra_db::SourceDatabaseStorage,
14 crate::db::AstDatabaseStorage
15)]
16#[derive(Default)]
17pub struct TestDB {
18 storage: salsa::Storage<TestDB>,
19 events: Mutex<Option<Vec<salsa::Event>>>,
20}
21
22impl fmt::Debug for TestDB {
23 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
24 f.debug_struct("TestDB").finish()
25 }
26}
27
28impl 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
37impl panic::RefUnwindSafe for TestDB {}
38
39impl 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}