aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/mock.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/mock.rs')
-rw-r--r--crates/ra_hir/src/mock.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/crates/ra_hir/src/mock.rs b/crates/ra_hir/src/mock.rs
index 00a07d1a1..87095fb21 100644
--- a/crates/ra_hir/src/mock.rs
+++ b/crates/ra_hir/src/mock.rs
@@ -17,7 +17,7 @@ pub const WORKSPACE: SourceRootId = SourceRootId(0);
17 db::PersistentHirDatabaseStorage 17 db::PersistentHirDatabaseStorage
18)] 18)]
19#[derive(Debug)] 19#[derive(Debug)]
20pub(crate) struct MockDatabase { 20pub struct MockDatabase {
21 events: Mutex<Option<Vec<salsa::Event<MockDatabase>>>>, 21 events: Mutex<Option<Vec<salsa::Event<MockDatabase>>>>,
22 runtime: salsa::Runtime<MockDatabase>, 22 runtime: salsa::Runtime<MockDatabase>,
23 interner: Arc<HirInterner>, 23 interner: Arc<HirInterner>,
@@ -27,13 +27,13 @@ pub(crate) struct MockDatabase {
27impl panic::RefUnwindSafe for MockDatabase {} 27impl panic::RefUnwindSafe for MockDatabase {}
28 28
29impl MockDatabase { 29impl MockDatabase {
30 pub(crate) fn with_files(fixture: &str) -> (MockDatabase, SourceRoot) { 30 pub fn with_files(fixture: &str) -> (MockDatabase, SourceRoot) {
31 let (db, source_root, position) = MockDatabase::from_fixture(fixture); 31 let (db, source_root, position) = MockDatabase::from_fixture(fixture);
32 assert!(position.is_none()); 32 assert!(position.is_none());
33 (db, source_root) 33 (db, source_root)
34 } 34 }
35 35
36 pub(crate) fn with_single_file(text: &str) -> (MockDatabase, SourceRoot, FileId) { 36 pub fn with_single_file(text: &str) -> (MockDatabase, SourceRoot, FileId) {
37 let mut db = MockDatabase::default(); 37 let mut db = MockDatabase::default();
38 let mut source_root = SourceRoot::default(); 38 let mut source_root = SourceRoot::default();
39 let file_id = db.add_file(WORKSPACE, &mut source_root, "/main.rs", text); 39 let file_id = db.add_file(WORKSPACE, &mut source_root, "/main.rs", text);
@@ -41,7 +41,7 @@ impl MockDatabase {
41 (db, source_root, file_id) 41 (db, source_root, file_id)
42 } 42 }
43 43
44 pub(crate) fn with_position(fixture: &str) -> (MockDatabase, FilePosition) { 44 pub fn with_position(fixture: &str) -> (MockDatabase, FilePosition) {
45 let (db, _, position) = MockDatabase::from_fixture(fixture); 45 let (db, _, position) = MockDatabase::from_fixture(fixture);
46 let position = position.expect("expected a marker ( <|> )"); 46 let position = position.expect("expected a marker ( <|> )");
47 (db, position) 47 (db, position)
@@ -166,13 +166,13 @@ impl AsRef<HirInterner> for MockDatabase {
166} 166}
167 167
168impl MockDatabase { 168impl MockDatabase {
169 pub(crate) fn log(&self, f: impl FnOnce()) -> Vec<salsa::Event<MockDatabase>> { 169 pub fn log(&self, f: impl FnOnce()) -> Vec<salsa::Event<MockDatabase>> {
170 *self.events.lock() = Some(Vec::new()); 170 *self.events.lock() = Some(Vec::new());
171 f(); 171 f();
172 self.events.lock().take().unwrap() 172 self.events.lock().take().unwrap()
173 } 173 }
174 174
175 pub(crate) fn log_executed(&self, f: impl FnOnce()) -> Vec<String> { 175 pub fn log_executed(&self, f: impl FnOnce()) -> Vec<String> {
176 let events = self.log(f); 176 let events = self.log(f);
177 events 177 events
178 .into_iter() 178 .into_iter()