From 69e6924dd596cab20333c81b4557008b7a67bad0 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 25 Jun 2020 08:24:27 +0200 Subject: [PATCH] Use Handle/Actor terminology for flycheck --- crates/ra_flycheck/src/lib.rs | 18 +++++++++--------- crates/rust-analyzer/src/global_state.rs | 11 +++++++---- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/crates/ra_flycheck/src/lib.rs b/crates/ra_flycheck/src/lib.rs index 0e2ee8698c0..6751e5c3898 100644 --- a/crates/ra_flycheck/src/lib.rs +++ b/crates/ra_flycheck/src/lib.rs @@ -48,21 +48,21 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { /// diagnostics based on the output. /// The spawned thread is shut down when this struct is dropped. #[derive(Debug)] -pub struct Flycheck { +pub struct FlycheckHandle { // XXX: drop order is significant cmd_send: Sender, handle: jod_thread::JoinHandle<()>, pub task_recv: Receiver, } -impl Flycheck { - pub fn new(config: FlycheckConfig, workspace_root: PathBuf) -> Flycheck { +impl FlycheckHandle { + pub fn spawn(config: FlycheckConfig, workspace_root: PathBuf) -> FlycheckHandle { let (task_send, task_recv) = unbounded::(); let (cmd_send, cmd_recv) = unbounded::(); let handle = jod_thread::spawn(move || { - FlycheckThread::new(config, workspace_root).run(&task_send, &cmd_recv); + FlycheckActor::new(config, workspace_root).run(&task_send, &cmd_recv); }); - Flycheck { task_recv, cmd_send, handle } + FlycheckHandle { task_recv, cmd_send, handle } } /// Schedule a re-start of the cargo check worker. @@ -95,7 +95,7 @@ pub enum CheckCommand { Update, } -struct FlycheckThread { +struct FlycheckActor { config: FlycheckConfig, workspace_root: PathBuf, last_update_req: Option, @@ -109,9 +109,9 @@ struct FlycheckThread { check_process: Option>, } -impl FlycheckThread { - fn new(config: FlycheckConfig, workspace_root: PathBuf) -> FlycheckThread { - FlycheckThread { +impl FlycheckActor { + fn new(config: FlycheckConfig, workspace_root: PathBuf) -> FlycheckActor { + FlycheckActor { config, workspace_root, last_update_req: None, diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs index 64d4e2787ae..2a7111a888c 100644 --- a/crates/rust-analyzer/src/global_state.rs +++ b/crates/rust-analyzer/src/global_state.rs @@ -9,7 +9,7 @@ use lsp_types::Url; use parking_lot::RwLock; use ra_db::{CrateId, SourceRoot, VfsPath}; -use ra_flycheck::{Flycheck, FlycheckConfig}; +use ra_flycheck::{FlycheckConfig, FlycheckHandle}; use ra_ide::{Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId}; use ra_project_model::{CargoWorkspace, ProcMacroClient, ProjectWorkspace, Target}; use stdx::format_to; @@ -27,12 +27,15 @@ }; use rustc_hash::{FxHashMap, FxHashSet}; -fn create_flycheck(workspaces: &[ProjectWorkspace], config: &FlycheckConfig) -> Option { +fn create_flycheck( + workspaces: &[ProjectWorkspace], + config: &FlycheckConfig, +) -> Option { // FIXME: Figure out the multi-workspace situation 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())) + Some(FlycheckHandle::spawn(config.clone(), cargo_project_root.into())) } ProjectWorkspace::Json { .. } => { log::warn!("Cargo check watching only supported for cargo workspaces, disabling"); @@ -63,7 +66,7 @@ pub(crate) struct GlobalState { pub(crate) analysis_host: AnalysisHost, pub(crate) loader: Box, pub(crate) task_receiver: Receiver, - pub(crate) flycheck: Option, + pub(crate) flycheck: Option, pub(crate) diagnostics: DiagnosticCollection, pub(crate) mem_docs: FxHashSet, pub(crate) vfs: Arc)>>,