compare_properties node property.

This commit is contained in:
Tom Alexander 2023-10-09 22:45:32 -04:00
parent d1184fa1d0
commit 7af5359e00
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -1625,36 +1625,38 @@ fn compare_property_drawer<'b, 's>(
} }
fn compare_node_property<'b, 's>( fn compare_node_property<'b, 's>(
_source: &'s str, source: &'s str,
emacs: &'b Token<'s>, emacs: &'b Token<'s>,
rust: &'b NodeProperty<'s>, rust: &'b NodeProperty<'s>,
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> { ) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
let child_status = Vec::new();
let mut this_status = DiffStatus::Good; let mut this_status = DiffStatus::Good;
let mut child_status = Vec::new();
let mut message = None; let mut message = None;
// Compare key assert_no_children(emacs, &mut this_status, &mut message)?;
let key =
get_property_quoted_string(emacs, ":key")?.ok_or("Node properties should have a key.")?;
if key != rust.property_name {
this_status = DiffStatus::Bad;
message = Some(format!(
"Key mismatch (emacs != rust) {:?} != {:?}",
key, rust.property_name
));
}
// Compare value for diff in compare_properties!(
let value = get_property_quoted_string(emacs, ":value")?; source,
match (value.as_ref(), rust.value) { emacs,
(None, None) => {} rust,
(Some(emacs_value), Some(rust_value)) if emacs_value == rust_value => {} (
_ => { EmacsField::Required(":key"),
this_status = DiffStatus::Bad; |r| Some(r.property_name),
message = Some(format!( compare_property_quoted_string
"Value mismatch (emacs != rust) {:?} != {:?}", ),
value, rust.value (
)); EmacsField::Required(":value"),
|r| r.value,
compare_property_quoted_string
)
) {
match diff {
ComparePropertiesResult::NoChange => {}
ComparePropertiesResult::SelfChange(new_status, new_message) => {
this_status = new_status;
message = new_message
}
ComparePropertiesResult::DiffEntry(diff_entry) => child_status.push(diff_entry),
} }
} }