mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Remove the need to manually sync config in package.json
This commit is contained in:
parent
21660f1d97
commit
c04b561e7e
3 changed files with 37 additions and 18 deletions
|
@ -39,7 +39,7 @@ config_data! {
|
||||||
/// Automatically refresh project info via `cargo metadata` on
|
/// Automatically refresh project info via `cargo metadata` on
|
||||||
/// `Cargo.toml` changes.
|
/// `Cargo.toml` changes.
|
||||||
cargo_autoreload: bool = "true",
|
cargo_autoreload: bool = "true",
|
||||||
/// Activate all available features.
|
/// Activate all available features (`--all-features`).
|
||||||
cargo_allFeatures: bool = "false",
|
cargo_allFeatures: bool = "false",
|
||||||
/// List of features to activate.
|
/// List of features to activate.
|
||||||
cargo_features: Vec<String> = "[]",
|
cargo_features: Vec<String> = "[]",
|
||||||
|
@ -55,10 +55,10 @@ config_data! {
|
||||||
|
|
||||||
/// Run specified `cargo check` command for diagnostics on save.
|
/// Run specified `cargo check` command for diagnostics on save.
|
||||||
checkOnSave_enable: bool = "true",
|
checkOnSave_enable: bool = "true",
|
||||||
/// Check with all features (will be passed as `--all-features`).
|
/// Check with all features (`--all-features`).
|
||||||
/// Defaults to `#rust-analyzer.cargo.allFeatures#`.
|
/// Defaults to `#rust-analyzer.cargo.allFeatures#`.
|
||||||
checkOnSave_allFeatures: Option<bool> = "null",
|
checkOnSave_allFeatures: Option<bool> = "null",
|
||||||
/// Check all targets and tests (will be passed as `--all-targets`).
|
/// Check all targets and tests (`--all-targets`).
|
||||||
checkOnSave_allTargets: bool = "true",
|
checkOnSave_allTargets: bool = "true",
|
||||||
/// Cargo command to use for `cargo check`.
|
/// Cargo command to use for `cargo check`.
|
||||||
checkOnSave_command: String = "\"check\"",
|
checkOnSave_command: String = "\"check\"",
|
||||||
|
@ -156,7 +156,7 @@ config_data! {
|
||||||
/// `rust-project.json`, or JSON objects in `rust-project.json` format.
|
/// `rust-project.json`, or JSON objects in `rust-project.json` format.
|
||||||
linkedProjects: Vec<ManifestOrProjectJson> = "[]",
|
linkedProjects: Vec<ManifestOrProjectJson> = "[]",
|
||||||
|
|
||||||
/// Number of syntax trees rust-analyzer keeps in memory. Defaults to 128.
|
/// Number of syntax trees rust-analyzer keeps in memory. Defaults to 128.
|
||||||
lruCapacity: Option<usize> = "null",
|
lruCapacity: Option<usize> = "null",
|
||||||
|
|
||||||
/// Whether to show `can't find Cargo.toml` error message.
|
/// Whether to show `can't find Cargo.toml` error message.
|
||||||
|
@ -844,15 +844,32 @@ mod tests {
|
||||||
fn schema_in_sync_with_package_json() {
|
fn schema_in_sync_with_package_json() {
|
||||||
let s = Config::json_schema();
|
let s = Config::json_schema();
|
||||||
let schema = format!("{:#}", s);
|
let schema = format!("{:#}", s);
|
||||||
let schema = schema.trim_start_matches('{').trim_end_matches('}');
|
let mut schema = schema
|
||||||
|
.trim_start_matches('{')
|
||||||
|
.trim_end_matches('}')
|
||||||
|
.replace(" ", " ")
|
||||||
|
.replace("\n", "\n ")
|
||||||
|
.trim_start_matches('\n')
|
||||||
|
.trim_end()
|
||||||
|
.to_string();
|
||||||
|
schema.push_str(",\n");
|
||||||
|
|
||||||
let package_json = project_dir().join("editors/code/package.json");
|
let package_json_path = project_dir().join("editors/code/package.json");
|
||||||
let package_json = fs::read_to_string(&package_json).unwrap();
|
let mut package_json = fs::read_to_string(&package_json_path).unwrap();
|
||||||
|
|
||||||
let p = remove_ws(&package_json);
|
let start_marker = " \"$generated-start\": false,\n";
|
||||||
|
let end_marker = " \"$generated-end\": false\n";
|
||||||
|
|
||||||
|
let start = package_json.find(start_marker).unwrap() + start_marker.len();
|
||||||
|
let end = package_json.find(end_marker).unwrap();
|
||||||
|
let p = remove_ws(&package_json[start..end]);
|
||||||
let s = remove_ws(&schema);
|
let s = remove_ws(&schema);
|
||||||
|
|
||||||
assert!(p.contains(&s), "update config in package.json. New config:\n{:#}", schema);
|
if !p.contains(&s) {
|
||||||
|
package_json.replace_range(start..end, &schema);
|
||||||
|
fs::write(&package_json_path, &mut package_json).unwrap();
|
||||||
|
panic!("new config, updating package.json")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
[[rust-analyzer.cargo.autoreload]]rust-analyzer.cargo.autoreload (default: `true`)::
|
[[rust-analyzer.cargo.autoreload]]rust-analyzer.cargo.autoreload (default: `true`)::
|
||||||
Automatically refresh project info via `cargo metadata` on `Cargo.toml` changes.
|
Automatically refresh project info via `cargo metadata` on `Cargo.toml` changes.
|
||||||
[[rust-analyzer.cargo.allFeatures]]rust-analyzer.cargo.allFeatures (default: `false`)::
|
[[rust-analyzer.cargo.allFeatures]]rust-analyzer.cargo.allFeatures (default: `false`)::
|
||||||
Activate all available features.
|
Activate all available features (`--all-features`).
|
||||||
[[rust-analyzer.cargo.features]]rust-analyzer.cargo.features (default: `[]`)::
|
[[rust-analyzer.cargo.features]]rust-analyzer.cargo.features (default: `[]`)::
|
||||||
List of features to activate.
|
List of features to activate.
|
||||||
[[rust-analyzer.cargo.loadOutDirsFromCheck]]rust-analyzer.cargo.loadOutDirsFromCheck (default: `false`)::
|
[[rust-analyzer.cargo.loadOutDirsFromCheck]]rust-analyzer.cargo.loadOutDirsFromCheck (default: `false`)::
|
||||||
|
@ -21,9 +21,9 @@
|
||||||
[[rust-analyzer.checkOnSave.enable]]rust-analyzer.checkOnSave.enable (default: `true`)::
|
[[rust-analyzer.checkOnSave.enable]]rust-analyzer.checkOnSave.enable (default: `true`)::
|
||||||
Run specified `cargo check` command for diagnostics on save.
|
Run specified `cargo check` command for diagnostics on save.
|
||||||
[[rust-analyzer.checkOnSave.allFeatures]]rust-analyzer.checkOnSave.allFeatures (default: `null`)::
|
[[rust-analyzer.checkOnSave.allFeatures]]rust-analyzer.checkOnSave.allFeatures (default: `null`)::
|
||||||
Check with all features (will be passed as `--all-features`). Defaults to `#rust-analyzer.cargo.allFeatures#`.
|
Check with all features (`--all-features`). Defaults to `#rust-analyzer.cargo.allFeatures#`.
|
||||||
[[rust-analyzer.checkOnSave.allTargets]]rust-analyzer.checkOnSave.allTargets (default: `true`)::
|
[[rust-analyzer.checkOnSave.allTargets]]rust-analyzer.checkOnSave.allTargets (default: `true`)::
|
||||||
Check all targets and tests (will be passed as `--all-targets`).
|
Check all targets and tests (`--all-targets`).
|
||||||
[[rust-analyzer.checkOnSave.command]]rust-analyzer.checkOnSave.command (default: `"check"`)::
|
[[rust-analyzer.checkOnSave.command]]rust-analyzer.checkOnSave.command (default: `"check"`)::
|
||||||
Cargo command to use for `cargo check`.
|
Cargo command to use for `cargo check`.
|
||||||
[[rust-analyzer.checkOnSave.noDefaultFeatures]]rust-analyzer.checkOnSave.noDefaultFeatures (default: `null`)::
|
[[rust-analyzer.checkOnSave.noDefaultFeatures]]rust-analyzer.checkOnSave.noDefaultFeatures (default: `null`)::
|
||||||
|
@ -91,7 +91,7 @@
|
||||||
[[rust-analyzer.linkedProjects]]rust-analyzer.linkedProjects (default: `[]`)::
|
[[rust-analyzer.linkedProjects]]rust-analyzer.linkedProjects (default: `[]`)::
|
||||||
Disable project auto-discovery in favor of explicitly specified set of projects.\n\nElements must be paths pointing to `Cargo.toml`, `rust-project.json`, or JSON objects in `rust-project.json` format.
|
Disable project auto-discovery in favor of explicitly specified set of projects.\n\nElements must be paths pointing to `Cargo.toml`, `rust-project.json`, or JSON objects in `rust-project.json` format.
|
||||||
[[rust-analyzer.lruCapacity]]rust-analyzer.lruCapacity (default: `null`)::
|
[[rust-analyzer.lruCapacity]]rust-analyzer.lruCapacity (default: `null`)::
|
||||||
Number of syntax trees rust-analyzer keeps in memory. Defaults to 128.
|
Number of syntax trees rust-analyzer keeps in memory. Defaults to 128.
|
||||||
[[rust-analyzer.notifications.cargoTomlNotFound]]rust-analyzer.notifications.cargoTomlNotFound (default: `true`)::
|
[[rust-analyzer.notifications.cargoTomlNotFound]]rust-analyzer.notifications.cargoTomlNotFound (default: `true`)::
|
||||||
Whether to show `can't find Cargo.toml` error message.
|
Whether to show `can't find Cargo.toml` error message.
|
||||||
[[rust-analyzer.procMacro.enable]]rust-analyzer.procMacro.enable (default: `false`)::
|
[[rust-analyzer.procMacro.enable]]rust-analyzer.procMacro.enable (default: `false`)::
|
||||||
|
|
|
@ -349,6 +349,7 @@
|
||||||
"default": {},
|
"default": {},
|
||||||
"markdownDescription": "Optional settings passed to the debug engine. Example: `{ \"lldb\": { \"terminal\":\"external\"} }`"
|
"markdownDescription": "Optional settings passed to the debug engine. Example: `{ \"lldb\": { \"terminal\":\"external\"} }`"
|
||||||
},
|
},
|
||||||
|
"$generated-start": false,
|
||||||
"rust-analyzer.assist.importMergeBehavior": {
|
"rust-analyzer.assist.importMergeBehavior": {
|
||||||
"markdownDescription": "The strategy to use when inserting new imports or merging imports.",
|
"markdownDescription": "The strategy to use when inserting new imports or merging imports.",
|
||||||
"default": "full",
|
"default": "full",
|
||||||
|
@ -390,7 +391,7 @@
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
"rust-analyzer.cargo.allFeatures": {
|
"rust-analyzer.cargo.allFeatures": {
|
||||||
"markdownDescription": "Activate all available features.",
|
"markdownDescription": "Activate all available features (`--all-features`).",
|
||||||
"default": false,
|
"default": false,
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
|
@ -431,7 +432,7 @@
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
"rust-analyzer.checkOnSave.allFeatures": {
|
"rust-analyzer.checkOnSave.allFeatures": {
|
||||||
"markdownDescription": "Check with all features (will be passed as `--all-features`). Defaults to `#rust-analyzer.cargo.allFeatures#`.",
|
"markdownDescription": "Check with all features (`--all-features`). Defaults to `#rust-analyzer.cargo.allFeatures#`.",
|
||||||
"default": null,
|
"default": null,
|
||||||
"type": [
|
"type": [
|
||||||
"null",
|
"null",
|
||||||
|
@ -439,7 +440,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"rust-analyzer.checkOnSave.allTargets": {
|
"rust-analyzer.checkOnSave.allTargets": {
|
||||||
"markdownDescription": "Check all targets and tests (will be passed as `--all-targets`).",
|
"markdownDescription": "Check all targets and tests (`--all-targets`).",
|
||||||
"default": true,
|
"default": true,
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
|
@ -650,7 +651,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rust-analyzer.lruCapacity": {
|
"rust-analyzer.lruCapacity": {
|
||||||
"markdownDescription": "Number of syntax trees rust-analyzer keeps in memory. Defaults to 128.",
|
"markdownDescription": "Number of syntax trees rust-analyzer keeps in memory. Defaults to 128.",
|
||||||
"default": null,
|
"default": null,
|
||||||
"type": [
|
"type": [
|
||||||
"null",
|
"null",
|
||||||
|
@ -718,7 +719,8 @@
|
||||||
"items": {
|
"items": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"$generated-end": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"problemPatterns": [
|
"problemPatterns": [
|
||||||
|
|
Loading…
Reference in a new issue