aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_lsp_server/src')
-rw-r--r--crates/ra_lsp_server/src/project_model.rs21
1 files changed, 9 insertions, 12 deletions
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 }