Skip to content

Commit 0039f6b

Browse files
committed
GlobalConfigInput etc
1 parent 33a4fe8 commit 0039f6b

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

crates/rust-analyzer/src/config.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ mod patch_old_style;
6060
// To deprecate an option by replacing it with another name use `new_name | `old_name` so that we keep
6161
// parsing the old name.
6262
config_data! {
63-
global: struct GlobalConfigData {
63+
global: struct GlobalConfigData <- GlobalConfigInput {
6464
/// Whether to insert #[must_use] when generating `as_` methods
6565
/// for enum variants.
6666
assist_emitMustUse: bool = false,
@@ -366,7 +366,7 @@ config_data! {
366366
}
367367

368368
config_data! {
369-
local: struct LocalConfigData {
369+
local: struct LocalConfigData <- LocalConfigInput {
370370
/// Toggles the additional completions that automatically add imports when completed.
371371
/// Note that your client must specify the `additionalTextEdits` LSP client capability to truly have this feature enabled.
372372
completion_autoimport_enable: bool = true,
@@ -583,7 +583,7 @@ config_data! {
583583
}
584584

585585
config_data! {
586-
client: struct ClientConfigData {}
586+
client: struct ClientConfigData <- ClientConfigInput {}
587587
}
588588

589589
impl Default for ConfigData {
@@ -2325,7 +2325,7 @@ macro_rules! _default_str {
23252325

23262326
macro_rules! _config_data {
23272327
// modname is for the tests
2328-
($modname:ident: struct $name:ident {
2328+
($modname:ident: struct $name:ident <- $input:ident {
23292329
$(
23302330
$(#[doc=$doc:literal])*
23312331
$field:ident $(| $alias:ident)*: $ty:ty = $(@$marker:ident: )? $default:expr,
@@ -2334,6 +2334,11 @@ macro_rules! _config_data {
23342334
#[allow(non_snake_case)]
23352335
#[derive(Debug, Clone, Serialize)]
23362336
struct $name { $($field: $ty,)* }
2337+
2338+
#[allow(non_snake_case)]
2339+
#[derive(Debug, Clone, Serialize)]
2340+
struct $input { $($field: Option<$ty>,)* }
2341+
23372342
impl $name {
23382343
#[allow(unused)]
23392344
fn from_json(json: &mut serde_json::Value, error_sink: &mut Vec<(String, serde_json::Error)>) -> $name {
@@ -2372,6 +2377,14 @@ macro_rules! _config_data {
23722377
},)*
23732378
])
23742379
}
2380+
2381+
fn apply_input(&mut self, input: $input) {
2382+
$(
2383+
if let Some(value) = input.$field {
2384+
self.$field = value;
2385+
}
2386+
)*
2387+
}
23752388
}
23762389

23772390
mod $modname {

0 commit comments

Comments
 (0)