Compare the additional properties.

This commit is contained in:
Tom Alexander
2023-12-27 18:20:23 -05:00
parent f050e9b6a8
commit d552ef6569
3 changed files with 38 additions and 0 deletions

View File

@@ -6,6 +6,8 @@ use crate::compare::get_property_quoted_string;
use crate::compare::ElispFact;
use crate::compare::EmacsField;
use crate::compare::Token;
use crate::wasm::AdditionalProperties;
use crate::wasm::AdditionalPropertyValue;
use crate::wasm::WasmAstNode;
use crate::wasm::WasmDocument;
use crate::wasm::WasmHeadline;
@@ -416,3 +418,35 @@ fn wasm_compare_standard_properties<'b, 's>(
result.children.push(layer);
Ok(result)
}
fn wasm_compare_additional_properties<'b, 's>(
source: &'s str,
emacs: &'b Token<'s>,
wasm: &AdditionalProperties<'_, '_>,
) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>> {
let mut result = WasmDiffResult::default();
let mut layer = WasmDiffResult::default();
layer.name = "additional-properties".into();
for (property_name, property_value) in wasm.properties.iter() {
let emacs_property_name = format!(":{property_name}", property_name = property_name);
match property_value {
AdditionalPropertyValue::SingleString(wasm_value) => {
layer.extend(wasm_compare_property_quoted_string(
source,
emacs,
wasm,
&emacs_property_name,
|_| Some(wasm_value),
)?)?;
}
// TODO: similar to compare_affiliated_keywords
AdditionalPropertyValue::ListOfStrings(_) => todo!(),
AdditionalPropertyValue::OptionalPair { optval, val } => todo!(),
AdditionalPropertyValue::ObjectTree(_) => todo!(),
}
}
result.children.push(layer);
Ok(result)
}