aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmil Lauridsen <[email protected]>2020-01-11 20:32:40 +0000
committerEmil Lauridsen <[email protected]>2020-01-11 20:32:40 +0000
commit480c44918c73922b134b670cbd33014b8fcfc883 (patch)
treed26ccf2d4cce9639b6f7b3373734d989c8861ba0
parentd6da18e99d2fb4e67e3bc7503059282b5e14bd13 (diff)
Disable cargo checking in workspaces with no cargo projects
-rw-r--r--crates/ra_cargo_watch/src/lib.rs6
-rw-r--r--crates/ra_lsp_server/src/world.rs28
2 files changed, 20 insertions, 14 deletions
diff --git a/crates/ra_cargo_watch/src/lib.rs b/crates/ra_cargo_watch/src/lib.rs
index 9bc0fd405..cb0856aa4 100644
--- a/crates/ra_cargo_watch/src/lib.rs
+++ b/crates/ra_cargo_watch/src/lib.rs
@@ -58,6 +58,12 @@ impl CheckWatcher {
58 CheckWatcher { task_recv, cmd_send: Some(cmd_send), handle: Some(handle), shared } 58 CheckWatcher { task_recv, cmd_send: Some(cmd_send), handle: Some(handle), shared }
59 } 59 }
60 60
61 /// Returns a CheckWatcher that doesn't actually do anything
62 pub fn dummy() -> CheckWatcher {
63 let shared = Arc::new(RwLock::new(CheckWatcherSharedState::new()));
64 CheckWatcher { task_recv: never(), cmd_send: None, handle: None, shared }
65 }
66
61 /// Schedule a re-start of the cargo check worker. 67 /// Schedule a re-start of the cargo check worker.
62 pub fn update(&self) { 68 pub fn update(&self) {
63 if let Some(cmd_send) = &self.cmd_send { 69 if let Some(cmd_send) = &self.cmd_send {
diff --git a/crates/ra_lsp_server/src/world.rs b/crates/ra_lsp_server/src/world.rs
index cea18937f..a52bd2633 100644
--- a/crates/ra_lsp_server/src/world.rs
+++ b/crates/ra_lsp_server/src/world.rs
@@ -132,20 +132,20 @@ impl WorldState {
132 change.set_crate_graph(crate_graph); 132 change.set_crate_graph(crate_graph);
133 133
134 // FIXME: Figure out the multi-workspace situation 134 // FIXME: Figure out the multi-workspace situation
135 let check_watcher = { 135 let check_watcher = workspaces
136 let first_workspace = workspaces.first().unwrap(); 136 .iter()
137 let cargo_project_root = match first_workspace { 137 .find_map(|w| match w {
138 ProjectWorkspace::Cargo { cargo, .. } => cargo.workspace_root().to_path_buf(), 138 ProjectWorkspace::Cargo { cargo, .. } => Some(cargo),
139 ProjectWorkspace::Json { .. } => { 139 ProjectWorkspace::Json { .. } => None,
140 log::warn!( 140 })
141 "Cargo check watching only supported for cargo workspaces, disabling" 141 .map(|cargo| {
142 ); 142 let cargo_project_root = cargo.workspace_root().to_path_buf();
143 options.cargo_watch.enable = false; 143 CheckWatcher::new(&options.cargo_watch, cargo_project_root)
144 PathBuf::new() 144 })
145 } 145 .unwrap_or_else(|| {
146 }; 146 log::warn!("Cargo check watching only supported for cargo workspaces, disabling");
147 CheckWatcher::new(&options.cargo_watch, cargo_project_root) 147 CheckWatcher::dummy()
148 }; 148 });
149 149
150 let mut analysis_host = AnalysisHost::new(lru_capacity, feature_flags); 150 let mut analysis_host = AnalysisHost::new(lru_capacity, feature_flags);
151 analysis_host.apply_change(change); 151 analysis_host.apply_change(change);