use std::collections::HashSet;
use babelfont::SmolStr;
use fea_rs_ast::{LayoutVisitor, Statement};
#[derive(Default)]
pub(crate) struct NameGathererVisitor {
pub lookup_names: HashSet<SmolStr>,
pub class_names: HashSet<SmolStr>,
}
impl NameGathererVisitor {
pub fn new() -> Self {
Self::default()
}
}
impl LayoutVisitor for NameGathererVisitor {
fn visit_statement(&mut self, statement: &mut Statement) -> bool {
match statement {
Statement::LookupBlock(lookup_block) => {
log::debug!("Found lookup block: {}", lookup_block.name);
self.lookup_names.insert(lookup_block.name.clone());
}
Statement::GlyphClassDefinition(class_definition) => {
log::debug!("Found glyph class: {}", class_definition.name);
self.class_names
.insert(SmolStr::new(&class_definition.name));
}
_ => {}
}
true
}
}