Reload watcher configuration

This commit is contained in:
Kirill Bulatov 2020-03-21 00:40:02 +02:00
parent 8a23bec2cd
commit bbe59c7197

View File

@ -31,6 +31,23 @@
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 @@ pub fn new(
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 @@ pub fn update_configuration(
) {
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;
}