Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
feat: replace js in method name
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Nov 5, 2021
1 parent df33e87 commit b480bdb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions xtask/src/codegen/kinds_src.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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)
}
}
}
Expand Down

0 comments on commit b480bdb

Please sign in to comment.