mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +00:00
index all local crates
This commit is contained in:
parent
51fec4ef84
commit
e6465e7e2a
6 changed files with 37 additions and 33 deletions
|
@ -4,7 +4,7 @@ use relative_path::{RelativePathBuf};
|
|||
use test_utils::{extract_offset, parse_fixture, CURSOR_MARKER};
|
||||
use ra_db::mock::FileMap;
|
||||
|
||||
use crate::{Analysis, AnalysisChange, AnalysisHost, FileId, FilePosition, WORKSPACE};
|
||||
use crate::{Analysis, AnalysisChange, AnalysisHost, FileId, FilePosition, SourceRootId};
|
||||
|
||||
/// Mock analysis is used in test to bootstrap an AnalysisHost/Analysis
|
||||
/// from a set of in-memory files.
|
||||
|
@ -78,12 +78,14 @@ impl MockAnalysis {
|
|||
pub fn analysis_host(self) -> AnalysisHost {
|
||||
let mut host = AnalysisHost::default();
|
||||
let mut file_map = FileMap::default();
|
||||
let source_root = SourceRootId(0);
|
||||
let mut change = AnalysisChange::new();
|
||||
change.add_root(source_root);
|
||||
for (path, contents) in self.files.into_iter() {
|
||||
assert!(path.starts_with('/'));
|
||||
let path = RelativePathBuf::from_path(&path[1..]).unwrap();
|
||||
let file_id = file_map.add(path.clone());
|
||||
change.add_file(WORKSPACE, file_id, path, Arc::new(contents));
|
||||
change.add_file(source_root, file_id, path, Arc::new(contents));
|
||||
}
|
||||
// change.set_file_resolver(Arc::new(file_map));
|
||||
host.apply_change(change);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue