mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
fix tests
This commit is contained in:
parent
e6465e7e2a
commit
2fe41574a1
5 changed files with 26 additions and 13 deletions
|
@ -43,10 +43,19 @@ impl AnalysisHostImpl {
|
|||
pub fn apply_change(&mut self, change: AnalysisChange) {
|
||||
log::info!("apply_change {:?}", change);
|
||||
// self.gc_syntax_trees();
|
||||
for root_id in change.new_roots {
|
||||
if !change.new_roots.is_empty() {
|
||||
let mut local_roots = Vec::clone(&self.db.local_roots());
|
||||
for (root_id, is_local) in change.new_roots {
|
||||
self.db
|
||||
.query_mut(ra_db::SourceRootQuery)
|
||||
.set(root_id, Default::default());
|
||||
if is_local {
|
||||
local_roots.push(root_id);
|
||||
}
|
||||
}
|
||||
self.db
|
||||
.query_mut(ra_db::SourceRootQuery)
|
||||
.set(root_id, Default::default());
|
||||
.query_mut(ra_db::LocalRootsQuery)
|
||||
.set((), Arc::new(local_roots));
|
||||
}
|
||||
|
||||
for (root_id, root_change) in change.roots_changed {
|
||||
|
|
|
@ -44,7 +44,7 @@ pub use ra_db::{
|
|||
|
||||
#[derive(Default)]
|
||||
pub struct AnalysisChange {
|
||||
new_roots: Vec<SourceRootId>,
|
||||
new_roots: Vec<(SourceRootId, bool)>,
|
||||
roots_changed: FxHashMap<SourceRootId, RootChange>,
|
||||
files_changed: Vec<(FileId, Arc<String>)>,
|
||||
libraries_added: Vec<LibraryData>,
|
||||
|
@ -95,8 +95,8 @@ impl AnalysisChange {
|
|||
pub fn new() -> AnalysisChange {
|
||||
AnalysisChange::default()
|
||||
}
|
||||
pub fn add_root(&mut self, root_id: SourceRootId) {
|
||||
self.new_roots.push(root_id);
|
||||
pub fn add_root(&mut self, root_id: SourceRootId, is_local: bool) {
|
||||
self.new_roots.push((root_id, is_local));
|
||||
}
|
||||
pub fn add_file(
|
||||
&mut self,
|
||||
|
|
|
@ -80,7 +80,7 @@ impl MockAnalysis {
|
|||
let mut file_map = FileMap::default();
|
||||
let source_root = SourceRootId(0);
|
||||
let mut change = AnalysisChange::new();
|
||||
change.add_root(source_root);
|
||||
change.add_root(source_root, true);
|
||||
for (path, contents) in self.files.into_iter() {
|
||||
assert!(path.starts_with('/'));
|
||||
let path = RelativePathBuf::from_path(&path[1..]).unwrap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue