Initial code structure for property drawers.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
use super::sexp::Token;
|
||||
use super::util::assert_bounds;
|
||||
use super::util::assert_name;
|
||||
use crate::compare::util::get_offsets;
|
||||
use crate::parser::Comment;
|
||||
use crate::parser::Document;
|
||||
use crate::parser::DocumentElement;
|
||||
@@ -13,6 +12,7 @@ use crate::parser::Heading;
|
||||
use crate::parser::Paragraph;
|
||||
use crate::parser::PlainList;
|
||||
use crate::parser::PlainListItem;
|
||||
use crate::parser::PropertyDrawer;
|
||||
use crate::parser::Section;
|
||||
use crate::DynamicBlock;
|
||||
|
||||
@@ -197,6 +197,7 @@ fn compare_element<'s>(
|
||||
Element::FootnoteDefinition(obj) => compare_footnote_definition(source, emacs, obj),
|
||||
Element::Comment(obj) => compare_comment(source, emacs, obj),
|
||||
Element::Drawer(obj) => compare_drawer(source, emacs, obj),
|
||||
Element::PropertyDrawer(obj) => compare_property_drawer(source, emacs, obj),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -428,3 +429,33 @@ fn compare_drawer<'s>(
|
||||
children: child_status,
|
||||
})
|
||||
}
|
||||
|
||||
fn compare_property_drawer<'s>(
|
||||
source: &'s str,
|
||||
emacs: &'s Token<'s>,
|
||||
rust: &'s PropertyDrawer<'s>,
|
||||
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
||||
let children = emacs.as_list()?;
|
||||
let mut child_status = Vec::new();
|
||||
let mut this_status = DiffStatus::Good;
|
||||
let emacs_name = "property-drawer";
|
||||
if assert_name(emacs, emacs_name).is_err() {
|
||||
this_status = DiffStatus::Bad;
|
||||
}
|
||||
|
||||
if assert_bounds(source, emacs, rust).is_err() {
|
||||
this_status = DiffStatus::Bad;
|
||||
}
|
||||
|
||||
for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) {
|
||||
// TODO: What are node properties and are they the only legal child of property drawers?
|
||||
// child_status.push(compare_element(source, emacs_child, rust_child)?);
|
||||
}
|
||||
|
||||
Ok(DiffResult {
|
||||
status: this_status,
|
||||
name: emacs_name.to_owned(),
|
||||
message: None,
|
||||
children: child_status,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user