aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/rust-analyzer/src/world.rs33
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::{
31use ra_db::ExternSourceId; 31use ra_db::ExternSourceId;
32use rustc_hash::{FxHashMap, FxHashSet}; 32use rustc_hash::{FxHashMap, FxHashSet};
33 33
34fn 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)]
35pub struct Options { 52pub 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