mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 20:43:21 +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
|
||||
/// `Cargo.toml` changes.
|
||||
cargo_autoreload: bool = "true",
|
||||
/// Activate all available features.
|
||||
/// Activate all available features (`--all-features`).
|
||||
cargo_allFeatures: bool = "false",
|
||||
/// List of features to activate.
|
||||
cargo_features: Vec<String> = "[]",
|
||||
|
@ -55,10 +55,10 @@ config_data! {
|
|||
|
||||
/// Run specified `cargo check` command for diagnostics on save.
|
||||
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#`.
|
||||
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",
|
||||
/// Cargo command to use for `cargo check`.
|
||||
checkOnSave_command: String = "\"check\"",
|
||||
|
@ -844,15 +844,32 @@ mod tests {
|
|||
fn schema_in_sync_with_package_json() {
|
||||
let s = Config::json_schema();
|
||||
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 = fs::read_to_string(&package_json).unwrap();
|
||||
let package_json_path = project_dir().join("editors/code/package.json");
|
||||
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);
|
||||
|
||||
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]
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
[[rust-analyzer.cargo.autoreload]]rust-analyzer.cargo.autoreload (default: `true`)::
|
||||
Automatically refresh project info via `cargo metadata` on `Cargo.toml` changes.
|
||||
[[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: `[]`)::
|
||||
List of features to activate.
|
||||
[[rust-analyzer.cargo.loadOutDirsFromCheck]]rust-analyzer.cargo.loadOutDirsFromCheck (default: `false`)::
|
||||
|
@ -21,9 +21,9 @@
|
|||
[[rust-analyzer.checkOnSave.enable]]rust-analyzer.checkOnSave.enable (default: `true`)::
|
||||
Run specified `cargo check` command for diagnostics on save.
|
||||
[[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`)::
|
||||
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"`)::
|
||||
Cargo command to use for `cargo check`.
|
||||
[[rust-analyzer.checkOnSave.noDefaultFeatures]]rust-analyzer.checkOnSave.noDefaultFeatures (default: `null`)::
|
||||
|
|
|
@ -349,6 +349,7 @@
|
|||
"default": {},
|
||||
"markdownDescription": "Optional settings passed to the debug engine. Example: `{ \"lldb\": { \"terminal\":\"external\"} }`"
|
||||
},
|
||||
"$generated-start": false,
|
||||
"rust-analyzer.assist.importMergeBehavior": {
|
||||
"markdownDescription": "The strategy to use when inserting new imports or merging imports.",
|
||||
"default": "full",
|
||||
|
@ -390,7 +391,7 @@
|
|||
"type": "boolean"
|
||||
},
|
||||
"rust-analyzer.cargo.allFeatures": {
|
||||
"markdownDescription": "Activate all available features.",
|
||||
"markdownDescription": "Activate all available features (`--all-features`).",
|
||||
"default": false,
|
||||
"type": "boolean"
|
||||
},
|
||||
|
@ -431,7 +432,7 @@
|
|||
"type": "boolean"
|
||||
},
|
||||
"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,
|
||||
"type": [
|
||||
"null",
|
||||
|
@ -439,7 +440,7 @@
|
|||
]
|
||||
},
|
||||
"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,
|
||||
"type": "boolean"
|
||||
},
|
||||
|
@ -718,7 +719,8 @@
|
|||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"$generated-end": false
|
||||
}
|
||||
},
|
||||
"problemPatterns": [
|
||||
|
|
Loading…
Reference in a new issue