From b480bdb695db8ea0f6771373a5e185cd376d30c3 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Fri, 5 Nov 2021 11:58:28 -0300 Subject: [PATCH] feat: replace js in method name --- xtask/src/codegen/kinds_src.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/xtask/src/codegen/kinds_src.rs b/xtask/src/codegen/kinds_src.rs index 49cd8a2ba2fb..8657679c22bb 100644 --- a/xtask/src/codegen/kinds_src.rs +++ b/xtask/src/codegen/kinds_src.rs @@ -3,6 +3,8 @@ use quote::{format_ident, quote}; +const LANGUAGE_PREFIXES: [&str; 4] = ["js_", "ts_", "jsx_", "tsx_"]; + pub struct KindsSrc<'a> { pub punct: &'a [(&'a str, &'a str)], pub keywords: &'a [&'a str], @@ -505,10 +507,14 @@ impl Field { if !name_from_label { panic!("The node {} doesn't have a label", ty); } - if name == "type" { + let mut final_name = name.clone(); + for prefix in LANGUAGE_PREFIXES { + final_name = final_name.replace(prefix, ""); + } + if final_name == "type" { format_ident!("ty") } else { - format_ident!("{}", name) + format_ident!("{}", final_name) } } }