aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_project_model/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_project_model/src')
-rw-r--r--crates/ra_project_model/src/lib.rs9
1 files changed, 3 insertions, 6 deletions
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs
index abc79684c..156af9e7a 100644
--- a/crates/ra_project_model/src/lib.rs
+++ b/crates/ra_project_model/src/lib.rs
@@ -7,7 +7,6 @@ use failure::bail;
7use rustc_hash::FxHashMap; 7use rustc_hash::FxHashMap;
8 8
9use ra_db::{CrateGraph, FileId}; 9use ra_db::{CrateGraph, FileId};
10use ra_vfs::Vfs;
11 10
12pub use crate::{ 11pub use crate::{
13 cargo_workspace::{CargoWorkspace, Package, Target, TargetKind}, 12 cargo_workspace::{CargoWorkspace, Package, Target, TargetKind},
@@ -32,12 +31,11 @@ impl ProjectWorkspace {
32 Ok(res) 31 Ok(res)
33 } 32 }
34 33
35 pub fn to_crate_graph(&self, vfs: &mut Vfs) -> CrateGraph { 34 pub fn to_crate_graph(&self, load: &mut dyn FnMut(&Path) -> Option<FileId>) -> CrateGraph {
36 let mut crate_graph = CrateGraph::default(); 35 let mut crate_graph = CrateGraph::default();
37 let mut sysroot_crates = FxHashMap::default(); 36 let mut sysroot_crates = FxHashMap::default();
38 for krate in self.sysroot.crates() { 37 for krate in self.sysroot.crates() {
39 if let Some(file_id) = vfs.load(krate.root(&self.sysroot)) { 38 if let Some(file_id) = load(krate.root(&self.sysroot)) {
40 let file_id = FileId(file_id.0.into());
41 sysroot_crates.insert(krate, crate_graph.add_crate_root(file_id)); 39 sysroot_crates.insert(krate, crate_graph.add_crate_root(file_id));
42 } 40 }
43 } 41 }
@@ -63,8 +61,7 @@ impl ProjectWorkspace {
63 let mut lib_tgt = None; 61 let mut lib_tgt = None;
64 for tgt in pkg.targets(&self.cargo) { 62 for tgt in pkg.targets(&self.cargo) {
65 let root = tgt.root(&self.cargo); 63 let root = tgt.root(&self.cargo);
66 if let Some(file_id) = vfs.load(root) { 64 if let Some(file_id) = load(root) {
67 let file_id = FileId(file_id.0.into());
68 let crate_id = crate_graph.add_crate_root(file_id); 65 let crate_id = crate_graph.add_crate_root(file_id);
69 if tgt.kind(&self.cargo) == TargetKind::Lib { 66 if tgt.kind(&self.cargo) == TargetKind::Lib {
70 lib_tgt = Some(crate_id); 67 lib_tgt = Some(crate_id);