Revert "Remove unneeded send method"

This reverts commit 567bde603c.
This commit is contained in:
mo8it 2024-08-12 10:42:35 +02:00
parent 2ece0fbfef
commit 7cce80c173
3 changed files with 32 additions and 28 deletions

View file

@ -256,7 +256,7 @@ impl FlycheckActor {
}
fn report_progress(&self, progress: Progress) {
self.sender.send(FlycheckMessage::Progress { id: self.id, progress }).unwrap();
self.send(FlycheckMessage::Progress { id: self.id, progress });
}
fn next_event(&self, inbox: &Receiver<StateChange>) -> Option<Event> {
@ -329,9 +329,7 @@ impl FlycheckActor {
);
}
if self.status == FlycheckStatus::Started {
self.sender
.send(FlycheckMessage::ClearDiagnostics { id: self.id })
.unwrap();
self.send(FlycheckMessage::ClearDiagnostics { id: self.id });
}
self.report_progress(Progress::DidFinish(res));
self.status = FlycheckStatus::Finished;
@ -353,17 +351,13 @@ impl FlycheckActor {
"diagnostic received"
);
if self.status == FlycheckStatus::Started {
self.sender
.send(FlycheckMessage::ClearDiagnostics { id: self.id })
.unwrap();
self.send(FlycheckMessage::ClearDiagnostics { id: self.id });
}
self.sender
.send(FlycheckMessage::AddDiagnostic {
id: self.id,
workspace_root: self.root.clone(),
diagnostic: msg,
})
.unwrap();
self.send(FlycheckMessage::AddDiagnostic {
id: self.id,
workspace_root: self.root.clone(),
diagnostic: msg,
});
self.status = FlycheckStatus::DiagnosticSent;
}
},
@ -483,6 +477,10 @@ impl FlycheckActor {
cmd.args(args);
Some(cmd)
}
fn send(&self, check_task: FlycheckMessage) {
self.sender.send(check_task).unwrap();
}
}
#[allow(clippy::large_enum_variant)]

View file

@ -504,7 +504,7 @@ impl GlobalState {
handler: ReqHandler,
) {
let request = self.req_queue.outgoing.register(R::METHOD.to_owned(), params, handler);
self.sender.send(request.into()).unwrap();
self.send(request.into());
}
pub(crate) fn complete_request(&mut self, response: lsp_server::Response) {
@ -521,7 +521,7 @@ impl GlobalState {
params: N::Params,
) {
let not = lsp_server::Notification::new(N::METHOD.to_owned(), params);
self.sender.send(not.into()).unwrap();
self.send(not.into());
}
pub(crate) fn register_request(
@ -544,13 +544,13 @@ impl GlobalState {
let duration = start.elapsed();
tracing::debug!("handled {} - ({}) in {:0.2?}", method, response.id, duration);
self.sender.send(response.into()).unwrap();
self.send(response.into());
}
}
pub(crate) fn cancel(&mut self, request_id: lsp_server::RequestId) {
if let Some(response) = self.req_queue.incoming.cancel(request_id) {
self.sender.send(response.into()).unwrap();
self.send(response.into());
}
}
@ -558,6 +558,10 @@ impl GlobalState {
self.req_queue.incoming.is_completed(&request.id)
}
fn send(&self, message: lsp_server::Message) {
self.sender.send(message).unwrap()
}
pub(crate) fn publish_diagnostics(
&mut self,
uri: Url,

View file

@ -186,19 +186,17 @@ impl NotifyActor {
}
}
self.sender
.send(loader::Message::Progress {
n_total,
n_done: LoadingProgress::Finished,
config_version,
dir: None,
})
.unwrap();
self.send(loader::Message::Progress {
n_total,
n_done: LoadingProgress::Finished,
config_version,
dir: None,
});
}
Message::Invalidate(path) => {
let contents = read(path.as_path());
let files = vec![(path, contents)];
self.sender.send(loader::Message::Changed { files }).unwrap();
self.send(loader::Message::Changed { files });
}
},
Event::NotifyEvent(event) => {
@ -246,7 +244,7 @@ impl NotifyActor {
Some((path, contents))
})
.collect();
self.sender.send(loader::Message::Changed { files }).unwrap();
self.send(loader::Message::Changed { files });
}
}
}
@ -330,6 +328,10 @@ impl NotifyActor {
log_notify_error(watcher.watch(path, RecursiveMode::NonRecursive));
}
}
fn send(&self, msg: loader::Message) {
self.sender.send(msg).unwrap();
}
}
fn read(path: &AbsPath) -> Option<Vec<u8>> {