aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/test_db.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_ty/src/test_db.rs')
-rw-r--r--crates/ra_hir_ty/src/test_db.rs21
1 files changed, 3 insertions, 18 deletions
diff --git a/crates/ra_hir_ty/src/test_db.rs b/crates/ra_hir_ty/src/test_db.rs
index 0bd29f435..fb8723fb7 100644
--- a/crates/ra_hir_ty/src/test_db.rs
+++ b/crates/ra_hir_ty/src/test_db.rs
@@ -82,7 +82,7 @@ impl FileLoader for TestDB {
82} 82}
83 83
84impl TestDB { 84impl TestDB {
85 pub fn module_for_file(&self, file_id: FileId) -> ModuleId { 85 pub(crate) fn module_for_file(&self, file_id: FileId) -> ModuleId {
86 for &krate in self.relevant_crates(file_id).iter() { 86 for &krate in self.relevant_crates(file_id).iter() {
87 let crate_def_map = self.crate_def_map(krate); 87 let crate_def_map = self.crate_def_map(krate);
88 for (local_id, data) in crate_def_map.modules.iter() { 88 for (local_id, data) in crate_def_map.modules.iter() {
@@ -124,7 +124,7 @@ impl TestDB {
124 } 124 }
125 } 125 }
126 126
127 pub fn diagnostics(&self) -> (String, u32) { 127 pub(crate) fn diagnostics(&self) -> (String, u32) {
128 let mut buf = String::new(); 128 let mut buf = String::new();
129 let mut count = 0; 129 let mut count = 0;
130 self.diag(|d| { 130 self.diag(|d| {
@@ -134,22 +134,7 @@ impl TestDB {
134 (buf, count) 134 (buf, count)
135 } 135 }
136 136
137 /// Like `diagnostics`, but filtered for a single diagnostic. 137 pub(crate) fn extract_annotations(&self) -> FxHashMap<FileId, Vec<(TextRange, String)>> {
138 pub fn diagnostic<D: Diagnostic>(&self) -> (String, u32) {
139 let mut buf = String::new();
140 let mut count = 0;
141 self.diag(|d| {
142 // We want to filter diagnostics by the particular one we are testing for, to
143 // avoid surprising results in tests.
144 if d.downcast_ref::<D>().is_some() {
145 format_to!(buf, "{:?}: {}\n", d.syntax_node(self).text(), d.message());
146 count += 1;
147 };
148 });
149 (buf, count)
150 }
151
152 pub fn extract_annotations(&self) -> FxHashMap<FileId, Vec<(TextRange, String)>> {
153 let mut files = Vec::new(); 138 let mut files = Vec::new();
154 let crate_graph = self.crate_graph(); 139 let crate_graph = self.crate_graph();
155 for krate in crate_graph.iter() { 140 for krate in crate_graph.iter() {