Skip to content

Commit

Permalink
Merge pull request #8 from AndrewDRX/development
Browse files Browse the repository at this point in the history
Enhancement: Support PascalCase for Namespaces
  • Loading branch information
SomeRanDev authored Feb 16, 2024
2 parents 21ae52f + 01ceaeb commit b7c8813
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/cscompiler/components/CSType.hx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,27 @@ class CSType extends CSBase {
**/
public function getNameSpace(baseType: BaseType):String {
final pack = getPackWithoutModule(baseType);
return pack.length > 0 ? pack.join(".") : CSCompiler.DEFAULT_ROOT_NAMESPACE;
if (pack.length == 0) {
return CSCompiler.DEFAULT_ROOT_NAMESPACE;
}
var returnValue = pack.join(".");
if (!Context.defined("ns-style")) {
return returnValue;
}
switch (Context.definedValue("ns-style")) {
case "pascal":
returnValue = ~/[\._]\w/g.map(
returnValue,
(each) -> {
final part = each.matched(0);
final separator = part.charAt(0);
final character = part.charAt(1).toUpperCase();
return '${separator == "." ? separator : ""}${character}';
}
);
returnValue = '${returnValue.charAt(0).toUpperCase()}${returnValue.substr(1)}';
}
return returnValue;
}

/**
Expand Down

0 comments on commit b7c8813

Please sign in to comment.