Skip to content

Commit

Permalink
Merge pull request #18 from EmbarkStudios/bwe/fix-filename-for-keywords
Browse files Browse the repository at this point in the history
Fix handling of filename for keywords
  • Loading branch information
bwestlin authored Mar 11, 2024
2 parents 177a91a + b66f1a0 commit d384ab6
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion proto-gen/src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,9 @@ impl Module {
Some(output)
};
if let Some(file) = self.file.as_ref() {
let file_location = self.location.join(format!("{}.rs", self.name));
let file_location = self
.location
.join(format!("{}.rs", self.proper_file_name()));
// It's the same filename we don't need to move it but we need to edit it if it has
// child modules.
let is_same_file = &file_location == file;
Expand Down Expand Up @@ -261,6 +263,15 @@ impl Module {
fn get_name(&self) -> &str {
self.name.as_str()
}

#[inline]
fn proper_file_name<'a>(&self) -> &str {
if self.name.starts_with("r#") {
&self.name[2..]
} else {
self.name.as_str()
}
}
}

fn as_file_name_string(path: impl AsRef<Path>) -> Result<String, String> {
Expand Down

0 comments on commit d384ab6

Please sign in to comment.