Rust: use macro to inject extraction functions for detached properties

This commit is contained in:
Arthur Baars
2024-10-08 10:47:40 +02:00
parent 8372a2e562
commit db28f1b29e
3 changed files with 159 additions and 3 deletions

View File

@@ -419,8 +419,9 @@ fn write_extractor(grammar: &AstSrc) -> std::io::Result<String> {
"//! Generated by `ast-generator`, do not edit by hand.\n
#![cfg_attr(any(), rustfmt::skip)]
use crate::generated;
use super::base::{{TextValue, Translator}};
use crate::emit_detached;
use crate::generated;
use crate::trap::{{Label, TrapId}};
use ra_ap_syntax::ast::{{
HasArgList, HasAttrs, HasGenericArgs, HasGenericParams, HasLoopBody, HasModuleItem, HasName,
@@ -520,6 +521,11 @@ impl Translator<'_> {{
}
writeln!(buf, " }});")?;
writeln!(buf, " self.emit_location(label, &node);")?;
writeln!(
buf,
" emit_detached!({}, self, node, label);",
class_name
)?;
writeln!(
buf,
" self.emit_tokens(&node, label.into(), node.syntax().children_with_tokens());"