From 8716c4cec3a05ba891b20b5f28df69d925b913ad Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 2 Oct 2020 15:45:09 +0200 Subject: 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. --- crates/ide/src/lib.rs | 7 +++---- crates/ide/src/mock_analysis.rs | 6 ++---- crates/ide/src/parent_module.rs | 4 ++-- 3 files changed, 7 insertions(+), 10 deletions(-) (limited to 'crates/ide/src') 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::{ utils::MergeBehaviour, Assist, AssistConfig, AssistId, AssistKind, ResolvedAssist, }; pub use base_db::{ - Canceled, CrateGraph, CrateId, Edition, FileId, FilePosition, FileRange, SourceRoot, + Canceled, Change, CrateGraph, CrateId, Edition, FileId, FilePosition, FileRange, SourceRoot, SourceRootId, }; pub use hir::{Documentation, Semantics}; pub use ide_db::{ - change::AnalysisChange, label::Label, line_index::{LineCol, LineIndex}, search::SearchScope, @@ -141,7 +140,7 @@ impl AnalysisHost { /// Applies changes to the current state of the world. If there are /// outstanding snapshots, they will be canceled. - pub fn apply_change(&mut self, change: AnalysisChange) { + pub fn apply_change(&mut self, change: Change) { self.db.apply_change(change) } @@ -195,7 +194,7 @@ impl Analysis { file_set.insert(file_id, VfsPath::new_virtual_path("/main.rs".to_string())); let source_root = SourceRoot::new_local(file_set); - let mut change = AnalysisChange::new(); + let mut change = Change::new(); change.set_roots(vec![source_root]); let mut crate_graph = CrateGraph::default(); // 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::{ extract_annotations, extract_range_or_offset, Fixture, RangeOrOffset, CURSOR_MARKER, }; -use crate::{ - Analysis, AnalysisChange, AnalysisHost, CrateGraph, Edition, FileId, FilePosition, FileRange, -}; +use crate::{Analysis, AnalysisHost, Change, CrateGraph, Edition, FileId, FilePosition, FileRange}; /// Mock analysis is used in test to bootstrap an AnalysisHost/Analysis /// from a set of in-memory files. @@ -95,7 +93,7 @@ impl MockAnalysis { } pub(crate) fn analysis_host(self) -> AnalysisHost { let mut host = AnalysisHost::default(); - let mut change = AnalysisChange::new(); + let mut change = Change::new(); let mut file_set = FileSet::default(); let mut crate_graph = CrateGraph::default(); 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 { use crate::{ mock_analysis::{analysis_and_position, MockAnalysis}, - AnalysisChange, CrateGraph, + Change, CrateGraph, Edition::Edition2018, }; @@ -146,7 +146,7 @@ mod foo; Env::default(), Default::default(), ); - let mut change = AnalysisChange::new(); + let mut change = Change::new(); change.set_crate_graph(crate_graph); host.apply_change(change); -- cgit v1.2.3