diff options
author | Edwin Cheng <[email protected]> | 2021-01-07 17:08:46 +0000 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2021-01-07 17:18:58 +0000 |
commit | 2b2d699b35d69375def80fe51c6a8c3bfbe53828 (patch) | |
tree | 1c10b2986017fc1e756d2bce75250546cce9310b /crates/rust-analyzer/src/reload.rs | |
parent | 54eb87de0363cfba1d7104b8d37898fc120c029b (diff) |
Report progress for cargo metadata and output-dir
Diffstat (limited to 'crates/rust-analyzer/src/reload.rs')
-rw-r--r-- | crates/rust-analyzer/src/reload.rs | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs index 76b50931a..f4e084741 100644 --- a/crates/rust-analyzer/src/reload.rs +++ b/crates/rust-analyzer/src/reload.rs | |||
@@ -15,6 +15,13 @@ use crate::{ | |||
15 | }; | 15 | }; |
16 | use lsp_ext::StatusParams; | 16 | use lsp_ext::StatusParams; |
17 | 17 | ||
18 | #[derive(Debug)] | ||
19 | pub(crate) enum ProjectWorkspaceProgress { | ||
20 | Begin, | ||
21 | Report(String), | ||
22 | End, | ||
23 | } | ||
24 | |||
18 | impl GlobalState { | 25 | impl GlobalState { |
19 | pub(crate) fn update_configuration(&mut self, config: Config) { | 26 | pub(crate) fn update_configuration(&mut self, config: Config) { |
20 | let _p = profile::span("GlobalState::update_configuration"); | 27 | let _p = profile::span("GlobalState::update_configuration"); |
@@ -93,23 +100,42 @@ impl GlobalState { | |||
93 | } | 100 | } |
94 | pub(crate) fn fetch_workspaces(&mut self) { | 101 | pub(crate) fn fetch_workspaces(&mut self) { |
95 | log::info!("will fetch workspaces"); | 102 | log::info!("will fetch workspaces"); |
96 | self.task_pool.handle.spawn({ | 103 | |
104 | self.task_pool.handle.spawn_with_sender({ | ||
97 | let linked_projects = self.config.linked_projects(); | 105 | let linked_projects = self.config.linked_projects(); |
98 | let cargo_config = self.config.cargo(); | 106 | let cargo_config = self.config.cargo(); |
99 | move || { | 107 | |
108 | move |sender| { | ||
109 | let progress = { | ||
110 | let sender = sender.clone(); | ||
111 | move |msg| { | ||
112 | sender | ||
113 | .send(Task::FetchWorkspace(ProjectWorkspaceProgress::Report(msg))) | ||
114 | .unwrap() | ||
115 | } | ||
116 | }; | ||
117 | |||
118 | sender.send(Task::FetchWorkspace(ProjectWorkspaceProgress::Begin)).unwrap(); | ||
119 | |||
100 | let workspaces = linked_projects | 120 | let workspaces = linked_projects |
101 | .iter() | 121 | .iter() |
102 | .map(|project| match project { | 122 | .map(|project| match project { |
103 | LinkedProject::ProjectManifest(manifest) => { | 123 | LinkedProject::ProjectManifest(manifest) => { |
104 | project_model::ProjectWorkspace::load(manifest.clone(), &cargo_config) | 124 | project_model::ProjectWorkspace::load( |
125 | manifest.clone(), | ||
126 | &cargo_config, | ||
127 | &progress, | ||
128 | ) | ||
105 | } | 129 | } |
106 | LinkedProject::InlineJsonProject(it) => { | 130 | LinkedProject::InlineJsonProject(it) => { |
107 | project_model::ProjectWorkspace::load_inline(it.clone()) | 131 | project_model::ProjectWorkspace::load_inline(it.clone()) |
108 | } | 132 | } |
109 | }) | 133 | }) |
110 | .collect::<Vec<_>>(); | 134 | .collect::<Vec<_>>(); |
135 | |||
136 | sender.send(Task::FetchWorkspace(ProjectWorkspaceProgress::End)).unwrap(); | ||
111 | log::info!("did fetch workspaces {:?}", workspaces); | 137 | log::info!("did fetch workspaces {:?}", workspaces); |
112 | Task::Workspaces(workspaces) | 138 | sender.send(Task::Workspaces(workspaces)).unwrap() |
113 | } | 139 | } |
114 | }); | 140 | }); |
115 | } | 141 | } |