Compare children of heading.
This commit is contained in:
parent
4dbf8b9c69
commit
c4e6549feb
@ -1,8 +1,9 @@
|
||||
use super::sexp::Token;
|
||||
use crate::compare::util::get_offsets;
|
||||
use crate::parser::Document;
|
||||
use crate::parser::Section;
|
||||
use crate::parser::DocumentElement;
|
||||
use crate::parser::Heading;
|
||||
use crate::parser::Section;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct DiffResult {
|
||||
@ -31,16 +32,11 @@ impl DiffResult {
|
||||
} else {
|
||||
"GOOD"
|
||||
}
|
||||
},
|
||||
}
|
||||
DiffStatus::Bad => "BAD",
|
||||
}
|
||||
};
|
||||
println!(
|
||||
"{}{} {}",
|
||||
" ".repeat(indentation),
|
||||
status_text,
|
||||
self.name
|
||||
);
|
||||
println!("{}{} {}", " ".repeat(indentation), status_text, self.name);
|
||||
for child in self.children.iter() {
|
||||
child.print_indented(indentation + 1)?;
|
||||
}
|
||||
@ -48,7 +44,9 @@ impl DiffResult {
|
||||
}
|
||||
|
||||
pub fn has_bad_children(&self) -> bool {
|
||||
self.children.iter().any(|child| {child.status == DiffStatus::Bad || child.has_bad_children()})
|
||||
self.children
|
||||
.iter()
|
||||
.any(|child| child.status == DiffStatus::Bad || child.has_bad_children())
|
||||
}
|
||||
}
|
||||
|
||||
@ -173,6 +171,17 @@ pub fn compare_heading<'s>(
|
||||
this_status = DiffStatus::Bad;
|
||||
}
|
||||
|
||||
for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) {
|
||||
match rust_child {
|
||||
DocumentElement::Heading(rust_heading) => {
|
||||
child_status.push(compare_heading(source, emacs_child, rust_heading)?);
|
||||
},
|
||||
DocumentElement::Section(rust_section) => {
|
||||
child_status.push(compare_section(source, emacs_child, rust_section)?);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Ok(DiffResult {
|
||||
status: this_status,
|
||||
name: "heading".to_owned(),
|
||||
|
@ -16,7 +16,8 @@ mod source;
|
||||
mod util;
|
||||
pub use document::document;
|
||||
pub use document::Document;
|
||||
pub use document::Section;
|
||||
pub use document::DocumentElement;
|
||||
pub use document::Heading;
|
||||
pub use document::Section;
|
||||
pub use source::Source;
|
||||
type Context<'r, 's> = &'r parser_context::ContextTree<'r, 's>;
|
||||
|
Loading…
x
Reference in New Issue
Block a user