aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-02-03 18:26:35 +0000
committerAleksey Kladov <[email protected]>2019-02-06 14:00:00 +0000
commit0c5fd8f7cbf04eda763e55bc9a38dad5f7ec917d (patch)
tree4af15c8906b85de01a15c717bc1fac388952cd3d /crates/ra_hir/src
parent736a55c97e69f95e6ff4a0c3dafb2018e8ea05f9 (diff)
move assists to a separate crate
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/lib.rs3
-rw-r--r--crates/ra_hir/src/mock.rs12
2 files changed, 7 insertions, 8 deletions
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs
index 54da55598..a9cd955cf 100644
--- a/crates/ra_hir/src/lib.rs
+++ b/crates/ra_hir/src/lib.rs
@@ -18,8 +18,7 @@ macro_rules! impl_froms {
18} 18}
19 19
20pub mod db; 20pub mod db;
21#[cfg(test)] 21pub mod mock;
22mod mock;
23mod query_definitions; 22mod query_definitions;
24mod path; 23mod path;
25pub mod source_binder; 24pub mod source_binder;
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()