Compare node properties.

This commit is contained in:
Tom Alexander
2023-09-06 18:49:59 -04:00
parent 49afcf0db6
commit 6fc607cfe0
3 changed files with 50 additions and 5 deletions

View File

@@ -36,6 +36,7 @@ use crate::types::Keyword;
use crate::types::LatexEnvironment;
use crate::types::LatexFragment;
use crate::types::LineBreak;
use crate::types::NodeProperty;
use crate::types::Object;
use crate::types::OrgMacro;
use crate::types::Paragraph;
@@ -934,7 +935,7 @@ fn compare_property_drawer<'s>(
rust: &'s PropertyDrawer<'s>,
) -> Result<DiffEntry<'s>, Box<dyn std::error::Error>> {
let children = emacs.as_list()?;
let child_status = Vec::new();
let mut child_status = Vec::new();
let mut this_status = DiffStatus::Good;
let mut message = None;
let emacs_name = "property-drawer";
@@ -950,9 +951,8 @@ fn compare_property_drawer<'s>(
Ok(_) => {}
};
for (_emacs_child, _rust_child) in children.iter().skip(2).zip(rust.children.iter()) {
// TODO: What are node properties and are they the only legal child of property drawers?
// child_status.push(compare_element(source, emacs_child, rust_child)?);
for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) {
child_status.push(compare_node_property(source, emacs_child, rust_child)?);
}
Ok(DiffResult {
@@ -966,6 +966,40 @@ fn compare_property_drawer<'s>(
.into())
}
fn compare_node_property<'s>(
source: &'s str,
emacs: &'s Token<'s>,
rust: &'s NodeProperty<'s>,
) -> Result<DiffEntry<'s>, Box<dyn std::error::Error>> {
let child_status = Vec::new();
let mut this_status = DiffStatus::Good;
let mut message = None;
let emacs_name = "node-property";
if assert_name(emacs, emacs_name).is_err() {
this_status = DiffStatus::Bad;
}
match assert_bounds(source, emacs, rust) {
Err(err) => {
this_status = DiffStatus::Bad;
message = Some(err.to_string())
}
Ok(_) => {}
};
// TODO: Compare :key :value
Ok(DiffResult {
status: this_status,
name: emacs_name.to_owned(),
message,
children: child_status,
rust_source: rust.get_source(),
emacs_token: emacs,
}
.into())
}
fn compare_table<'s>(
source: &'s str,
emacs: &'s Token<'s>,