aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/mock_analysis.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_analysis/src/mock_analysis.rs')
-rw-r--r--crates/ra_analysis/src/mock_analysis.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/crates/ra_analysis/src/mock_analysis.rs b/crates/ra_analysis/src/mock_analysis.rs
index 691af4a48..0c042e672 100644
--- a/crates/ra_analysis/src/mock_analysis.rs
+++ b/crates/ra_analysis/src/mock_analysis.rs
@@ -4,7 +4,7 @@ use relative_path::{RelativePathBuf};
4use test_utils::{extract_offset, parse_fixture, CURSOR_MARKER}; 4use test_utils::{extract_offset, parse_fixture, CURSOR_MARKER};
5use ra_db::mock::FileMap; 5use ra_db::mock::FileMap;
6 6
7use crate::{Analysis, AnalysisChange, AnalysisHost, FileId, FilePosition, WORKSPACE}; 7use crate::{Analysis, AnalysisChange, AnalysisHost, FileId, FilePosition, SourceRootId};
8 8
9/// Mock analysis is used in test to bootstrap an AnalysisHost/Analysis 9/// Mock analysis is used in test to bootstrap an AnalysisHost/Analysis
10/// from a set of in-memory files. 10/// from a set of in-memory files.
@@ -78,12 +78,14 @@ impl MockAnalysis {
78 pub fn analysis_host(self) -> AnalysisHost { 78 pub fn analysis_host(self) -> AnalysisHost {
79 let mut host = AnalysisHost::default(); 79 let mut host = AnalysisHost::default();
80 let mut file_map = FileMap::default(); 80 let mut file_map = FileMap::default();
81 let source_root = SourceRootId(0);
81 let mut change = AnalysisChange::new(); 82 let mut change = AnalysisChange::new();
83 change.add_root(source_root);
82 for (path, contents) in self.files.into_iter() { 84 for (path, contents) in self.files.into_iter() {
83 assert!(path.starts_with('/')); 85 assert!(path.starts_with('/'));
84 let path = RelativePathBuf::from_path(&path[1..]).unwrap(); 86 let path = RelativePathBuf::from_path(&path[1..]).unwrap();
85 let file_id = file_map.add(path.clone()); 87 let file_id = file_map.add(path.clone());
86 change.add_file(WORKSPACE, file_id, path, Arc::new(contents)); 88 change.add_file(source_root, file_id, path, Arc::new(contents));
87 } 89 }
88 // change.set_file_resolver(Arc::new(file_map)); 90 // change.set_file_resolver(Arc::new(file_map));
89 host.apply_change(change); 91 host.apply_change(change);