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