use fea_rs_ast::{fea_rs, fea_rs::parse::ParseTree};
use indexmap::IndexSet;
use crate::layout::visitor::LayoutVisitor;
#[allow(dead_code)]
pub(crate) struct LookupGathererVisitor<'a> {
parse_tree: &'a ParseTree,
pub lookup_names: IndexSet<String>,
}
impl<'a> LookupGathererVisitor<'a> {
#[allow(dead_code)]
pub fn new(parse_tree: &'a ParseTree) -> Self {
Self {
parse_tree,
lookup_names: IndexSet::new(),
}
}
}
impl LayoutVisitor for LookupGathererVisitor<'_> {
fn get_root(&self) -> &fea_rs::Node {
self.parse_tree.root()
}
fn visit_lookupblock(&mut self, lookup: &fea_rs::typed::LookupBlock) -> bool {
#[allow(clippy::unwrap_used)] let node = lookup
.node()
.iter_children()
.find(|n| n.kind() == fea_rs::Kind::Label)
.unwrap();
#[allow(clippy::unwrap_used)] let name = node.token_text().unwrap().to_string();
log::debug!("Found lookup block: {}", name);
self.lookup_names.insert(name);
false }
}