compare_properties babel call.
This commit is contained in:
parent
c2222c9102
commit
9f166278f4
@ -2488,73 +2488,64 @@ fn compare_keyword<'b, 's>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn compare_babel_call<'b, 's>(
|
fn compare_babel_call<'b, 's>(
|
||||||
_source: &'s str,
|
source: &'s str,
|
||||||
emacs: &'b Token<'s>,
|
emacs: &'b Token<'s>,
|
||||||
rust: &'b BabelCall<'s>,
|
rust: &'b BabelCall<'s>,
|
||||||
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
||||||
let child_status = Vec::new();
|
|
||||||
let mut this_status = DiffStatus::Good;
|
let mut this_status = DiffStatus::Good;
|
||||||
|
let mut child_status = Vec::new();
|
||||||
let mut message = None;
|
let mut message = None;
|
||||||
|
|
||||||
// TODO: Compare :caption
|
assert_no_children(emacs, &mut this_status, &mut message)?;
|
||||||
// Compare name
|
|
||||||
let name = get_property_quoted_string(emacs, ":name")?;
|
|
||||||
if name.as_ref().map(String::as_str) != rust.name {
|
|
||||||
this_status = DiffStatus::Bad;
|
|
||||||
message = Some(format!(
|
|
||||||
"Name mismatch (emacs != rust) {:?} != {:?}",
|
|
||||||
name, rust.name
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compare value
|
for diff in compare_properties!(
|
||||||
let value = get_property_quoted_string(emacs, ":value")?.unwrap_or(String::new());
|
source,
|
||||||
if value != rust.value {
|
emacs,
|
||||||
this_status = DiffStatus::Bad;
|
rust,
|
||||||
message = Some(format!(
|
(
|
||||||
"Value mismatch (emacs != rust) {:?} != {:?}",
|
EmacsField::Optional(":name"),
|
||||||
value, rust.value
|
|r| r.name,
|
||||||
))
|
compare_property_quoted_string
|
||||||
}
|
),
|
||||||
|
(
|
||||||
// Compare call
|
EmacsField::Optional(":caption"),
|
||||||
let call = get_property_quoted_string(emacs, ":call")?;
|
compare_identity,
|
||||||
if call.as_ref().map(String::as_str) != rust.call {
|
compare_noop
|
||||||
this_status = DiffStatus::Bad;
|
),
|
||||||
message = Some(format!(
|
(
|
||||||
"Call mismatch (emacs != rust) {:?} != {:?}",
|
EmacsField::Required(":value"),
|
||||||
call, rust.call
|
|r| Some(r.value),
|
||||||
))
|
compare_property_quoted_string
|
||||||
}
|
),
|
||||||
|
(
|
||||||
// Compare arguments
|
EmacsField::Required(":call"),
|
||||||
let arguments = get_property_quoted_string(emacs, ":arguments")?;
|
|r| r.call,
|
||||||
if arguments.as_ref().map(String::as_str) != rust.arguments {
|
compare_property_quoted_string
|
||||||
this_status = DiffStatus::Bad;
|
),
|
||||||
message = Some(format!(
|
(
|
||||||
"Arguments mismatch (emacs != rust) {:?} != {:?}",
|
EmacsField::Required(":arguments"),
|
||||||
arguments, rust.arguments
|
|r| r.arguments,
|
||||||
))
|
compare_property_quoted_string
|
||||||
}
|
),
|
||||||
|
(
|
||||||
// Compare inside header
|
EmacsField::Required(":inside-header"),
|
||||||
let inside_header = get_property_quoted_string(emacs, ":inside-header")?;
|
|r| r.inside_header,
|
||||||
if inside_header.as_ref().map(String::as_str) != rust.inside_header {
|
compare_property_quoted_string
|
||||||
this_status = DiffStatus::Bad;
|
),
|
||||||
message = Some(format!(
|
(
|
||||||
"Inside header mismatch (emacs != rust) {:?} != {:?}",
|
EmacsField::Required(":end-header"),
|
||||||
inside_header, rust.inside_header
|
|r| r.end_header,
|
||||||
))
|
compare_property_quoted_string
|
||||||
}
|
)
|
||||||
|
) {
|
||||||
// Compare end header
|
match diff {
|
||||||
let end_header = get_property_quoted_string(emacs, ":end-header")?;
|
ComparePropertiesResult::NoChange => {}
|
||||||
if end_header.as_ref().map(String::as_str) != rust.end_header {
|
ComparePropertiesResult::SelfChange(new_status, new_message) => {
|
||||||
this_status = DiffStatus::Bad;
|
this_status = new_status;
|
||||||
message = Some(format!(
|
message = new_message
|
||||||
"End header mismatch (emacs != rust) {:?} != {:?}",
|
}
|
||||||
end_header, rust.end_header
|
ComparePropertiesResult::DiffEntry(diff_entry) => child_status.push(diff_entry),
|
||||||
))
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(DiffResult {
|
Ok(DiffResult {
|
||||||
|
Loading…
Reference in New Issue
Block a user