diff options
Diffstat (limited to 'crates/ra_lsp_server/src')
-rw-r--r-- | crates/ra_lsp_server/src/cargo_target_spec.rs | 20 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/server_world.rs | 9 |
2 files changed, 13 insertions, 16 deletions
diff --git a/crates/ra_lsp_server/src/cargo_target_spec.rs b/crates/ra_lsp_server/src/cargo_target_spec.rs index e011eab7c..cdf2ec10b 100644 --- a/crates/ra_lsp_server/src/cargo_target_spec.rs +++ b/crates/ra_lsp_server/src/cargo_target_spec.rs | |||
@@ -1,5 +1,5 @@ | |||
1 | use crate::{ | 1 | use crate::{ |
2 | project_model::TargetKind, | 2 | project_model::{self, TargetKind}, |
3 | server_world::ServerWorld, | 3 | server_world::ServerWorld, |
4 | Result | 4 | Result |
5 | }; | 5 | }; |
@@ -65,14 +65,16 @@ impl CargoTargetSpec { | |||
65 | }; | 65 | }; |
66 | let file_id = world.analysis().crate_root(crate_id)?; | 66 | let file_id = world.analysis().crate_root(crate_id)?; |
67 | let path = world.vfs.read().file2path(ra_vfs::VfsFile(file_id.0.into())); | 67 | let path = world.vfs.read().file2path(ra_vfs::VfsFile(file_id.0.into())); |
68 | let res = world.workspaces.iter().find_map(|ws| { | 68 | let res = world.workspaces.iter().find_map(|ws| match ws { |
69 | let tgt = ws.cargo.target_by_root(&path)?; | 69 | project_model::ProjectWorkspace::Cargo { cargo, .. } => { |
70 | let res = CargoTargetSpec { | 70 | let tgt = cargo.target_by_root(&path)?; |
71 | package: tgt.package(&ws.cargo).name(&ws.cargo).to_string(), | 71 | Some(CargoTargetSpec { |
72 | target: tgt.name(&ws.cargo).to_string(), | 72 | package: tgt.package(&cargo).name(&cargo).to_string(), |
73 | target_kind: tgt.kind(&ws.cargo), | 73 | target: tgt.name(&cargo).to_string(), |
74 | }; | 74 | target_kind: tgt.kind(&cargo), |
75 | Some(res) | 75 | }) |
76 | } | ||
77 | project_model::ProjectWorkspace::Json { .. } => None, | ||
76 | }); | 78 | }); |
77 | Ok(res) | 79 | Ok(res) |
78 | } | 80 | } |
diff --git a/crates/ra_lsp_server/src/server_world.rs b/crates/ra_lsp_server/src/server_world.rs index 4a68c019f..7163568b9 100644 --- a/crates/ra_lsp_server/src/server_world.rs +++ b/crates/ra_lsp_server/src/server_world.rs | |||
@@ -40,12 +40,7 @@ impl ServerWorldState { | |||
40 | let mut roots = Vec::new(); | 40 | let mut roots = Vec::new(); |
41 | roots.push(root.clone()); | 41 | roots.push(root.clone()); |
42 | for ws in workspaces.iter() { | 42 | for ws in workspaces.iter() { |
43 | for pkg in ws.cargo.packages() { | 43 | roots.extend(ws.to_roots()); |
44 | roots.push(pkg.root(&ws.cargo).to_path_buf()); | ||
45 | } | ||
46 | for krate in ws.sysroot.crates() { | ||
47 | roots.push(krate.root_dir(&ws.sysroot).to_path_buf()) | ||
48 | } | ||
49 | } | 44 | } |
50 | let (mut vfs, roots) = Vfs::new(roots); | 45 | let (mut vfs, roots) = Vfs::new(roots); |
51 | let roots_to_scan = roots.len(); | 46 | let roots_to_scan = roots.len(); |
@@ -185,7 +180,7 @@ impl ServerWorld { | |||
185 | } else { | 180 | } else { |
186 | res.push_str("workspaces:\n"); | 181 | res.push_str("workspaces:\n"); |
187 | for w in self.workspaces.iter() { | 182 | for w in self.workspaces.iter() { |
188 | res += &format!("{} packages loaded\n", w.cargo.packages().count()); | 183 | res += &format!("{} packages loaded\n", w.count()); |
189 | } | 184 | } |
190 | } | 185 | } |
191 | res.push_str("\nanalysis:\n"); | 186 | res.push_str("\nanalysis:\n"); |