Make name mismatch report an error rather than abort everything.
This commit is contained in:
parent
a6d8c873d4
commit
94193d4fa5
@ -74,9 +74,11 @@ pub fn compare_document<'s>(
|
|||||||
rust: &'s Document<'s>,
|
rust: &'s Document<'s>,
|
||||||
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
||||||
let children = emacs.as_list()?;
|
let children = emacs.as_list()?;
|
||||||
assert_name(emacs, "org-data")?;
|
|
||||||
let mut child_status = Vec::new();
|
let mut child_status = Vec::new();
|
||||||
let mut this_status = DiffStatus::Good;
|
let mut this_status = DiffStatus::Good;
|
||||||
|
if assert_name(emacs, "org-data").is_err() {
|
||||||
|
this_status = DiffStatus::Bad;
|
||||||
|
}
|
||||||
|
|
||||||
// Skipping "org-data" and the first parameter which is often nil
|
// Skipping "org-data" and the first parameter which is often nil
|
||||||
for (i, token) in children.iter().skip(2).enumerate() {
|
for (i, token) in children.iter().skip(2).enumerate() {
|
||||||
@ -122,9 +124,11 @@ fn compare_section<'s>(
|
|||||||
rust: &'s Section<'s>,
|
rust: &'s Section<'s>,
|
||||||
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
||||||
let children = emacs.as_list()?;
|
let children = emacs.as_list()?;
|
||||||
assert_name(emacs, "section")?;
|
|
||||||
let mut child_status = Vec::new();
|
|
||||||
let mut this_status = DiffStatus::Good;
|
let mut this_status = DiffStatus::Good;
|
||||||
|
let mut child_status = Vec::new();
|
||||||
|
if assert_name(emacs, "section").is_err() {
|
||||||
|
this_status = DiffStatus::Bad;
|
||||||
|
}
|
||||||
|
|
||||||
if assert_bounds(source, emacs, rust).is_err() {
|
if assert_bounds(source, emacs, rust).is_err() {
|
||||||
this_status = DiffStatus::Bad;
|
this_status = DiffStatus::Bad;
|
||||||
@ -148,9 +152,11 @@ fn compare_heading<'s>(
|
|||||||
rust: &'s Heading<'s>,
|
rust: &'s Heading<'s>,
|
||||||
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
||||||
let children = emacs.as_list()?;
|
let children = emacs.as_list()?;
|
||||||
assert_name(emacs, "headline")?;
|
|
||||||
let mut child_status = Vec::new();
|
let mut child_status = Vec::new();
|
||||||
let mut this_status = DiffStatus::Good;
|
let mut this_status = DiffStatus::Good;
|
||||||
|
if assert_name(emacs, "headline").is_err() {
|
||||||
|
this_status = DiffStatus::Bad;
|
||||||
|
}
|
||||||
|
|
||||||
if assert_bounds(source, emacs, rust).is_err() {
|
if assert_bounds(source, emacs, rust).is_err() {
|
||||||
this_status = DiffStatus::Bad;
|
this_status = DiffStatus::Bad;
|
||||||
@ -197,9 +203,11 @@ fn compare_paragraph<'s>(
|
|||||||
rust: &'s Paragraph<'s>,
|
rust: &'s Paragraph<'s>,
|
||||||
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
||||||
let children = emacs.as_list()?;
|
let children = emacs.as_list()?;
|
||||||
assert_name(emacs, "paragraph")?;
|
|
||||||
let mut child_status = Vec::new();
|
let mut child_status = Vec::new();
|
||||||
let mut this_status = DiffStatus::Good;
|
let mut this_status = DiffStatus::Good;
|
||||||
|
if assert_name(emacs, "paragraph").is_err() {
|
||||||
|
this_status = DiffStatus::Bad;
|
||||||
|
}
|
||||||
|
|
||||||
if assert_bounds(source, emacs, rust).is_err() {
|
if assert_bounds(source, emacs, rust).is_err() {
|
||||||
this_status = DiffStatus::Bad;
|
this_status = DiffStatus::Bad;
|
||||||
@ -221,9 +229,11 @@ fn compare_plain_list<'s>(
|
|||||||
rust: &'s PlainList<'s>,
|
rust: &'s PlainList<'s>,
|
||||||
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
||||||
let children = emacs.as_list()?;
|
let children = emacs.as_list()?;
|
||||||
assert_name(emacs, "plain-list")?;
|
|
||||||
let mut child_status = Vec::new();
|
let mut child_status = Vec::new();
|
||||||
let mut this_status = DiffStatus::Good;
|
let mut this_status = DiffStatus::Good;
|
||||||
|
if assert_name(emacs, "plain-list").is_err() {
|
||||||
|
this_status = DiffStatus::Bad;
|
||||||
|
}
|
||||||
|
|
||||||
if assert_bounds(source, emacs, rust).is_err() {
|
if assert_bounds(source, emacs, rust).is_err() {
|
||||||
this_status = DiffStatus::Bad;
|
this_status = DiffStatus::Bad;
|
||||||
@ -247,9 +257,11 @@ fn compare_plain_list_item<'s>(
|
|||||||
rust: &'s PlainListItem<'s>,
|
rust: &'s PlainListItem<'s>,
|
||||||
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
||||||
let children = emacs.as_list()?;
|
let children = emacs.as_list()?;
|
||||||
assert_name(emacs, "item")?;
|
|
||||||
let mut child_status = Vec::new();
|
let mut child_status = Vec::new();
|
||||||
let mut this_status = DiffStatus::Good;
|
let mut this_status = DiffStatus::Good;
|
||||||
|
if assert_name(emacs, "item").is_err() {
|
||||||
|
this_status = DiffStatus::Bad;
|
||||||
|
}
|
||||||
|
|
||||||
if assert_bounds(source, emacs, rust).is_err() {
|
if assert_bounds(source, emacs, rust).is_err() {
|
||||||
this_status = DiffStatus::Bad;
|
this_status = DiffStatus::Bad;
|
||||||
@ -273,16 +285,18 @@ fn compare_greater_block<'s>(
|
|||||||
rust: &'s GreaterBlock<'s>,
|
rust: &'s GreaterBlock<'s>,
|
||||||
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
||||||
let children = emacs.as_list()?;
|
let children = emacs.as_list()?;
|
||||||
assert_name(
|
let mut child_status = Vec::new();
|
||||||
|
let mut this_status = DiffStatus::Good;
|
||||||
|
if assert_name(
|
||||||
emacs,
|
emacs,
|
||||||
match rust.name.to_lowercase().as_str() {
|
match rust.name.to_lowercase().as_str() {
|
||||||
"center" => "center-block",
|
"center" => "center-block",
|
||||||
"quote" => "quote-block",
|
"quote" => "quote-block",
|
||||||
_ => todo!(),
|
_ => todo!(),
|
||||||
},
|
},
|
||||||
)?;
|
).is_err() {
|
||||||
let mut child_status = Vec::new();
|
this_status = DiffStatus::Bad;
|
||||||
let mut this_status = DiffStatus::Good;
|
}
|
||||||
|
|
||||||
if assert_bounds(source, emacs, rust).is_err() {
|
if assert_bounds(source, emacs, rust).is_err() {
|
||||||
this_status = DiffStatus::Bad;
|
this_status = DiffStatus::Bad;
|
||||||
@ -306,9 +320,11 @@ fn compare_dynamic_block<'s>(
|
|||||||
rust: &'s DynamicBlock<'s>,
|
rust: &'s DynamicBlock<'s>,
|
||||||
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
||||||
let children = emacs.as_list()?;
|
let children = emacs.as_list()?;
|
||||||
assert_name(emacs, "dynamic-block")?;
|
|
||||||
let mut child_status = Vec::new();
|
let mut child_status = Vec::new();
|
||||||
let mut this_status = DiffStatus::Good;
|
let mut this_status = DiffStatus::Good;
|
||||||
|
if assert_name(emacs, "dynamic-block").is_err() {
|
||||||
|
this_status = DiffStatus::Bad;
|
||||||
|
}
|
||||||
|
|
||||||
if assert_bounds(source, emacs, rust).is_err() {
|
if assert_bounds(source, emacs, rust).is_err() {
|
||||||
this_status = DiffStatus::Bad;
|
this_status = DiffStatus::Bad;
|
||||||
@ -332,9 +348,11 @@ fn compare_footnote_definition<'s>(
|
|||||||
rust: &'s FootnoteDefinition<'s>,
|
rust: &'s FootnoteDefinition<'s>,
|
||||||
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
||||||
let children = emacs.as_list()?;
|
let children = emacs.as_list()?;
|
||||||
assert_name(emacs, "footnote-definition")?;
|
|
||||||
let mut child_status = Vec::new();
|
let mut child_status = Vec::new();
|
||||||
let mut this_status = DiffStatus::Good;
|
let mut this_status = DiffStatus::Good;
|
||||||
|
if assert_name(emacs, "footnote-definition").is_err() {
|
||||||
|
this_status = DiffStatus::Bad;
|
||||||
|
}
|
||||||
|
|
||||||
if assert_bounds(source, emacs, rust).is_err() {
|
if assert_bounds(source, emacs, rust).is_err() {
|
||||||
this_status = DiffStatus::Bad;
|
this_status = DiffStatus::Bad;
|
||||||
@ -358,9 +376,11 @@ fn compare_comment<'s>(
|
|||||||
rust: &'s Comment<'s>,
|
rust: &'s Comment<'s>,
|
||||||
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
||||||
let children = emacs.as_list()?;
|
let children = emacs.as_list()?;
|
||||||
assert_name(emacs, "comment")?;
|
|
||||||
let mut child_status = Vec::new();
|
let mut child_status = Vec::new();
|
||||||
let mut this_status = DiffStatus::Good;
|
let mut this_status = DiffStatus::Good;
|
||||||
|
if assert_name(emacs, "comment").is_err() {
|
||||||
|
this_status = DiffStatus::Bad;
|
||||||
|
}
|
||||||
|
|
||||||
if assert_bounds(source, emacs, rust).is_err() {
|
if assert_bounds(source, emacs, rust).is_err() {
|
||||||
this_status = DiffStatus::Bad;
|
this_status = DiffStatus::Bad;
|
||||||
@ -380,9 +400,11 @@ fn compare_drawer<'s>(
|
|||||||
rust: &'s Drawer<'s>,
|
rust: &'s Drawer<'s>,
|
||||||
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
||||||
let children = emacs.as_list()?;
|
let children = emacs.as_list()?;
|
||||||
assert_name(emacs, "drawer")?;
|
|
||||||
let mut child_status = Vec::new();
|
let mut child_status = Vec::new();
|
||||||
let mut this_status = DiffStatus::Good;
|
let mut this_status = DiffStatus::Good;
|
||||||
|
if assert_name(emacs, "drawer").is_err() {
|
||||||
|
this_status = DiffStatus::Bad;
|
||||||
|
}
|
||||||
|
|
||||||
if assert_bounds(source, emacs, rust).is_err() {
|
if assert_bounds(source, emacs, rust).is_err() {
|
||||||
this_status = DiffStatus::Bad;
|
this_status = DiffStatus::Bad;
|
||||||
|
Loading…
Reference in New Issue
Block a user