diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-02-06 14:01:07 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-02-06 14:01:07 +0000 |
commit | f6cf9393a8327b4c0385bccbc5be84a79bd50057 (patch) | |
tree | 4af15c8906b85de01a15c717bc1fac388952cd3d /crates/ra_hir | |
parent | 736a55c97e69f95e6ff4a0c3dafb2018e8ea05f9 (diff) | |
parent | 0c5fd8f7cbf04eda763e55bc9a38dad5f7ec917d (diff) |
Merge #750
750: Move assists to a separate crate r=matklad a=matklad
I am slowly coming to conclusion that ide_api_light does not make a lot of sense after all :D
This PR moves assists to a separate crate, so that assists can use database (so, inspect types, do name-resolution, etc)
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir')
-rw-r--r-- | crates/ra_hir/src/lib.rs | 3 | ||||
-rw-r--r-- | crates/ra_hir/src/mock.rs | 12 |
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 | ||
20 | pub mod db; | 20 | pub mod db; |
21 | #[cfg(test)] | 21 | pub mod mock; |
22 | mod mock; | ||
23 | mod query_definitions; | 22 | mod query_definitions; |
24 | mod path; | 23 | mod path; |
25 | pub mod source_binder; | 24 | 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); | |||
17 | db::PersistentHirDatabaseStorage | 17 | db::PersistentHirDatabaseStorage |
18 | )] | 18 | )] |
19 | #[derive(Debug)] | 19 | #[derive(Debug)] |
20 | pub(crate) struct MockDatabase { | 20 | pub 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 { | |||
27 | impl panic::RefUnwindSafe for MockDatabase {} | 27 | impl panic::RefUnwindSafe for MockDatabase {} |
28 | 28 | ||
29 | impl MockDatabase { | 29 | impl 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 | ||
168 | impl MockDatabase { | 168 | impl 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() |