Remove unneeded send method

This commit is contained in:
mo8it 2024-08-09 23:59:42 +02:00
parent 0b541ebbaa
commit 567bde603c
3 changed files with 28 additions and 32 deletions

View file

@ -256,7 +256,7 @@ impl FlycheckActor {
}
fn report_progress(&self, progress: Progress) {
self.send(FlycheckMessage::Progress { id: self.id, progress });
self.sender.send(FlycheckMessage::Progress { id: self.id, progress }).unwrap();
}
fn next_event(&self, inbox: &Receiver<StateChange>) -> Option<Event> {
@ -329,7 +329,9 @@ impl FlycheckActor {
);
}
if self.status == FlycheckStatus::Started {
self.send(FlycheckMessage::ClearDiagnostics { id: self.id });
self.sender
.send(FlycheckMessage::ClearDiagnostics { id: self.id })
.unwrap();
}
self.report_progress(Progress::DidFinish(res));
self.status = FlycheckStatus::Finished;
@ -351,13 +353,17 @@ impl FlycheckActor {
"diagnostic received"
);
if self.status == FlycheckStatus::Started {
self.send(FlycheckMessage::ClearDiagnostics { id: self.id });
self.sender
.send(FlycheckMessage::ClearDiagnostics { id: self.id })
.unwrap();
}
self.send(FlycheckMessage::AddDiagnostic {
id: self.id,
workspace_root: self.root.clone(),
diagnostic: msg,
});
self.sender
.send(FlycheckMessage::AddDiagnostic {
id: self.id,
workspace_root: self.root.clone(),
diagnostic: msg,
})
.unwrap();
self.status = FlycheckStatus::DiagnosticSent;
}
},
@ -477,10 +483,6 @@ 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.send(request.into());
self.sender.send(request.into()).unwrap();
}
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.send(not.into());
self.sender.send(not.into()).unwrap();
}
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.send(response.into());
self.sender.send(response.into()).unwrap();
}
}
pub(crate) fn cancel(&mut self, request_id: lsp_server::RequestId) {
if let Some(response) = self.req_queue.incoming.cancel(request_id) {
self.send(response.into());
self.sender.send(response.into()).unwrap();
}
}
@ -558,10 +558,6 @@ 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

@ -180,17 +180,19 @@ impl NotifyActor {
}
}
}
self.send(loader::Message::Progress {
n_total,
n_done: LoadingProgress::Finished,
config_version,
dir: None,
});
self.sender
.send(loader::Message::Progress {
n_total,
n_done: LoadingProgress::Finished,
config_version,
dir: None,
})
.unwrap();
}
Message::Invalidate(path) => {
let contents = read(path.as_path());
let files = vec![(path, contents)];
self.send(loader::Message::Changed { files });
self.sender.send(loader::Message::Changed { files }).unwrap();
}
},
Event::NotifyEvent(event) => {
@ -238,7 +240,7 @@ impl NotifyActor {
Some((path, contents))
})
.collect();
self.send(loader::Message::Changed { files });
self.sender.send(loader::Message::Changed { files }).unwrap();
}
}
}
@ -322,10 +324,6 @@ 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>> {