syn
syn copied to clipboard
Methods to get name of visit, visit_mut, fold methods as ident
As part of the library from #607 -- users will want to generate code that calls visitor / folder methods on specific syntax tree node types.
Something like:
impl Node {
pub fn name_of_visit_method(&self) -> Ident;
pub fn name_of_visit_mut_method(&self) -> Ident;
pub fn name_of_fold_method(&self) -> Ident;
}
where e.g. the "Expr" node would return "visit_expr", "visit_expr_mut", "fold_expr".
A code generator could guess these method names by using the inflections
crate and mirroring what our codegen does, but that is annoying.
Ident::new(&format!("visit_{}", node.ident.to_snake_case()), Span::call_site())