From 9ca59733e396c47fd3ab4c07c9567e9ec67a849c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 6 Apr 2021 12:35:40 +0300 Subject: Improve readability It's better to order functions in the order they are called, if there's ordering between them. --- crates/rust-analyzer/src/reload.rs | 57 +++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs index cdd6eae69..a8ae56070 100644 --- a/crates/rust-analyzer/src/reload.rs +++ b/crates/rust-analyzer/src/reload.rs @@ -117,35 +117,6 @@ impl GlobalState { } } - pub(crate) fn fetch_build_data_request(&mut self, build_data_collector: BuildDataCollector) { - self.fetch_build_data_queue.request_op(build_data_collector); - } - - pub(crate) fn fetch_build_data_if_needed(&mut self) { - let mut build_data_collector = match self.fetch_build_data_queue.should_start_op() { - Some(it) => it, - None => return, - }; - self.task_pool.handle.spawn_with_sender(move |sender| { - sender.send(Task::FetchBuildData(BuildDataProgress::Begin)).unwrap(); - - let progress = { - let sender = sender.clone(); - move |msg| { - sender.send(Task::FetchBuildData(BuildDataProgress::Report(msg))).unwrap() - } - }; - let res = build_data_collector.collect(&progress); - sender.send(Task::FetchBuildData(BuildDataProgress::End(res))).unwrap(); - }); - } - pub(crate) fn fetch_build_data_completed( - &mut self, - build_data: anyhow::Result, - ) { - self.fetch_build_data_queue.op_completed(Some(build_data)) - } - pub(crate) fn fetch_workspaces_request(&mut self) { self.fetch_workspaces_queue.request_op(()) } @@ -204,6 +175,34 @@ impl GlobalState { self.fetch_workspaces_queue.op_completed(workspaces) } + pub(crate) fn fetch_build_data_request(&mut self, build_data_collector: BuildDataCollector) { + self.fetch_build_data_queue.request_op(build_data_collector); + } + pub(crate) fn fetch_build_data_if_needed(&mut self) { + let mut build_data_collector = match self.fetch_build_data_queue.should_start_op() { + Some(it) => it, + None => return, + }; + self.task_pool.handle.spawn_with_sender(move |sender| { + sender.send(Task::FetchBuildData(BuildDataProgress::Begin)).unwrap(); + + let progress = { + let sender = sender.clone(); + move |msg| { + sender.send(Task::FetchBuildData(BuildDataProgress::Report(msg))).unwrap() + } + }; + let res = build_data_collector.collect(&progress); + sender.send(Task::FetchBuildData(BuildDataProgress::End(res))).unwrap(); + }); + } + pub(crate) fn fetch_build_data_completed( + &mut self, + build_data: anyhow::Result, + ) { + self.fetch_build_data_queue.op_completed(Some(build_data)) + } + pub(crate) fn switch_workspaces(&mut self) { let _p = profile::span("GlobalState::switch_workspaces"); let workspaces = self.fetch_workspaces_queue.last_op_result(); -- cgit v1.2.3