aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock6
-rw-r--r--Cargo.toml1
-rw-r--r--crates/ra_lsp_server/src/project_model.rs21
3 files changed, 13 insertions, 15 deletions
diff --git a/Cargo.lock b/Cargo.lock
index c84fa0c02..949a58e86 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -113,7 +113,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
113[[package]] 113[[package]]
114name = "cargo_metadata" 114name = "cargo_metadata"
115version = "0.6.4" 115version = "0.6.4"
116source = "registry+https://github.com/rust-lang/crates.io-index" 116source = "git+https://github.com/matklad/cargo_metadata.git?branch=well-typed#2f125128c38beeef34e0bfc1bc27861a24753dfe"
117dependencies = [ 117dependencies = [
118 "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", 118 "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
119 "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", 119 "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -724,7 +724,7 @@ dependencies = [
724name = "ra_lsp_server" 724name = "ra_lsp_server"
725version = "0.1.0" 725version = "0.1.0"
726dependencies = [ 726dependencies = [
727 "cargo_metadata 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", 727 "cargo_metadata 0.6.4 (git+https://github.com/matklad/cargo_metadata.git?branch=well-typed)",
728 "crossbeam-channel 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", 728 "crossbeam-channel 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
729 "drop_bomb 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", 729 "drop_bomb 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
730 "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", 730 "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1489,7 +1489,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1489"checksum block-buffer 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a076c298b9ecdb530ed9d967e74a6027d6a7478924520acddcddc24c1c8ab3ab" 1489"checksum block-buffer 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a076c298b9ecdb530ed9d967e74a6027d6a7478924520acddcddc24c1c8ab3ab"
1490"checksum byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40" 1490"checksum byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40"
1491"checksum byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "94f88df23a25417badc922ab0f5716cc1330e87f71ddd9203b3a3ccd9cedf75d" 1491"checksum byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "94f88df23a25417badc922ab0f5716cc1330e87f71ddd9203b3a3ccd9cedf75d"
1492"checksum cargo_metadata 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e5d1b4d380e1bab994591a24c2bdd1b054f64b60bef483a8c598c7c345bc3bbe" 1492"checksum cargo_metadata 0.6.4 (git+https://github.com/matklad/cargo_metadata.git?branch=well-typed)" = "<none>"
1493"checksum cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4a8b715cb4597106ea87c7c84b2f1d452c7492033765df7f32651e66fcf749" 1493"checksum cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4a8b715cb4597106ea87c7c84b2f1d452c7492033765df7f32651e66fcf749"
1494"checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" 1494"checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4"
1495"checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878" 1495"checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878"
diff --git a/Cargo.toml b/Cargo.toml
index c5155e899..82b08ab40 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -6,3 +6,4 @@ incremental = true
6debug = true 6debug = true
7 7
8[patch.'crates-io'] 8[patch.'crates-io']
9cargo_metadata = { git = "https://github.com/matklad/cargo_metadata.git", branch = "well-typed" }
diff --git a/crates/ra_lsp_server/src/project_model.rs b/crates/ra_lsp_server/src/project_model.rs
index ae2149463..ff9befe46 100644
--- a/crates/ra_lsp_server/src/project_model.rs
+++ b/crates/ra_lsp_server/src/project_model.rs
@@ -2,7 +2,7 @@ use std::path::{Path, PathBuf};
2 2
3use cargo_metadata::{metadata_run, CargoOpt}; 3use cargo_metadata::{metadata_run, CargoOpt};
4use ra_syntax::SmolStr; 4use ra_syntax::SmolStr;
5use rustc_hash::{FxHashMap, FxHashSet}; 5use rustc_hash::FxHashMap;
6use failure::{format_err, bail}; 6use failure::{format_err, bail};
7use thread_worker::{WorkerHandle, Worker}; 7use thread_worker::{WorkerHandle, Worker};
8 8
@@ -109,11 +109,7 @@ impl CargoWorkspace {
109 let mut packages = Vec::new(); 109 let mut packages = Vec::new();
110 let mut targets = Vec::new(); 110 let mut targets = Vec::new();
111 111
112 let ws_members: FxHashSet<String> = meta 112 let ws_members = &meta.workspace_members;
113 .workspace_members
114 .into_iter()
115 .map(|it| it.raw)
116 .collect();
117 113
118 for meta_pkg in meta.packages { 114 for meta_pkg in meta.packages {
119 let pkg = Package(packages.len()); 115 let pkg = Package(packages.len());
@@ -121,7 +117,7 @@ impl CargoWorkspace {
121 pkg_by_id.insert(meta_pkg.id.clone(), pkg); 117 pkg_by_id.insert(meta_pkg.id.clone(), pkg);
122 let mut pkg_data = PackageData { 118 let mut pkg_data = PackageData {
123 name: meta_pkg.name.into(), 119 name: meta_pkg.name.into(),
124 manifest: PathBuf::from(meta_pkg.manifest_path), 120 manifest: meta_pkg.manifest_path.clone(),
125 targets: Vec::new(), 121 targets: Vec::new(),
126 is_member, 122 is_member,
127 dependencies: Vec::new(), 123 dependencies: Vec::new(),
@@ -131,7 +127,7 @@ impl CargoWorkspace {
131 targets.push(TargetData { 127 targets.push(TargetData {
132 pkg, 128 pkg,
133 name: meta_tgt.name.into(), 129 name: meta_tgt.name.into(),
134 root: PathBuf::from(meta_tgt.src_path), 130 root: meta_tgt.src_path.clone(),
135 kind: TargetKind::new(meta_tgt.kind.as_slice()), 131 kind: TargetKind::new(meta_tgt.kind.as_slice()),
136 }); 132 });
137 pkg_data.targets.push(tgt); 133 pkg_data.targets.push(tgt);
@@ -141,10 +137,11 @@ impl CargoWorkspace {
141 let resolve = meta.resolve.expect("metadata executed with deps"); 137 let resolve = meta.resolve.expect("metadata executed with deps");
142 for node in resolve.nodes { 138 for node in resolve.nodes {
143 let source = pkg_by_id[&node.id]; 139 let source = pkg_by_id[&node.id];
144 for id in node.dependencies { 140 for dep_node in node.deps {
145 let target = pkg_by_id[&id]; 141 let dep = PackageDependency {
146 let name: SmolStr = packages[target.0].name.replace('-', "_").into(); 142 name: dep_node.name.into(),
147 let dep = PackageDependency { name, pkg: target }; 143 pkg: pkg_by_id[&dep_node.pkg],
144 };
148 packages[source.0].dependencies.push(dep); 145 packages[source.0].dependencies.push(dep);
149 } 146 }
150 } 147 }