diff options
author | Aleksey Kladov <[email protected]> | 2020-10-02 14:45:09 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-10-02 15:45:08 +0100 |
commit | 8716c4cec3a05ba891b20b5f28df69d925b913ad (patch) | |
tree | e2f073c459e9a1e1c98b98d524565633524b84c2 /crates/ide/src | |
parent | 700c9bc019346a321d230c51bbea597a497bed84 (diff) |
Move ide::AnalysisChange -> base_db::Change
This seems like a better factoring logically; ideally, clients shouldn't touch
`set_` methods of the database directly. Additionally, I think this
should remove the unfortunate duplication in fixture code.
Diffstat (limited to 'crates/ide/src')
-rw-r--r-- | crates/ide/src/lib.rs | 7 | ||||
-rw-r--r-- | crates/ide/src/mock_analysis.rs | 6 | ||||
-rw-r--r-- | crates/ide/src/parent_module.rs | 4 |
3 files changed, 7 insertions, 10 deletions
diff --git a/crates/ide/src/lib.rs b/crates/ide/src/lib.rs index bab3ec1ff..073b766a5 100644 --- a/crates/ide/src/lib.rs +++ b/crates/ide/src/lib.rs | |||
@@ -87,12 +87,11 @@ pub use assists::{ | |||
87 | utils::MergeBehaviour, Assist, AssistConfig, AssistId, AssistKind, ResolvedAssist, | 87 | utils::MergeBehaviour, Assist, AssistConfig, AssistId, AssistKind, ResolvedAssist, |
88 | }; | 88 | }; |
89 | pub use base_db::{ | 89 | pub use base_db::{ |
90 | Canceled, CrateGraph, CrateId, Edition, FileId, FilePosition, FileRange, SourceRoot, | 90 | Canceled, Change, CrateGraph, CrateId, Edition, FileId, FilePosition, FileRange, SourceRoot, |
91 | SourceRootId, | 91 | SourceRootId, |
92 | }; | 92 | }; |
93 | pub use hir::{Documentation, Semantics}; | 93 | pub use hir::{Documentation, Semantics}; |
94 | pub use ide_db::{ | 94 | pub use ide_db::{ |
95 | change::AnalysisChange, | ||
96 | label::Label, | 95 | label::Label, |
97 | line_index::{LineCol, LineIndex}, | 96 | line_index::{LineCol, LineIndex}, |
98 | search::SearchScope, | 97 | search::SearchScope, |
@@ -141,7 +140,7 @@ impl AnalysisHost { | |||
141 | 140 | ||
142 | /// Applies changes to the current state of the world. If there are | 141 | /// Applies changes to the current state of the world. If there are |
143 | /// outstanding snapshots, they will be canceled. | 142 | /// outstanding snapshots, they will be canceled. |
144 | pub fn apply_change(&mut self, change: AnalysisChange) { | 143 | pub fn apply_change(&mut self, change: Change) { |
145 | self.db.apply_change(change) | 144 | self.db.apply_change(change) |
146 | } | 145 | } |
147 | 146 | ||
@@ -195,7 +194,7 @@ impl Analysis { | |||
195 | file_set.insert(file_id, VfsPath::new_virtual_path("/main.rs".to_string())); | 194 | file_set.insert(file_id, VfsPath::new_virtual_path("/main.rs".to_string())); |
196 | let source_root = SourceRoot::new_local(file_set); | 195 | let source_root = SourceRoot::new_local(file_set); |
197 | 196 | ||
198 | let mut change = AnalysisChange::new(); | 197 | let mut change = Change::new(); |
199 | change.set_roots(vec![source_root]); | 198 | change.set_roots(vec![source_root]); |
200 | let mut crate_graph = CrateGraph::default(); | 199 | let mut crate_graph = CrateGraph::default(); |
201 | // FIXME: cfg options | 200 | // FIXME: cfg options |
diff --git a/crates/ide/src/mock_analysis.rs b/crates/ide/src/mock_analysis.rs index 327cdf91e..6812db9b9 100644 --- a/crates/ide/src/mock_analysis.rs +++ b/crates/ide/src/mock_analysis.rs | |||
@@ -7,9 +7,7 @@ use test_utils::{ | |||
7 | extract_annotations, extract_range_or_offset, Fixture, RangeOrOffset, CURSOR_MARKER, | 7 | extract_annotations, extract_range_or_offset, Fixture, RangeOrOffset, CURSOR_MARKER, |
8 | }; | 8 | }; |
9 | 9 | ||
10 | use crate::{ | 10 | use crate::{Analysis, AnalysisHost, Change, CrateGraph, Edition, FileId, FilePosition, FileRange}; |
11 | Analysis, AnalysisChange, AnalysisHost, CrateGraph, Edition, FileId, FilePosition, FileRange, | ||
12 | }; | ||
13 | 11 | ||
14 | /// Mock analysis is used in test to bootstrap an AnalysisHost/Analysis | 12 | /// Mock analysis is used in test to bootstrap an AnalysisHost/Analysis |
15 | /// from a set of in-memory files. | 13 | /// from a set of in-memory files. |
@@ -95,7 +93,7 @@ impl MockAnalysis { | |||
95 | } | 93 | } |
96 | pub(crate) fn analysis_host(self) -> AnalysisHost { | 94 | pub(crate) fn analysis_host(self) -> AnalysisHost { |
97 | let mut host = AnalysisHost::default(); | 95 | let mut host = AnalysisHost::default(); |
98 | let mut change = AnalysisChange::new(); | 96 | let mut change = Change::new(); |
99 | let mut file_set = FileSet::default(); | 97 | let mut file_set = FileSet::default(); |
100 | let mut crate_graph = CrateGraph::default(); | 98 | let mut crate_graph = CrateGraph::default(); |
101 | let mut root_crate = None; | 99 | let mut root_crate = None; |
diff --git a/crates/ide/src/parent_module.rs b/crates/ide/src/parent_module.rs index 59ed2967c..68b107901 100644 --- a/crates/ide/src/parent_module.rs +++ b/crates/ide/src/parent_module.rs | |||
@@ -69,7 +69,7 @@ mod tests { | |||
69 | 69 | ||
70 | use crate::{ | 70 | use crate::{ |
71 | mock_analysis::{analysis_and_position, MockAnalysis}, | 71 | mock_analysis::{analysis_and_position, MockAnalysis}, |
72 | AnalysisChange, CrateGraph, | 72 | Change, CrateGraph, |
73 | Edition::Edition2018, | 73 | Edition::Edition2018, |
74 | }; | 74 | }; |
75 | 75 | ||
@@ -146,7 +146,7 @@ mod foo; | |||
146 | Env::default(), | 146 | Env::default(), |
147 | Default::default(), | 147 | Default::default(), |
148 | ); | 148 | ); |
149 | let mut change = AnalysisChange::new(); | 149 | let mut change = Change::new(); |
150 | change.set_crate_graph(crate_graph); | 150 | change.set_crate_graph(crate_graph); |
151 | host.apply_change(change); | 151 | host.apply_change(change); |
152 | 152 | ||