aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src/test_db.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_def/src/test_db.rs')
-rw-r--r--crates/hir_def/src/test_db.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/crates/hir_def/src/test_db.rs b/crates/hir_def/src/test_db.rs
index 2b36c824a..00fe711fe 100644
--- a/crates/hir_def/src/test_db.rs
+++ b/crates/hir_def/src/test_db.rs
@@ -25,7 +25,7 @@ use crate::{db::DefDatabase, ModuleDefId};
25 crate::db::DefDatabaseStorage 25 crate::db::DefDatabaseStorage
26)] 26)]
27#[derive(Default)] 27#[derive(Default)]
28pub struct TestDB { 28pub(crate) struct TestDB {
29 storage: salsa::Storage<TestDB>, 29 storage: salsa::Storage<TestDB>,
30 events: Mutex<Option<Vec<salsa::Event>>>, 30 events: Mutex<Option<Vec<salsa::Event>>>,
31} 31}
@@ -72,7 +72,7 @@ impl FileLoader for TestDB {
72} 72}
73 73
74impl TestDB { 74impl TestDB {
75 pub fn module_for_file(&self, file_id: FileId) -> crate::ModuleId { 75 pub(crate) fn module_for_file(&self, file_id: FileId) -> crate::ModuleId {
76 for &krate in self.relevant_crates(file_id).iter() { 76 for &krate in self.relevant_crates(file_id).iter() {
77 let crate_def_map = self.crate_def_map(krate); 77 let crate_def_map = self.crate_def_map(krate);
78 for (local_id, data) in crate_def_map.modules.iter() { 78 for (local_id, data) in crate_def_map.modules.iter() {
@@ -84,13 +84,13 @@ impl TestDB {
84 panic!("Can't find module for file") 84 panic!("Can't find module for file")
85 } 85 }
86 86
87 pub fn log(&self, f: impl FnOnce()) -> Vec<salsa::Event> { 87 pub(crate) fn log(&self, f: impl FnOnce()) -> Vec<salsa::Event> {
88 *self.events.lock().unwrap() = Some(Vec::new()); 88 *self.events.lock().unwrap() = Some(Vec::new());
89 f(); 89 f();
90 self.events.lock().unwrap().take().unwrap() 90 self.events.lock().unwrap().take().unwrap()
91 } 91 }
92 92
93 pub fn log_executed(&self, f: impl FnOnce()) -> Vec<String> { 93 pub(crate) fn log_executed(&self, f: impl FnOnce()) -> Vec<String> {
94 let events = self.log(f); 94 let events = self.log(f);
95 events 95 events
96 .into_iter() 96 .into_iter()
@@ -105,7 +105,7 @@ impl TestDB {
105 .collect() 105 .collect()
106 } 106 }
107 107
108 pub fn extract_annotations(&self) -> FxHashMap<FileId, Vec<(TextRange, String)>> { 108 pub(crate) fn extract_annotations(&self) -> FxHashMap<FileId, Vec<(TextRange, String)>> {
109 let mut files = Vec::new(); 109 let mut files = Vec::new();
110 let crate_graph = self.crate_graph(); 110 let crate_graph = self.crate_graph();
111 for krate in crate_graph.iter() { 111 for krate in crate_graph.iter() {
@@ -129,7 +129,7 @@ impl TestDB {
129 .collect() 129 .collect()
130 } 130 }
131 131
132 pub fn diagnostics<F: FnMut(&dyn Diagnostic)>(&self, mut cb: F) { 132 pub(crate) fn diagnostics<F: FnMut(&dyn Diagnostic)>(&self, mut cb: F) {
133 let crate_graph = self.crate_graph(); 133 let crate_graph = self.crate_graph();
134 for krate in crate_graph.iter() { 134 for krate in crate_graph.iter() {
135 let crate_def_map = self.crate_def_map(krate); 135 let crate_def_map = self.crate_def_map(krate);
@@ -148,7 +148,7 @@ impl TestDB {
148 } 148 }
149 } 149 }
150 150
151 pub fn check_diagnostics(&self) { 151 pub(crate) fn check_diagnostics(&self) {
152 let db: &TestDB = self; 152 let db: &TestDB = self;
153 let annotations = db.extract_annotations(); 153 let annotations = db.extract_annotations();
154 assert!(!annotations.is_empty()); 154 assert!(!annotations.is_empty());