mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Minor rename
This commit is contained in:
parent
0ec5d4f55c
commit
5d401092f0
3 changed files with 49 additions and 49 deletions
|
@ -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<CheckCommand>,
|
||||
handle: jod_thread::JoinHandle<()>,
|
||||
handle: jod_thread::JoinHandle,
|
||||
}
|
||||
|
||||
impl FlycheckHandle {
|
||||
pub fn spawn(
|
||||
sender: Box<dyn Fn(CheckTask) + Send>,
|
||||
sender: Box<dyn Fn(Message) + Send>,
|
||||
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<dyn Fn(CheckTask) + Send>,
|
||||
sender: Box<dyn Fn(Message) + Send>,
|
||||
config: FlycheckConfig,
|
||||
workspace_root: PathBuf,
|
||||
last_update_req: Option<Instant>,
|
||||
|
@ -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<jod_thread::JoinHandle<()>>,
|
||||
check_process: Option<jod_thread::JoinHandle>,
|
||||
}
|
||||
|
||||
impl FlycheckActor {
|
||||
fn new(
|
||||
sender: Box<dyn Fn(CheckTask) + Send>,
|
||||
sender: Box<dyn Fn(Message) + Send>,
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue