From bbe59c719725d0d6957623c1e391858bedd21779 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sat, 21 Mar 2020 00:40:02 +0200 Subject: Reload watcher configuration --- crates/rust-analyzer/src/world.rs | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'crates') 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::{ use ra_db::ExternSourceId; use rustc_hash::{FxHashMap, FxHashSet}; +fn create_watcher(workspaces: &[ProjectWorkspace], options: &Options) -> CheckWatcher { + workspaces + .iter() + .find_map(|w| match w { + ProjectWorkspace::Cargo { cargo, .. } => Some(cargo), + ProjectWorkspace::Json { .. } => None, + }) + .map(|cargo| { + let cargo_project_root = cargo.workspace_root().to_path_buf(); + Some(CheckWatcher::new(&options.cargo_watch, cargo_project_root)) + }) + .unwrap_or_else(|| { + log::warn!("Cargo check watching only supported for cargo workspaces, disabling"); + None + }) +} + #[derive(Debug, Clone)] pub struct Options { pub publish_decorations: bool, @@ -168,20 +185,7 @@ impl WorldState { change.set_crate_graph(crate_graph); // FIXME: Figure out the multi-workspace situation - let check_watcher = workspaces - .iter() - .find_map(|w| match w { - ProjectWorkspace::Cargo { cargo, .. } => Some(cargo), - ProjectWorkspace::Json { .. } => None, - }) - .map(|cargo| { - let cargo_project_root = cargo.workspace_root().to_path_buf(); - Some(CheckWatcher::new(&options.cargo_watch, cargo_project_root)) - }) - .unwrap_or_else(|| { - log::warn!("Cargo check watching only supported for cargo workspaces, disabling"); - None - }); + let check_watcher = create_watcher(&workspaces, &options); let mut analysis_host = AnalysisHost::new(lru_capacity); analysis_host.apply_change(change); @@ -207,6 +211,7 @@ impl WorldState { ) { self.feature_flags = Arc::new(feature_flags); self.analysis_host.update_lru_capacity(lru_capacity); + self.check_watcher = create_watcher(&self.workspaces, &options); self.options = options; } -- cgit v1.2.3