From 5d401092f004f7f61e622b6c1d19a32799cbe31f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 25 Jun 2020 09:19:01 +0200 Subject: Minor rename --- crates/flycheck/src/lib.rs | 57 +++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 28 deletions(-) (limited to 'crates/flycheck') diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs index af75adbe2..0f23e97f7 100644 --- a/crates/flycheck/src/lib.rs +++ b/crates/flycheck/src/lib.rs @@ -10,7 +10,6 @@ use std::{ time::Instant, }; -use cargo_metadata::Message; use crossbeam_channel::{never, select, unbounded, Receiver, RecvError, Sender}; pub use cargo_metadata::diagnostic::{ @@ -51,12 +50,12 @@ impl fmt::Display for FlycheckConfig { pub struct FlycheckHandle { // XXX: drop order is significant cmd_send: Sender, - handle: jod_thread::JoinHandle<()>, + handle: jod_thread::JoinHandle, } impl FlycheckHandle { pub fn spawn( - sender: Box, + sender: Box, config: FlycheckConfig, workspace_root: PathBuf, ) -> FlycheckHandle { @@ -74,7 +73,7 @@ impl FlycheckHandle { } #[derive(Debug)] -pub enum CheckTask { +pub enum Message { /// Request a clearing of all cached diagnostics from the check watcher ClearDiagnostics, @@ -82,23 +81,23 @@ pub enum CheckTask { AddDiagnostic { workspace_root: PathBuf, diagnostic: Diagnostic }, /// Request check progress notification to client - Status(Status), + Progress(Progress), } #[derive(Debug)] -pub enum Status { +pub enum Progress { Being, - Progress(String), + DidCheckCrate(String), End, } -pub enum CheckCommand { +enum CheckCommand { /// Request re-start of check thread Update, } struct FlycheckActor { - sender: Box, + sender: Box, config: FlycheckConfig, workspace_root: PathBuf, last_update_req: Option, @@ -109,12 +108,12 @@ struct FlycheckActor { /// doesn't provide a way to read sub-process output without blocking, so we /// have to wrap sub-processes output handling in a thread and pass messages /// back over a channel. - check_process: Option>, + check_process: Option, } impl FlycheckActor { fn new( - sender: Box, + sender: Box, config: FlycheckConfig, workspace_root: PathBuf, ) -> FlycheckActor { @@ -154,15 +153,15 @@ impl FlycheckActor { if self.should_recheck() { self.last_update_req = None; - self.send(CheckTask::ClearDiagnostics); + self.send(Message::ClearDiagnostics); self.restart_check_process(); } } } fn clean_previous_results(&self) { - self.send(CheckTask::ClearDiagnostics); - self.send(CheckTask::Status(Status::End)); + self.send(Message::ClearDiagnostics); + self.send(Message::Progress(Progress::End)); } fn should_recheck(&mut self) -> bool { @@ -184,28 +183,28 @@ impl FlycheckActor { fn handle_message(&self, msg: CheckEvent) { match msg { CheckEvent::Begin => { - self.send(CheckTask::Status(Status::Being)); + self.send(Message::Progress(Progress::Being)); } CheckEvent::End => { - self.send(CheckTask::Status(Status::End)); + self.send(Message::Progress(Progress::End)); } - CheckEvent::Msg(Message::CompilerArtifact(msg)) => { - self.send(CheckTask::Status(Status::Progress(msg.target.name))); + CheckEvent::Msg(cargo_metadata::Message::CompilerArtifact(msg)) => { + self.send(Message::Progress(Progress::DidCheckCrate(msg.target.name))); } - CheckEvent::Msg(Message::CompilerMessage(msg)) => { - self.send(CheckTask::AddDiagnostic { + CheckEvent::Msg(cargo_metadata::Message::CompilerMessage(msg)) => { + self.send(Message::AddDiagnostic { workspace_root: self.workspace_root.clone(), diagnostic: msg.message, }); } - CheckEvent::Msg(Message::BuildScriptExecuted(_msg)) => {} - CheckEvent::Msg(Message::BuildFinished(_)) => {} - CheckEvent::Msg(Message::TextLine(_)) => {} - CheckEvent::Msg(Message::Unknown) => {} + CheckEvent::Msg(cargo_metadata::Message::BuildScriptExecuted(_)) + | CheckEvent::Msg(cargo_metadata::Message::BuildFinished(_)) + | CheckEvent::Msg(cargo_metadata::Message::TextLine(_)) + | CheckEvent::Msg(cargo_metadata::Message::Unknown) => {} } } @@ -256,9 +255,11 @@ impl FlycheckActor { let res = run_cargo(cmd, &mut |message| { // Skip certain kinds of messages to only spend time on what's useful match &message { - Message::CompilerArtifact(artifact) if artifact.fresh => return true, - Message::BuildScriptExecuted(_) => return true, - Message::Unknown => return true, + cargo_metadata::Message::CompilerArtifact(artifact) if artifact.fresh => { + return true + } + cargo_metadata::Message::BuildScriptExecuted(_) + | cargo_metadata::Message::Unknown => return true, _ => {} } @@ -278,7 +279,7 @@ impl FlycheckActor { })) } - fn send(&self, check_task: CheckTask) { + fn send(&self, check_task: Message) { (self.sender)(check_task) } } -- cgit v1.2.3