Change part class naming scheme

update tests depending on part class naming
This commit is contained in:
Dmitry Petrov
2015-07-24 15:09:16 +03:00
committed by Michael Bogdanov
parent 801d10229b
commit a47eaa2cb5
59 changed files with 166 additions and 120 deletions
@@ -45,8 +45,12 @@ public class PackagePartClassUtils {
}
@NotNull
private static String replaceSpecialSymbols(@NotNull String str) {
return str.replace('.', '_');
private static String getSanitizedIdentifier(@NotNull String str) {
str = str.replaceAll("[^\\p{L}\\p{Digit}]", "_");
if (!Character.isJavaIdentifierStart(str.charAt(0))) {
str = "_" + str;
}
return str;
}
@NotNull
@@ -65,20 +69,10 @@ public class PackagePartClassUtils {
if ('a' <= c && c <= 'z') {
fileName = Character.toUpperCase(fileName.charAt(0)) + fileName.substring(1);
}
fileName += "Kt";
}
if (jetFile != null) {
for (PsiElement child : jetFile.getDeclarations()) {
if (child instanceof JetClassOrObject) {
if (fileName.equalsIgnoreCase(((JetClassOrObject) child).getName())) {
fileName += "_";
break;
}
}
}
}
return facadeFqName.parent().child(Name.identifier(replaceSpecialSymbols(fileName)));
return facadeFqName.parent().child(Name.identifier(getSanitizedIdentifier(fileName)));
}
@NotNull