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

Commit

Permalink
chore: strip prefix only once
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Nov 9, 2021
1 parent 68ce656 commit 78eca9a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions xtask/src/codegen/kinds_src.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,14 +503,16 @@ impl Field {
format_ident!("{}_token", name)
}
Field::Node { name, .. } => {
let mut final_name = name.clone();
for prefix in LANGUAGE_PREFIXES {
final_name = String::from(
final_name
.strip_prefix(prefix)
.unwrap_or_else(|| final_name.as_str()),
);
}
let name = name;
let (prefix, tail) = name.split_once('_').unwrap_or(("", name));
let final_name = if LANGUAGE_PREFIXES.contains(&prefix) {
tail
} else {
name.as_str()
};

// this check here is to avoid emitting methods called "type()",
// where "type" is a reserved word
if final_name == "type" {
format_ident!("ty")
} else {
Expand Down

0 comments on commit 78eca9a

Please sign in to comment.