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.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/crates/ra_analysis/src/mock_analysis.rs b/crates/ra_analysis/src/mock_analysis.rs
index 0d9a7a147..7cbdfb953 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}; 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,14 +78,16 @@ 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, true);
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); 87 let file_id = file_map.add(path.clone());
86 change.add_file(file_id, 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);
90 host 92 host
91 } 93 }