aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-04-06 10:35:40 +0100
committerAleksey Kladov <[email protected]>2021-04-06 10:35:40 +0100
commit9ca59733e396c47fd3ab4c07c9567e9ec67a849c (patch)
tree8b8e016b80dbdafc1aa73acf3f7645654b07aad7
parentaaa8c208b12e3ddb1b4a7fd3d843182ae12cdae5 (diff)
Improve readability
It's better to order functions in the order they are called, if there's ordering between them.
-rw-r--r--crates/rust-analyzer/src/reload.rs57
1 files 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 {
117 } 117 }
118 } 118 }
119 119
120 pub(crate) fn fetch_build_data_request(&mut self, build_data_collector: BuildDataCollector) {
121 self.fetch_build_data_queue.request_op(build_data_collector);
122 }
123
124 pub(crate) fn fetch_build_data_if_needed(&mut self) {
125 let mut build_data_collector = match self.fetch_build_data_queue.should_start_op() {
126 Some(it) => it,
127 None => return,
128 };
129 self.task_pool.handle.spawn_with_sender(move |sender| {
130 sender.send(Task::FetchBuildData(BuildDataProgress::Begin)).unwrap();
131
132 let progress = {
133 let sender = sender.clone();
134 move |msg| {
135 sender.send(Task::FetchBuildData(BuildDataProgress::Report(msg))).unwrap()
136 }
137 };
138 let res = build_data_collector.collect(&progress);
139 sender.send(Task::FetchBuildData(BuildDataProgress::End(res))).unwrap();
140 });
141 }
142 pub(crate) fn fetch_build_data_completed(
143 &mut self,
144 build_data: anyhow::Result<BuildDataResult>,
145 ) {
146 self.fetch_build_data_queue.op_completed(Some(build_data))
147 }
148
149 pub(crate) fn fetch_workspaces_request(&mut self) { 120 pub(crate) fn fetch_workspaces_request(&mut self) {
150 self.fetch_workspaces_queue.request_op(()) 121 self.fetch_workspaces_queue.request_op(())
151 } 122 }
@@ -204,6 +175,34 @@ impl GlobalState {
204 self.fetch_workspaces_queue.op_completed(workspaces) 175 self.fetch_workspaces_queue.op_completed(workspaces)
205 } 176 }
206 177
178 pub(crate) fn fetch_build_data_request(&mut self, build_data_collector: BuildDataCollector) {
179 self.fetch_build_data_queue.request_op(build_data_collector);
180 }
181 pub(crate) fn fetch_build_data_if_needed(&mut self) {
182 let mut build_data_collector = match self.fetch_build_data_queue.should_start_op() {
183 Some(it) => it,
184 None => return,
185 };
186 self.task_pool.handle.spawn_with_sender(move |sender| {
187 sender.send(Task::FetchBuildData(BuildDataProgress::Begin)).unwrap();
188
189 let progress = {
190 let sender = sender.clone();
191 move |msg| {
192 sender.send(Task::FetchBuildData(BuildDataProgress::Report(msg))).unwrap()
193 }
194 };
195 let res = build_data_collector.collect(&progress);
196 sender.send(Task::FetchBuildData(BuildDataProgress::End(res))).unwrap();
197 });
198 }
199 pub(crate) fn fetch_build_data_completed(
200 &mut self,
201 build_data: anyhow::Result<BuildDataResult>,
202 ) {
203 self.fetch_build_data_queue.op_completed(Some(build_data))
204 }
205
207 pub(crate) fn switch_workspaces(&mut self) { 206 pub(crate) fn switch_workspaces(&mut self) {
208 let _p = profile::span("GlobalState::switch_workspaces"); 207 let _p = profile::span("GlobalState::switch_workspaces");
209 let workspaces = self.fetch_workspaces_queue.last_op_result(); 208 let workspaces = self.fetch_workspaces_queue.last_op_result();