aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_lsp_server')
-rw-r--r--crates/ra_lsp_server/src/project_model.rs19
-rw-r--r--crates/ra_lsp_server/src/server_world.rs4
2 files changed, 17 insertions, 6 deletions
diff --git a/crates/ra_lsp_server/src/project_model.rs b/crates/ra_lsp_server/src/project_model.rs
index 5da71b9f5..cb91ada90 100644
--- a/crates/ra_lsp_server/src/project_model.rs
+++ b/crates/ra_lsp_server/src/project_model.rs
@@ -34,7 +34,13 @@ struct PackageData {
34 manifest: PathBuf, 34 manifest: PathBuf,
35 targets: Vec<Target>, 35 targets: Vec<Target>,
36 is_member: bool, 36 is_member: bool,
37 dependencies: Vec<Package>, 37 dependencies: Vec<PackageDependency>,
38}
39
40#[derive(Debug, Clone)]
41pub struct PackageDependency {
42 pub pkg: Package,
43 pub name: SmolStr,
38} 44}
39 45
40#[derive(Debug, Clone)] 46#[derive(Debug, Clone)]
@@ -68,8 +74,11 @@ impl Package {
68 pub fn is_member(self, ws: &CargoWorkspace) -> bool { 74 pub fn is_member(self, ws: &CargoWorkspace) -> bool {
69 ws.pkg(self).is_member 75 ws.pkg(self).is_member
70 } 76 }
71 pub fn dependencies<'a>(self, ws: &'a CargoWorkspace) -> impl Iterator<Item = Package> + 'a { 77 pub fn dependencies<'a>(
72 ws.pkg(self).dependencies.iter().cloned() 78 self,
79 ws: &'a CargoWorkspace,
80 ) -> impl Iterator<Item = &'a PackageDependency> + 'a {
81 ws.pkg(self).dependencies.iter()
73 } 82 }
74} 83}
75 84
@@ -135,7 +144,9 @@ impl CargoWorkspace {
135 let source = pkg_by_id[&node.id]; 144 let source = pkg_by_id[&node.id];
136 for id in node.dependencies { 145 for id in node.dependencies {
137 let target = pkg_by_id[&id]; 146 let target = pkg_by_id[&id];
138 packages[source.0].dependencies.push(target); 147 let name: SmolStr = packages[target.0].name.replace('-', "_").into();
148 let dep = PackageDependency { name, pkg: target };
149 packages[source.0].dependencies.push(dep);
139 } 150 }
140 } 151 }
141 152
diff --git a/crates/ra_lsp_server/src/server_world.rs b/crates/ra_lsp_server/src/server_world.rs
index f2d602dc7..ab4c2c8aa 100644
--- a/crates/ra_lsp_server/src/server_world.rs
+++ b/crates/ra_lsp_server/src/server_world.rs
@@ -162,9 +162,9 @@ impl ServerWorldState {
162 } 162 }
163 for pkg in ws.packages() { 163 for pkg in ws.packages() {
164 for dep in pkg.dependencies(ws) { 164 for dep in pkg.dependencies(ws) {
165 if let Some(&to) = pkg_to_lib_crate.get(&dep) { 165 if let Some(&to) = pkg_to_lib_crate.get(&dep.pkg) {
166 for &from in pkg_crates.get(&pkg).into_iter().flatten() { 166 for &from in pkg_crates.get(&pkg).into_iter().flatten() {
167 crate_graph.add_dep(from, to); 167 crate_graph.add_dep(from, dep.name.clone(), to);
168 } 168 }
169 } 169 }
170 } 170 }