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.
This commit is contained in:
Aleksey Kladov
2020-10-02 15:45:09 +02:00
parent 700c9bc019
commit 8716c4cec3
11 changed files with 122 additions and 93 deletions

View File

@@ -8,8 +8,7 @@ use base_db::{
FileId,
};
use ide::{
Analysis, AnalysisChange, AnalysisHost, CompletionConfig, DiagnosticsConfig, FilePosition,
LineCol,
Analysis, AnalysisHost, Change, CompletionConfig, DiagnosticsConfig, FilePosition, LineCol,
};
use vfs::AbsPathBuf;
@@ -143,7 +142,7 @@ fn do_work<F: Fn(&Analysis) -> T, T>(host: &mut AnalysisHost, file_id: FileId, w
{
let mut text = host.analysis().file_text(file_id).unwrap().to_string();
text.push_str("\n/* Hello world */\n");
let mut change = AnalysisChange::new();
let mut change = Change::new();
change.change_file(file_id, Some(Arc::new(text)));
host.apply_change(change);
}
@@ -156,7 +155,7 @@ fn do_work<F: Fn(&Analysis) -> T, T>(host: &mut AnalysisHost, file_id: FileId, w
{
let mut text = host.analysis().file_text(file_id).unwrap().to_string();
text.push_str("\npub fn _dummy() {}\n");
let mut change = AnalysisChange::new();
let mut change = Change::new();
change.change_file(file_id, Some(Arc::new(text)));
host.apply_change(change);
}

View File

@@ -5,7 +5,7 @@ use std::{path::Path, sync::Arc};
use anyhow::Result;
use base_db::CrateGraph;
use crossbeam_channel::{unbounded, Receiver};
use ide::{AnalysisChange, AnalysisHost};
use ide::{AnalysisHost, Change};
use project_model::{CargoConfig, ProcMacroClient, ProjectManifest, ProjectWorkspace};
use vfs::{loader::Handle, AbsPath, AbsPathBuf};
@@ -62,7 +62,7 @@ fn load(
) -> AnalysisHost {
let lru_cap = std::env::var("RA_LRU_CAP").ok().and_then(|it| it.parse::<usize>().ok());
let mut host = AnalysisHost::new(lru_cap);
let mut analysis_change = AnalysisChange::new();
let mut analysis_change = Change::new();
// wait until Vfs has loaded all roots
for task in receiver {