From 0c5fd8f7cbf04eda763e55bc9a38dad5f7ec917d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 3 Feb 2019 21:26:35 +0300 Subject: move assists to a separate crate --- crates/ra_hir/src/lib.rs | 3 +-- crates/ra_hir/src/mock.rs | 12 ++++++------ 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'crates/ra_hir/src') 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 { } pub mod db; -#[cfg(test)] -mod mock; +pub mod mock; mod query_definitions; mod path; pub 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); db::PersistentHirDatabaseStorage )] #[derive(Debug)] -pub(crate) struct MockDatabase { +pub struct MockDatabase { events: Mutex>>>, runtime: salsa::Runtime, interner: Arc, @@ -27,13 +27,13 @@ pub(crate) struct MockDatabase { impl panic::RefUnwindSafe for MockDatabase {} impl MockDatabase { - pub(crate) fn with_files(fixture: &str) -> (MockDatabase, SourceRoot) { + pub fn with_files(fixture: &str) -> (MockDatabase, SourceRoot) { let (db, source_root, position) = MockDatabase::from_fixture(fixture); assert!(position.is_none()); (db, source_root) } - pub(crate) fn with_single_file(text: &str) -> (MockDatabase, SourceRoot, FileId) { + pub fn with_single_file(text: &str) -> (MockDatabase, SourceRoot, FileId) { let mut db = MockDatabase::default(); let mut source_root = SourceRoot::default(); let file_id = db.add_file(WORKSPACE, &mut source_root, "/main.rs", text); @@ -41,7 +41,7 @@ impl MockDatabase { (db, source_root, file_id) } - pub(crate) fn with_position(fixture: &str) -> (MockDatabase, FilePosition) { + pub fn with_position(fixture: &str) -> (MockDatabase, FilePosition) { let (db, _, position) = MockDatabase::from_fixture(fixture); let position = position.expect("expected a marker ( <|> )"); (db, position) @@ -166,13 +166,13 @@ impl AsRef for MockDatabase { } impl MockDatabase { - pub(crate) fn log(&self, f: impl FnOnce()) -> Vec> { + pub fn log(&self, f: impl FnOnce()) -> Vec> { *self.events.lock() = Some(Vec::new()); f(); self.events.lock().take().unwrap() } - pub(crate) fn log_executed(&self, f: impl FnOnce()) -> Vec { + pub fn log_executed(&self, f: impl FnOnce()) -> Vec { let events = self.log(f); events .into_iter() -- cgit v1.2.3