aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock1
-rw-r--r--crates/ra_lsp_server/src/server_world.rs6
-rw-r--r--crates/ra_project_model/Cargo.toml1
-rw-r--r--crates/ra_project_model/src/lib.rs9
4 files changed, 8 insertions, 9 deletions
diff --git a/Cargo.lock b/Cargo.lock
index a76d0b2fe..2c554ec10 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1055,7 +1055,6 @@ dependencies = [
1055 "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", 1055 "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
1056 "ra_arena 0.1.0", 1056 "ra_arena 0.1.0",
1057 "ra_db 0.1.0", 1057 "ra_db 0.1.0",
1058 "ra_vfs 0.1.0",
1059 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", 1058 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
1060 "test_utils 0.1.0", 1059 "test_utils 0.1.0",
1061 "walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)", 1060 "walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/crates/ra_lsp_server/src/server_world.rs b/crates/ra_lsp_server/src/server_world.rs
index 23270d0aa..f97d240fa 100644
--- a/crates/ra_lsp_server/src/server_world.rs
+++ b/crates/ra_lsp_server/src/server_world.rs
@@ -58,8 +58,12 @@ impl ServerWorldState {
58 58
59 // Create crate graph from all the workspaces 59 // Create crate graph from all the workspaces
60 let mut crate_graph = CrateGraph::default(); 60 let mut crate_graph = CrateGraph::default();
61 let mut load = |path: &std::path::Path| {
62 let vfs_file = vfs.load(path);
63 vfs_file.map(|f| FileId(f.0.into()))
64 };
61 for ws in workspaces.iter() { 65 for ws in workspaces.iter() {
62 crate_graph.extend(ws.to_crate_graph(&mut vfs)); 66 crate_graph.extend(ws.to_crate_graph(&mut load));
63 } 67 }
64 change.set_crate_graph(crate_graph); 68 change.set_crate_graph(crate_graph);
65 69
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
19ra_arena = { path = "../ra_arena" } 19ra_arena = { path = "../ra_arena" }
20ra_db = { path = "../ra_db" } 20ra_db = { path = "../ra_db" }
21ra_vfs = { path = "../ra_vfs" }
22 21
23[dev-dependencies] 22[dev-dependencies]
24test_utils = { path = "../test_utils" } 23test_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;
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);