X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=crates%2Frust-analyzer%2Fsrc%2Fglobal_state.rs;h=7759c0ae309f9e0a38eb16ec3f0da1c4c2b3cb41;hb=76a530242a12f75e2a8456f952cef07e2d564f67;hp=87f3fe4db8d3c57c0552c861b34e5a8e015d8ff8;hpb=10ee6eb7333d1978eac4c70039162f61d6275ba3;p=rust.git diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs index 87f3fe4db8d..7759c0ae309 100644 --- a/crates/rust-analyzer/src/global_state.rs +++ b/crates/rust-analyzer/src/global_state.rs @@ -27,9 +27,13 @@ }; use rustc_hash::{FxHashMap, FxHashSet}; -fn create_flycheck(workspaces: &[ProjectWorkspace], config: &FlycheckConfig) -> Option { +fn create_flycheck( + workspaces: &[ProjectWorkspace], + config: &FlycheckConfig, + progress_src: &ProgressSource<(), String>, +) -> Option { // FIXME: Figure out the multi-workspace situation - workspaces.iter().find_map(|w| match w { + workspaces.iter().find_map(move |w| match w { ProjectWorkspace::Cargo { cargo, .. } => { let cargo_project_root = cargo.workspace_root().to_path_buf(); Some(Flycheck::new(config.clone(), cargo_project_root.into())) @@ -143,7 +147,12 @@ pub(crate) fn new( } change.set_crate_graph(crate_graph); - let flycheck = config.check.as_ref().and_then(|c| create_flycheck(&workspaces, c)); + let (flycheck_progress_receiver, flycheck_progress_src) = + ProgressSource::real_if(config.client_caps.work_done_progress); + let flycheck = config + .check + .as_ref() + .and_then(|c| create_flycheck(&workspaces, c, &flycheck_progress_src)); let mut analysis_host = AnalysisHost::new(lru_capacity); analysis_host.apply_change(change); @@ -153,6 +162,8 @@ pub(crate) fn new( loader, task_receiver, flycheck, + flycheck_progress_src, + flycheck_progress_receiver, diagnostics: Default::default(), mem_docs: FxHashSet::default(), vfs: Arc::new(RwLock::new((vfs, FxHashMap::default()))), @@ -170,8 +181,10 @@ pub(crate) fn new( pub(crate) fn update_configuration(&mut self, config: Config) { self.analysis_host.update_lru_capacity(config.lru_capacity); if config.check != self.config.check { - self.flycheck = - config.check.as_ref().and_then(|it| create_flycheck(&self.workspaces, it)); + self.flycheck = config + .check + .as_ref() + .and_then(|it| create_flycheck(&self.workspaces, it, &self.flycheck_progress_src)); } self.config = config;