mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-16 15:14:02 +00:00
Add simplistic config validation
This commit is contained in:
parent
6d7055e322
commit
b90df7997d
1 changed files with 13 additions and 0 deletions
|
@ -571,6 +571,9 @@ impl Config {
|
||||||
None => tracing::info!("Invalid snippet {}", name),
|
None => tracing::info!("Invalid snippet {}", name),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.validate(&mut errors);
|
||||||
|
|
||||||
if errors.is_empty() {
|
if errors.is_empty() {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
|
@ -578,6 +581,16 @@ impl Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn validate(&self, error_sink: &mut Vec<(String, serde_json::Error)>) {
|
||||||
|
use serde::de::Error;
|
||||||
|
if self.data.checkOnSave_command.is_empty() {
|
||||||
|
error_sink.push((
|
||||||
|
"/checkOnSave/command".to_string(),
|
||||||
|
serde_json::Error::custom("expected a non-empty string"),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn json_schema() -> serde_json::Value {
|
pub fn json_schema() -> serde_json::Value {
|
||||||
ConfigData::json_schema()
|
ConfigData::json_schema()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue