diff options
Diffstat (limited to 'crates/ra_project_model')
-rw-r--r-- | crates/ra_project_model/Cargo.toml | 1 | ||||
-rw-r--r-- | crates/ra_project_model/src/lib.rs | 9 |
2 files changed, 3 insertions, 7 deletions
diff --git a/crates/ra_project_model/Cargo.toml b/crates/ra_project_model/Cargo.toml index 996dce351..9cdf2b322 100644 --- a/crates/ra_project_model/Cargo.toml +++ b/crates/ra_project_model/Cargo.toml | |||
@@ -18,7 +18,6 @@ cargo_metadata = "0.7.0" | |||
18 | 18 | ||
19 | ra_arena = { path = "../ra_arena" } | 19 | ra_arena = { path = "../ra_arena" } |
20 | ra_db = { path = "../ra_db" } | 20 | ra_db = { path = "../ra_db" } |
21 | ra_vfs = { path = "../ra_vfs" } | ||
22 | 21 | ||
23 | [dev-dependencies] | 22 | [dev-dependencies] |
24 | test_utils = { path = "../test_utils" } | 23 | test_utils = { path = "../test_utils" } |
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; | |||
7 | use rustc_hash::FxHashMap; | 7 | use rustc_hash::FxHashMap; |
8 | 8 | ||
9 | use ra_db::{CrateGraph, FileId}; | 9 | use ra_db::{CrateGraph, FileId}; |
10 | use ra_vfs::Vfs; | ||
11 | 10 | ||
12 | pub use crate::{ | 11 | pub 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); |