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

View file

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

View file

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