Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop Pascalizing Enum Cases #162

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
Stop pascalizing enum case name to avoid clashes
Pascalizing enum case names in restrictions can cause clashes (see #154)
  • Loading branch information
lkirkwood committed Apr 20, 2024
commit 2a97fcd2ddd3df0a176a168a76981c886933b3e0
14 changes: 7 additions & 7 deletions xsd-parser/src/generator/enum_case.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use crate::{
generator::{default::default_format_type, utils::split_name, Generator},
generator::{utils::split_name, Generator},
parser::types::{EnumCase, EnumSource},
};

use super::utils::{filter_type_name, sanitize};

pub trait EnumCaseGenerator {
fn generate(&self, entity: &EnumCase, gen: &Generator) -> String {
let typename = if entity.type_name.is_some() {
@@ -20,12 +22,10 @@ pub trait EnumCaseGenerator {
)
}

fn get_name(&self, entity: &EnumCase, gen: &Generator) -> String {
default_format_type(entity.name.as_str(), &gen.target_ns.borrow())
.split("::")
.last()
.unwrap()
.to_string()
fn get_name(&self, entity: &EnumCase, _: &Generator) -> String {
sanitize(filter_type_name(
&entity.name.split(':').last().unwrap_or(&entity.name.to_owned()),
))
}

fn get_type_name(&self, entity: &EnumCase, gen: &Generator) -> String {