aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-04-01 18:27:45 +0100
committerAleksey Kladov <[email protected]>2020-04-01 18:27:45 +0100
commit1225f719fe920587ebbe4170fc5aee1d87eadc22 (patch)
tree52156de3b6fa67e7d7310374c094aac579ff9195 /crates
parent1ac345a9f693e54aecd2ad70731acc75f982d2ae (diff)
Fix pointer syntax
Diffstat (limited to 'crates')
-rw-r--r--crates/rust-analyzer/src/config.rs56
-rw-r--r--crates/rust-analyzer/src/main_loop.rs10
2 files changed, 36 insertions, 30 deletions
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs
index d95ed9ec7..3c8f55f1e 100644
--- a/crates/rust-analyzer/src/config.rs
+++ b/crates/rust-analyzer/src/config.rs
@@ -99,56 +99,60 @@ impl Default for Config {
99impl Config { 99impl Config {
100 #[rustfmt::skip] 100 #[rustfmt::skip]
101 pub fn update(&mut self, value: &serde_json::Value) { 101 pub fn update(&mut self, value: &serde_json::Value) {
102 log::info!("Config::update({:#})", value);
103
102 let client_caps = self.client_caps.clone(); 104 let client_caps = self.client_caps.clone();
103 *self = Default::default(); 105 *self = Default::default();
104 self.client_caps = client_caps; 106 self.client_caps = client_caps;
105 107
106 set(value, "publishDecorations", &mut self.publish_decorations); 108 set(value, "/publishDecorations", &mut self.publish_decorations);
107 set(value, "excludeGlobs", &mut self.exclude_globs); 109 set(value, "/excludeGlobs", &mut self.exclude_globs);
108 set(value, "useClientWatching", &mut self.use_client_watching); 110 set(value, "/useClientWatching", &mut self.use_client_watching);
109 set(value, "lruCapacity", &mut self.lru_capacity); 111 set(value, "/lruCapacity", &mut self.lru_capacity);
110 112
111 set(value, "inlayHintsType", &mut self.inlay_hints.type_hints); 113 set(value, "/inlayHintsType", &mut self.inlay_hints.type_hints);
112 set(value, "inlayHintsParameter", &mut self.inlay_hints.parameter_hints); 114 set(value, "/inlayHintsParameter", &mut self.inlay_hints.parameter_hints);
113 set(value, "inlayHintsChaining", &mut self.inlay_hints.chaining_hints); 115 set(value, "/inlayHintsChaining", &mut self.inlay_hints.chaining_hints);
114 set(value, "inlayHintsMaxLength", &mut self.inlay_hints.max_length); 116 set(value, "/inlayHintsMaxLength", &mut self.inlay_hints.max_length);
115 117
116 if let Some(false) = get(value, "cargo_watch_enable") { 118 if let Some(false) = get(value, "cargo_watch_enable") {
117 self.check = None 119 self.check = None
118 } else { 120 } else {
119 if let Some(FlycheckConfig::CargoCommand { command, extra_args, all_targets }) = &mut self.check 121 if let Some(FlycheckConfig::CargoCommand { command, extra_args, all_targets }) = &mut self.check
120 { 122 {
121 set(value, "cargoWatchArgs", extra_args); 123 set(value, "/cargoWatchArgs", extra_args);
122 set(value, "cargoWatchCommand", command); 124 set(value, "/cargoWatchCommand", command);
123 set(value, "cargoWatchAllTargets", all_targets); 125 set(value, "/cargoWatchAllTargets", all_targets);
124 } 126 }
125 }; 127 };
126 128
127 set(value, "withSysroot", &mut self.with_sysroot); 129 set(value, "/withSysroot", &mut self.with_sysroot);
128 if let RustfmtConfig::Rustfmt { extra_args } = &mut self.rustfmt { 130 if let RustfmtConfig::Rustfmt { extra_args } = &mut self.rustfmt {
129 set(value, "rustfmtArgs", extra_args); 131 set(value, "/rustfmtArgs", extra_args);
130 } 132 }
131 133
132 set(value, "cargoFeatures/noDefaultFeatures", &mut self.cargo.no_default_features); 134 set(value, "/cargoFeatures/noDefaultFeatures", &mut self.cargo.no_default_features);
133 set(value, "cargoFeatures/allFeatures", &mut self.cargo.all_features); 135 set(value, "/cargoFeatures/allFeatures", &mut self.cargo.all_features);
134 set(value, "cargoFeatures/features", &mut self.cargo.features); 136 set(value, "/cargoFeatures/features", &mut self.cargo.features);
135 set(value, "cargoFeatures/loadOutDirsFromCheck", &mut self.cargo.load_out_dirs_from_check); 137 set(value, "/cargoFeatures/loadOutDirsFromCheck", &mut self.cargo.load_out_dirs_from_check);
138
139 set(value, "/vscodeLldb", &mut self.vscode_lldb);
136 140
137 set(value, "vscodeLldb", &mut self.vscode_lldb); 141 set(value, "/featureFlags/lsp.diagnostics", &mut self.publish_diagnostics);
142 set(value, "/featureFlags/notifications.workspace-loaded", &mut self.notifications.workspace_loaded);
143 set(value, "/featureFlags/notifications.cargo-toml-not-found", &mut self.notifications.cargo_toml_not_found);
144 set(value, "/featureFlags/completion.enable-postfix", &mut self.completion.enable_postfix_completions);
145 set(value, "/featureFlags/completion.insertion.add-call-parenthesis", &mut self.completion.add_call_parenthesis);
146 set(value, "/featureFlags/completion.insertion.add-argument-snippets", &mut self.completion.add_call_argument_snippets);
147 set(value, "/featureFlags/call-info.full", &mut self.call_info_full);
138 148
139 set(value, "featureFlags/lsp.diagnostics", &mut self.publish_diagnostics); 149 log::info!("Config::update() = {:#?}", self);
140 set(value, "featureFlags/notifications.workspace-loaded", &mut self.notifications.workspace_loaded);
141 set(value, "featureFlags/notifications.cargo-toml-not-found", &mut self.notifications.cargo_toml_not_found);
142 set(value, "featureFlags/completion.enable-postfix", &mut self.completion.enable_postfix_completions);
143 set(value, "featureFlags/completion.insertion.add-call-parenthesis", &mut self.completion.add_call_parenthesis);
144 set(value, "featureFlags/completion.insertion.add-argument-snippets", &mut self.completion.add_call_argument_snippets);
145 set(value, "featureFlags/call-info.full", &mut self.call_info_full);
146 150
147 fn get<'a, T: Deserialize<'a>>(value: &'a serde_json::Value, pointer: &str) -> Option<T> { 151 fn get<'a, T: Deserialize<'a>>(value: &'a serde_json::Value, pointer: &str) -> Option<T> {
148 value.pointer(pointer).and_then(|it| T::deserialize(it).ok()) 152 value.pointer(pointer).and_then(|it| T::deserialize(it).ok())
149 } 153 }
150 154
151 fn set<'a, T: Deserialize<'a>>(value: &'a serde_json::Value, pointer: &str, slot: &mut T) { 155 fn set<'a, T: Deserialize<'a> + std::fmt::Debug>(value: &'a serde_json::Value, pointer: &str, slot: &mut T) {
152 if let Some(new_value) = get(value, pointer) { 156 if let Some(new_value) = get(value, pointer) {
153 *slot = new_value 157 *slot = new_value
154 } 158 }
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index 00f92dbd5..45ae0ad9d 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -364,10 +364,12 @@ fn loop_turn(
364 (Some(err), _) => { 364 (Some(err), _) => {
365 log::error!("failed to fetch the server settings: {:?}", err) 365 log::error!("failed to fetch the server settings: {:?}", err)
366 } 366 }
367 (None, Some(new_config)) => { 367 (None, Some(configs)) => {
368 let mut config = world_state.config.clone(); 368 if let Some(new_config) = configs.get(0) {
369 config.update(&new_config); 369 let mut config = world_state.config.clone();
370 world_state.update_configuration(config); 370 config.update(&new_config);
371 world_state.update_configuration(config);
372 }
371 } 373 }
372 (None, None) => { 374 (None, None) => {
373 log::error!("received empty server settings response from the client") 375 log::error!("received empty server settings response from the client")