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.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/crates/ra_analysis/src/mock_analysis.rs b/crates/ra_analysis/src/mock_analysis.rs
index 960529404..846c76cfe 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, extract_range, parse_fixture, CURSOR_MARKER}; 4use test_utils::{extract_offset, extract_range, parse_fixture, CURSOR_MARKER};
5use ra_db::mock::FileMap; 5use ra_db::mock::FileMap;
6 6
7use crate::{Analysis, AnalysisChange, AnalysisHost, FileId, FilePosition, FileRange, SourceRootId}; 7use crate::{Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId, FilePosition, FileRange, 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.
@@ -87,12 +87,17 @@ impl MockAnalysis {
87 let source_root = SourceRootId(0); 87 let source_root = SourceRootId(0);
88 let mut change = AnalysisChange::new(); 88 let mut change = AnalysisChange::new();
89 change.add_root(source_root, true); 89 change.add_root(source_root, true);
90 let mut crate_graph = CrateGraph::default();
90 for (path, contents) in self.files.into_iter() { 91 for (path, contents) in self.files.into_iter() {
91 assert!(path.starts_with('/')); 92 assert!(path.starts_with('/'));
92 let path = RelativePathBuf::from_path(&path[1..]).unwrap(); 93 let path = RelativePathBuf::from_path(&path[1..]).unwrap();
93 let file_id = file_map.add(path.clone()); 94 let file_id = file_map.add(path.clone());
95 if path == "/lib.rs" || path == "/main.rs" {
96 crate_graph.add_crate_root(file_id);
97 }
94 change.add_file(source_root, file_id, path, Arc::new(contents)); 98 change.add_file(source_root, file_id, path, Arc::new(contents));
95 } 99 }
100 change.set_crate_graph(crate_graph);
96 // change.set_file_resolver(Arc::new(file_map)); 101 // change.set_file_resolver(Arc::new(file_map));
97 host.apply_change(change); 102 host.apply_change(change);
98 host 103 host