Starting a compare properties document function.

This commit is contained in:
Tom Alexander
2023-10-10 14:58:18 -04:00
parent 360b2d963d
commit a873794068
2 changed files with 91 additions and 0 deletions

View File

@@ -23,6 +23,7 @@ use super::sexp::unquote;
use super::sexp::Token;
use super::util::assert_no_children;
use super::util::compare_children;
use super::util::compare_children_iter;
use super::util::compare_standard_properties;
use super::util::get_property;
use super::util::get_property_boolean;
@@ -438,6 +439,63 @@ pub fn compare_document<'b, 's>(
}
fn _compare_document<'b, 's>(
source: &'s str,
emacs: &'b Token<'s>,
rust: &'b Document<'s>,
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
let mut this_status = DiffStatus::Good;
let mut child_status = Vec::new();
let mut message = None;
// compare_children_iter(
// source,
// emacs,
// rust.zeroth_section
// .iter()
// .map(Into::<AstNode>::into)
// .chain(rust.children.iter().map(Into::<AstNode>::into)),
// &mut child_status,
// &mut this_status,
// &mut message,
// )?;
for diff in compare_properties!(
source,
emacs,
rust,
// (
// EmacsField::Optional(":name"),
// |r| r.name,
// compare_property_quoted_string
// ),
(
EmacsField::Optional(":caption"),
compare_identity,
compare_noop
)
) {
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 {
status: this_status,
name: rust.get_elisp_name(),
message,
children: child_status,
rust_source: rust.get_source(),
emacs_token: emacs,
}
.into())
}
fn _old_compare_document<'b, 's>(
_source: &'s str,
emacs: &'b Token<'s>,
rust: &'b Document<'s>,