Move assert bounds for elements and objects (except PlainText) to the compare element/object functions.
This commit is contained in:
@@ -315,9 +315,9 @@ fn compare_element<'s>(
|
||||
Element::BabelCall(obj) => compare_babel_call(source, emacs, obj),
|
||||
Element::LatexEnvironment(obj) => compare_latex_environment(source, emacs, obj),
|
||||
};
|
||||
match compare_result {
|
||||
Ok(_) => compare_result,
|
||||
Err(ref e) => Ok(DiffResult {
|
||||
|
||||
let mut compare_result = match compare_result.unwrap_or_else(|e| {
|
||||
DiffResult {
|
||||
status: DiffStatus::Bad,
|
||||
name: "error!".to_owned(),
|
||||
message: Some(e.to_string()),
|
||||
@@ -325,8 +325,23 @@ fn compare_element<'s>(
|
||||
rust_source: rust.get_standard_properties().get_source(),
|
||||
emacs_token: emacs,
|
||||
}
|
||||
.into()),
|
||||
.into()
|
||||
}) {
|
||||
DiffEntry::DiffResult(inner) => inner,
|
||||
DiffEntry::DiffLayer(_) => {
|
||||
unreachable!("Layers are only interior to DiffResults of AST nodes.")
|
||||
}
|
||||
};
|
||||
|
||||
match assert_bounds(source, emacs, rust.get_standard_properties()) {
|
||||
Err(err) => {
|
||||
compare_result.status = DiffStatus::Bad;
|
||||
compare_result.message = Some(err.to_string())
|
||||
}
|
||||
Ok(_) => {}
|
||||
}
|
||||
|
||||
Ok(compare_result.into())
|
||||
}
|
||||
|
||||
fn compare_object<'s>(
|
||||
@@ -363,9 +378,8 @@ fn compare_object<'s>(
|
||||
Object::Superscript(obj) => compare_superscript(source, emacs, obj),
|
||||
Object::Timestamp(obj) => compare_timestamp(source, emacs, obj),
|
||||
};
|
||||
match compare_result {
|
||||
Ok(_) => compare_result,
|
||||
Err(ref e) => Ok(DiffResult {
|
||||
let mut compare_result = match compare_result.unwrap_or_else(|e| {
|
||||
DiffResult {
|
||||
status: DiffStatus::Bad,
|
||||
name: "error!".to_owned(),
|
||||
message: Some(e.to_string()),
|
||||
@@ -373,8 +387,27 @@ fn compare_object<'s>(
|
||||
rust_source: rust.get_standard_properties().get_source(),
|
||||
emacs_token: emacs,
|
||||
}
|
||||
.into()),
|
||||
.into()
|
||||
}) {
|
||||
DiffEntry::DiffResult(inner) => inner,
|
||||
DiffEntry::DiffLayer(_) => {
|
||||
unreachable!("Layers are only interior to DiffResults of AST nodes.")
|
||||
}
|
||||
};
|
||||
|
||||
// PlainText is a special case because upstream Org-Mode uses relative values for the bounds in plaintext rather than absolute so the below checks do not account for that.
|
||||
if let Object::PlainText(_) = rust {
|
||||
} else {
|
||||
match assert_bounds(source, emacs, rust.get_standard_properties()) {
|
||||
Err(err) => {
|
||||
compare_result.status = DiffStatus::Bad;
|
||||
compare_result.message = Some(err.to_string())
|
||||
}
|
||||
Ok(_) => {}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(compare_result.into())
|
||||
}
|
||||
|
||||
pub fn compare_document<'s>(
|
||||
|
||||
Reference in New Issue
Block a user