nodes without ast_node_id

This commit is contained in:
Anton-4 2022-03-02 17:14:51 +01:00
parent bddab60e6b
commit 853badf777
No known key found for this signature in database
GPG key ID: C954D6E0F9C0ABFD
21 changed files with 337 additions and 252 deletions

View file

@ -1,6 +1,4 @@
use std::fmt;
use crate::markup::nodes::MarkupNode;
use crate::markup::{nodes::MarkupNode, mark_id_ast_id_map::MarkIdAstIdMap};
pub type MarkNodeId = usize;
@ -34,14 +32,16 @@ impl SlowPool {
// TODO delete children of old node, this requires SlowPool to be changed to
// make sure the indexes still make sense after removal/compaction
}
}
impl fmt::Display for SlowPool {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "\n\n(mark_node_pool)\n")?;
pub fn debug_string(&self, mark_id_ast_id_map: &MarkIdAstIdMap) -> String {
let mut ret_str = String::new();
for (index, node) in self.nodes.iter().enumerate() {
let ast_node_id_str = format!("{:?}", node.get_ast_node_id());
for (mark_node_id, node) in self.nodes.iter().enumerate() {
let ast_node_id_str =
match mark_id_ast_id_map.get(mark_node_id) {
Ok(ast_id) => format!("{:?}", ast_id),
Err(err) => format!("{:?}", err)
};
let ast_node_id: String = ast_node_id_str
.chars()
.filter(|c| c.is_ascii_digit())
@ -55,17 +55,18 @@ impl fmt::Display for SlowPool {
child_str = format!("children: {:?}", node_children);
}
writeln!(
f,
"{}: {} ({}) ast_id {:?} {}",
index,
node.node_type_as_string(),
node.get_content(),
ast_node_id.parse::<usize>().unwrap(),
child_str
)?;
ret_str.push_str(
&format!(
"{}: {} ({}) ast_id {:?} {}",
mark_node_id,
node.node_type_as_string(),
node.get_content(),
ast_node_id.parse::<usize>().unwrap(),
child_str
)
);
}
Ok(())
ret_str
}
}