aboutsummaryrefslogtreecommitdiff
path: root/crates/rust-analyzer/src/reload.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-01-06 10:54:28 +0000
committerAleksey Kladov <[email protected]>2021-01-06 12:39:28 +0000
commitf7a15b5cd1df58e46066bbd27c90cb1ad7f9c316 (patch)
treedf2caa99c4558b9f2550420896ec9998566e1d5d /crates/rust-analyzer/src/reload.rs
parentc3104466596e85d7fa43b8e3ac015bcabd08fcce (diff)
More maintainable config
Rather than eagerly converting JSON, we losslessly keep it as is, and change the shape of user-submitted data at the last moment. This also allows us to remove a bunch of wrong Defaults
Diffstat (limited to 'crates/rust-analyzer/src/reload.rs')
-rw-r--r--crates/rust-analyzer/src/reload.rs26
1 files changed, 13 insertions, 13 deletions
diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs
index ce5cedeb3..51c24e966 100644
--- a/crates/rust-analyzer/src/reload.rs
+++ b/crates/rust-analyzer/src/reload.rs
@@ -19,12 +19,12 @@ impl GlobalState {
19 pub(crate) fn update_configuration(&mut self, config: Config) { 19 pub(crate) fn update_configuration(&mut self, config: Config) {
20 let _p = profile::span("GlobalState::update_configuration"); 20 let _p = profile::span("GlobalState::update_configuration");
21 let old_config = mem::replace(&mut self.config, config); 21 let old_config = mem::replace(&mut self.config, config);
22 if self.config.lru_capacity != old_config.lru_capacity { 22 if self.config.lru_capacity() != old_config.lru_capacity() {
23 self.analysis_host.update_lru_capacity(old_config.lru_capacity); 23 self.analysis_host.update_lru_capacity(self.config.lru_capacity());
24 } 24 }
25 if self.config.linked_projects != old_config.linked_projects { 25 if self.config.linked_projects() != old_config.linked_projects() {
26 self.fetch_workspaces() 26 self.fetch_workspaces()
27 } else if self.config.flycheck != old_config.flycheck { 27 } else if self.config.flycheck() != old_config.flycheck() {
28 self.reload_flycheck(); 28 self.reload_flycheck();
29 } 29 }
30 } 30 }
@@ -36,7 +36,7 @@ impl GlobalState {
36 Status::Loading | Status::NeedsReload => return, 36 Status::Loading | Status::NeedsReload => return,
37 Status::Ready | Status::Invalid => (), 37 Status::Ready | Status::Invalid => (),
38 } 38 }
39 if self.config.cargo_autoreload { 39 if self.config.cargo_autoreload() {
40 self.fetch_workspaces(); 40 self.fetch_workspaces();
41 } else { 41 } else {
42 self.transition(Status::NeedsReload); 42 self.transition(Status::NeedsReload);
@@ -94,8 +94,8 @@ impl GlobalState {
94 pub(crate) fn fetch_workspaces(&mut self) { 94 pub(crate) fn fetch_workspaces(&mut self) {
95 log::info!("will fetch workspaces"); 95 log::info!("will fetch workspaces");
96 self.task_pool.handle.spawn({ 96 self.task_pool.handle.spawn({
97 let linked_projects = self.config.linked_projects.clone(); 97 let linked_projects = self.config.linked_projects();
98 let cargo_config = self.config.cargo.clone(); 98 let cargo_config = self.config.cargo();
99 move || { 99 move || {
100 let workspaces = linked_projects 100 let workspaces = linked_projects
101 .iter() 101 .iter()
@@ -143,7 +143,7 @@ impl GlobalState {
143 return; 143 return;
144 } 144 }
145 145
146 if let FilesWatcher::Client = self.config.files.watcher { 146 if let FilesWatcher::Client = self.config.files().watcher {
147 let registration_options = lsp_types::DidChangeWatchedFilesRegistrationOptions { 147 let registration_options = lsp_types::DidChangeWatchedFilesRegistrationOptions {
148 watchers: workspaces 148 watchers: workspaces
149 .iter() 149 .iter()
@@ -170,9 +170,9 @@ impl GlobalState {
170 170
171 let project_folders = ProjectFolders::new(&workspaces); 171 let project_folders = ProjectFolders::new(&workspaces);
172 172
173 self.proc_macro_client = match &self.config.proc_macro_srv { 173 self.proc_macro_client = match self.config.proc_macro_srv() {
174 None => None, 174 None => None,
175 Some((path, args)) => match ProcMacroClient::extern_process(path.into(), args) { 175 Some((path, args)) => match ProcMacroClient::extern_process(path.clone(), args) {
176 Ok(it) => Some(it), 176 Ok(it) => Some(it),
177 Err(err) => { 177 Err(err) => {
178 log::error!( 178 log::error!(
@@ -185,7 +185,7 @@ impl GlobalState {
185 }, 185 },
186 }; 186 };
187 187
188 let watch = match self.config.files.watcher { 188 let watch = match self.config.files().watcher {
189 FilesWatcher::Client => vec![], 189 FilesWatcher::Client => vec![],
190 FilesWatcher::Notify => project_folders.watch, 190 FilesWatcher::Notify => project_folders.watch,
191 }; 191 };
@@ -211,7 +211,7 @@ impl GlobalState {
211 }; 211 };
212 for ws in workspaces.iter() { 212 for ws in workspaces.iter() {
213 crate_graph.extend(ws.to_crate_graph( 213 crate_graph.extend(ws.to_crate_graph(
214 self.config.cargo.target.as_deref(), 214 self.config.cargo().target.as_deref(),
215 self.proc_macro_client.as_ref(), 215 self.proc_macro_client.as_ref(),
216 &mut load, 216 &mut load,
217 )); 217 ));
@@ -231,7 +231,7 @@ impl GlobalState {
231 } 231 }
232 232
233 fn reload_flycheck(&mut self) { 233 fn reload_flycheck(&mut self) {
234 let config = match self.config.flycheck.clone() { 234 let config = match self.config.flycheck() {
235 Some(it) => it, 235 Some(it) => it,
236 None => { 236 None => {
237 self.flycheck = Vec::new(); 237 self.flycheck = Vec::new();