mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
Refactor main_loop
This commit is contained in:
parent
dd20c2ec5b
commit
379a096de9
4 changed files with 406 additions and 418 deletions
|
@ -120,7 +120,13 @@ impl FlycheckActor {
|
|||
) -> FlycheckActor {
|
||||
FlycheckActor { sender, config, workspace_root, last_update_req: None, check_process: None }
|
||||
}
|
||||
|
||||
fn next_event(&self, inbox: &Receiver<Restart>) -> Option<Event> {
|
||||
let check_chan = self.check_process.as_ref().map(|(chan, _thread)| chan);
|
||||
select! {
|
||||
recv(inbox) -> msg => msg.ok().map(Event::Restart),
|
||||
recv(check_chan.unwrap_or(&never())) -> msg => Some(Event::CheckEvent(msg.ok())),
|
||||
}
|
||||
}
|
||||
fn run(&mut self, inbox: Receiver<Restart>) {
|
||||
// If we rerun the thread, we need to discard the previous check results first
|
||||
self.send(Message::ClearDiagnostics);
|
||||
|
@ -167,15 +173,6 @@ impl FlycheckActor {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn next_event(&self, inbox: &Receiver<Restart>) -> Option<Event> {
|
||||
let check_chan = self.check_process.as_ref().map(|(chan, _thread)| chan);
|
||||
select! {
|
||||
recv(inbox) -> msg => msg.ok().map(Event::Restart),
|
||||
recv(check_chan.unwrap_or(&never())) -> msg => Some(Event::CheckEvent(msg.ok())),
|
||||
}
|
||||
}
|
||||
|
||||
fn should_recheck(&mut self) -> bool {
|
||||
if let Some(_last_update_req) = &self.last_update_req {
|
||||
// We currently only request an update on save, as we need up to
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue