]> git.lizzy.rs Git - rust.git/blobdiff - crates/rust-analyzer/src/global_state.rs
Merge branch 'Veetaha-feat/sync-branch'
[rust.git] / crates / rust-analyzer / src / global_state.rs
index 87f3fe4db8d3c57c0552c861b34e5a8e015d8ff8..7759c0ae309f9e0a38eb16ec3f0da1c4c2b3cb41 100644 (file)
 };
 use rustc_hash::{FxHashMap, FxHashSet};
 
-fn create_flycheck(workspaces: &[ProjectWorkspace], config: &FlycheckConfig) -> Option<Flycheck> {
+fn create_flycheck(
+    workspaces: &[ProjectWorkspace],
+    config: &FlycheckConfig,
+    progress_src: &ProgressSource<(), String>,
+) -> Option<Flycheck> {
     // 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;