diff options
author | Kirill Bulatov <[email protected]> | 2020-03-20 22:40:02 +0000 |
---|---|---|
committer | Kirill Bulatov <[email protected]> | 2020-03-30 11:39:14 +0100 |
commit | bbe59c719725d0d6957623c1e391858bedd21779 (patch) | |
tree | c99275536199e46e7b0408c8e0322e48da9c8f3b /crates | |
parent | 8a23bec2cdd008ff04cb01cdcca1f379f53156a3 (diff) |
Reload watcher configuration
Diffstat (limited to 'crates')
-rw-r--r-- | crates/rust-analyzer/src/world.rs | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/crates/rust-analyzer/src/world.rs b/crates/rust-analyzer/src/world.rs index d77844a36..b0c3c6a06 100644 --- a/crates/rust-analyzer/src/world.rs +++ b/crates/rust-analyzer/src/world.rs | |||
@@ -31,6 +31,23 @@ use crate::{ | |||
31 | use ra_db::ExternSourceId; | 31 | use ra_db::ExternSourceId; |
32 | use rustc_hash::{FxHashMap, FxHashSet}; | 32 | use rustc_hash::{FxHashMap, FxHashSet}; |
33 | 33 | ||
34 | fn create_watcher(workspaces: &[ProjectWorkspace], options: &Options) -> CheckWatcher { | ||
35 | workspaces | ||
36 | .iter() | ||
37 | .find_map(|w| match w { | ||
38 | ProjectWorkspace::Cargo { cargo, .. } => Some(cargo), | ||
39 | ProjectWorkspace::Json { .. } => None, | ||
40 | }) | ||
41 | .map(|cargo| { | ||
42 | let cargo_project_root = cargo.workspace_root().to_path_buf(); | ||
43 | Some(CheckWatcher::new(&options.cargo_watch, cargo_project_root)) | ||
44 | }) | ||
45 | .unwrap_or_else(|| { | ||
46 | log::warn!("Cargo check watching only supported for cargo workspaces, disabling"); | ||
47 | None | ||
48 | }) | ||
49 | } | ||
50 | |||
34 | #[derive(Debug, Clone)] | 51 | #[derive(Debug, Clone)] |
35 | pub struct Options { | 52 | pub struct Options { |
36 | pub publish_decorations: bool, | 53 | pub publish_decorations: bool, |
@@ -168,20 +185,7 @@ impl WorldState { | |||
168 | change.set_crate_graph(crate_graph); | 185 | change.set_crate_graph(crate_graph); |
169 | 186 | ||
170 | // FIXME: Figure out the multi-workspace situation | 187 | // FIXME: Figure out the multi-workspace situation |
171 | let check_watcher = workspaces | 188 | let check_watcher = create_watcher(&workspaces, &options); |
172 | .iter() | ||
173 | .find_map(|w| match w { | ||
174 | ProjectWorkspace::Cargo { cargo, .. } => Some(cargo), | ||
175 | ProjectWorkspace::Json { .. } => None, | ||
176 | }) | ||
177 | .map(|cargo| { | ||
178 | let cargo_project_root = cargo.workspace_root().to_path_buf(); | ||
179 | Some(CheckWatcher::new(&options.cargo_watch, cargo_project_root)) | ||
180 | }) | ||
181 | .unwrap_or_else(|| { | ||
182 | log::warn!("Cargo check watching only supported for cargo workspaces, disabling"); | ||
183 | None | ||
184 | }); | ||
185 | 189 | ||
186 | let mut analysis_host = AnalysisHost::new(lru_capacity); | 190 | let mut analysis_host = AnalysisHost::new(lru_capacity); |
187 | analysis_host.apply_change(change); | 191 | analysis_host.apply_change(change); |
@@ -207,6 +211,7 @@ impl WorldState { | |||
207 | ) { | 211 | ) { |
208 | self.feature_flags = Arc::new(feature_flags); | 212 | self.feature_flags = Arc::new(feature_flags); |
209 | self.analysis_host.update_lru_capacity(lru_capacity); | 213 | self.analysis_host.update_lru_capacity(lru_capacity); |
214 | self.check_watcher = create_watcher(&self.workspaces, &options); | ||
210 | self.options = options; | 215 | self.options = options; |
211 | } | 216 | } |
212 | 217 | ||