Remove some underscores from wasm schema to match elisp.

This commit is contained in:
Tom Alexander 2023-12-29 15:41:41 -05:00
parent adcd0de7e4
commit 5d31db39a4
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
3 changed files with 9 additions and 5 deletions

View File

@ -63,6 +63,7 @@ use super::WasmStandardProperties;
#[derive(Debug, Serialize, Deserialize)]
pub struct WasmAstNodeWrapper<I> {
#[serde(rename = "ast-node")]
pub(crate) ast_node: String,
#[serde(rename = "standard-properties")]
pub(crate) standard_properties: WasmStandardProperties,

View File

@ -10,8 +10,11 @@ use crate::types::StandardProperties;
pub(crate) struct WasmStandardProperties {
pub(crate) begin: usize,
pub(crate) end: usize,
#[serde(rename = "contents-begin")]
pub(crate) contents_begin: Option<usize>,
#[serde(rename = "contents-end")]
pub(crate) contents_end: Option<usize>,
#[serde(rename = "post-blank")]
pub(crate) post_blank: PostBlank,
}

View File

@ -87,7 +87,7 @@ fn compare_json_value<'b, 's>(
emacs: &'b Token<'s>,
) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>> {
match (value, emacs) {
(serde_json::Value::Object(wasm), Token::List(el)) if wasm.contains_key("ast_node") => {
(serde_json::Value::Object(wasm), Token::List(el)) if wasm.contains_key("ast-node") => {
// We hit a regular ast node.
compare_ast_node(source, el, wasm)
}
@ -139,7 +139,7 @@ fn compare_ast_node<'b, 's, 'p>(
.ok_or("Should have a name as the first child.")?
.as_atom()?;
let wasm_name = wasm
.get("ast_node")
.get("ast-node")
.ok_or("Should have a ast node type.")?
.as_str()
.ok_or("Ast node type should be a string.")?;
@ -248,9 +248,9 @@ fn compare_ast_node<'b, 's, 'p>(
for (emacs_value, wasm_name) in [
(emacs_standard_properties.begin, "begin"),
(emacs_standard_properties.end, "end"),
(emacs_standard_properties.contents_begin, "contents_begin"),
(emacs_standard_properties.contents_end, "contents_end"),
(emacs_standard_properties.post_blank, "post_blank"),
(emacs_standard_properties.contents_begin, "contents-begin"),
(emacs_standard_properties.contents_end, "contents-end"),
(emacs_standard_properties.post_blank, "post-blank"),
] {
match (emacs_value, wasm_standard_properties.get(wasm_name)) {
(None, None) => {}