sanitizeAsJavaIdentifier function moved to JvmAbi
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.load.java;
|
||||
|
||||
import kotlin.StringsKt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.name.ClassId;
|
||||
import org.jetbrains.kotlin.name.FqName;
|
||||
@@ -90,5 +91,10 @@ public final class JvmAbi {
|
||||
char c = name.charAt(IS_PREFIX.length());
|
||||
return !('a' <= c && c <= 'z');
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String sanitizeAsJavaIdentifier(@NotNull String str) {
|
||||
return StringsKt.replace(str, StringsKt.toRegex("[^\\p{L}\\p{Digit}]"), "_");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ internal sealed class JvmPropertySignature {
|
||||
val sourceElement = containingDeclaration.source as KotlinJvmBinarySourceElement
|
||||
val klass = (sourceElement.binaryClass as ReflectKotlinClass).klass
|
||||
val moduleName = klass.getAnnotation(KotlinClass::class.java).moduleName
|
||||
"$" + sanitizeAsJavaIdentifier(moduleName)
|
||||
"$" + JvmAbi.sanitizeAsJavaIdentifier(moduleName)
|
||||
}
|
||||
else {
|
||||
""
|
||||
@@ -129,9 +129,6 @@ internal sealed class JvmPropertySignature {
|
||||
}
|
||||
}
|
||||
|
||||
private fun sanitizeAsJavaIdentifier(str: String): String =
|
||||
str.replace("[^\\p{L}\\p{Digit}]".toRegex(), "_")
|
||||
|
||||
override fun asString(): String = string
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user