Skip to content

Commit 7f84964

Browse files
committed
Fix schema spell
1 parent a20bae9 commit 7f84964

File tree

2 files changed

+12
-24
lines changed

2 files changed

+12
-24
lines changed

crates/emmylua_code_analysis/resources/schema.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,12 +1000,12 @@
10001000
"EmmyrcSpecialSymbol": {
10011001
"type": "string",
10021002
"enum": [
1003-
"None",
1004-
"Require",
1005-
"Error",
1006-
"Assert",
1007-
"Type",
1008-
"Setmetatable"
1003+
"none",
1004+
"require",
1005+
"error",
1006+
"assert",
1007+
"type",
1008+
"setmetatable"
10091009
]
10101010
},
10111011
"EmmyrcStrict": {

crates/emmylua_code_analysis/src/config/configs/runtime.rs

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,10 @@ impl From<EmmyrcNonStdSymbol> for LuaNonStdSymbol {
180180
}
181181
}
182182

183-
#[derive(Debug, Clone, Copy, PartialEq, Eq, JsonSchema)]
183+
#[derive(Debug, Clone, Copy, PartialEq, Eq, JsonSchema, Serialize)]
184+
#[serde(rename_all = "lowercase")]
184185
pub enum EmmyrcSpecialSymbol {
186+
#[serde(rename = "none")]
185187
None,
186188
Require,
187189
Error,
@@ -195,35 +197,21 @@ impl<'de> Deserialize<'de> for EmmyrcSpecialSymbol {
195197
where
196198
D: Deserializer<'de>,
197199
{
200+
// 首先尝试使用默认的 derive 实现
198201
let s = String::deserialize(deserializer)?;
199202
match s.as_str() {
203+
"none" => Ok(EmmyrcSpecialSymbol::None),
200204
"require" => Ok(EmmyrcSpecialSymbol::Require),
201205
"error" => Ok(EmmyrcSpecialSymbol::Error),
202206
"assert" => Ok(EmmyrcSpecialSymbol::Assert),
203207
"type" => Ok(EmmyrcSpecialSymbol::Type),
204208
"setmetatable" => Ok(EmmyrcSpecialSymbol::Setmetatable),
209+
// 对于任何不匹配的值,返回 None
205210
_ => Ok(EmmyrcSpecialSymbol::None),
206211
}
207212
}
208213
}
209214

210-
impl<'serialize> Serialize for EmmyrcSpecialSymbol {
211-
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
212-
where
213-
S: serde::Serializer,
214-
{
215-
let s = match self {
216-
EmmyrcSpecialSymbol::None => "none",
217-
EmmyrcSpecialSymbol::Require => "require",
218-
EmmyrcSpecialSymbol::Error => "error",
219-
EmmyrcSpecialSymbol::Assert => "assert",
220-
EmmyrcSpecialSymbol::Type => "type",
221-
EmmyrcSpecialSymbol::Setmetatable => "setmetatable",
222-
};
223-
serializer.serialize_str(s)
224-
}
225-
}
226-
227215
impl From<EmmyrcSpecialSymbol> for Option<SpecialFunction> {
228216
fn from(symbol: EmmyrcSpecialSymbol) -> Self {
229217
match symbol {

0 commit comments

Comments
 (0)