compare_properties table row.

This commit is contained in:
Tom Alexander 2023-10-10 00:07:34 -04:00
parent 62815621e4
commit cf257443b0
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
1 changed files with 30 additions and 18 deletions

View File

@ -1750,28 +1750,40 @@ fn compare_table_row<'b, 's>(
emacs: &'b Token<'s>,
rust: &'b TableRow<'s>,
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
let children = emacs.as_list()?;
let mut child_status = Vec::new();
let mut this_status = DiffStatus::Good;
let mut child_status = Vec::new();
let mut message = None;
// Compare type
let row_type = get_property_unquoted_atom(emacs, ":type")?;
let rust_row_type = rust.get_type();
match (row_type, &rust_row_type) {
(Some("standard"), TableRowType::Standard) => {}
(Some("rule"), TableRowType::Rule) => {}
_ => {
this_status = DiffStatus::Bad;
message = Some(format!(
"Type mismatch (emacs != rust) {:?} != {:?}",
row_type, rust_row_type
));
}
}
compare_children(
source,
emacs,
&rust.children,
&mut child_status,
&mut this_status,
&mut message,
)?;
for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) {
child_status.push(compare_ast_node(source, emacs_child, rust_child.into())?);
for diff in compare_properties!(
source,
emacs,
rust,
(
EmacsField::Required(":type"),
|r| Some(match r.get_type() {
TableRowType::Standard => "standard",
TableRowType::Rule => "rule",
}),
compare_property_unquoted_atom
)
) {
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),
}
}
Ok(DiffResult {