sanitizeAsJavaIdentifier function moved to JvmAbi
This commit is contained in:
@@ -235,9 +235,4 @@ public class JvmCodegenUtil {
|
|||||||
av.visit(JvmAnnotationNames.MODULE_NAME_FIELD_NAME, name);
|
av.visit(JvmAnnotationNames.MODULE_NAME_FIELD_NAME, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public static String sanitizeAsJavaIdentifier(@NotNull String str) {
|
|
||||||
return PackagePartClassUtils.sanitizeAsJavaIdentifier(str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -880,7 +880,7 @@ public class JetTypeMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!(descriptor instanceof ConstructorDescriptor) && descriptor.getVisibility() == Visibilities.INTERNAL) {
|
if (!(descriptor instanceof ConstructorDescriptor) && descriptor.getVisibility() == Visibilities.INTERNAL) {
|
||||||
return name + "$" + JvmCodegenUtil.sanitizeAsJavaIdentifier(moduleName);
|
return name + "$" + JvmAbi.sanitizeAsJavaIdentifier(moduleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
|
|||||||
+2
-4
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.load.kotlin
|
|||||||
import com.intellij.openapi.util.io.FileUtil
|
import com.intellij.openapi.util.io.FileUtil
|
||||||
import com.intellij.openapi.vfs.VirtualFile
|
import com.intellij.openapi.vfs.VirtualFile
|
||||||
import org.jetbrains.annotations.TestOnly
|
import org.jetbrains.annotations.TestOnly
|
||||||
|
import org.jetbrains.kotlin.load.java.JvmAbi
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.psi.JetFile
|
import org.jetbrains.kotlin.psi.JetFile
|
||||||
@@ -38,10 +39,7 @@ public object PackagePartClassUtils {
|
|||||||
if (str.isEmpty())
|
if (str.isEmpty())
|
||||||
"_$PART_CLASS_NAME_SUFFIX"
|
"_$PART_CLASS_NAME_SUFFIX"
|
||||||
else
|
else
|
||||||
capitalizeAsJavaClassName(sanitizeAsJavaIdentifier(str)) + PART_CLASS_NAME_SUFFIX
|
capitalizeAsJavaClassName(JvmAbi.sanitizeAsJavaIdentifier(str)) + PART_CLASS_NAME_SUFFIX
|
||||||
|
|
||||||
public @JvmStatic fun sanitizeAsJavaIdentifier(str: String): String =
|
|
||||||
str.replace("[^\\p{L}\\p{Digit}]".toRegex(), "_")
|
|
||||||
|
|
||||||
private @JvmStatic fun capitalizeAsJavaClassName(str: String): String =
|
private @JvmStatic fun capitalizeAsJavaClassName(str: String): String =
|
||||||
// NB use Locale.ENGLISH so that build is locale-independent.
|
// NB use Locale.ENGLISH so that build is locale-independent.
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.load.java;
|
package org.jetbrains.kotlin.load.java;
|
||||||
|
|
||||||
|
import kotlin.StringsKt;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.kotlin.name.ClassId;
|
import org.jetbrains.kotlin.name.ClassId;
|
||||||
import org.jetbrains.kotlin.name.FqName;
|
import org.jetbrains.kotlin.name.FqName;
|
||||||
@@ -90,5 +91,10 @@ public final class JvmAbi {
|
|||||||
char c = name.charAt(IS_PREFIX.length());
|
char c = name.charAt(IS_PREFIX.length());
|
||||||
return !('a' <= c && c <= 'z');
|
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 sourceElement = containingDeclaration.source as KotlinJvmBinarySourceElement
|
||||||
val klass = (sourceElement.binaryClass as ReflectKotlinClass).klass
|
val klass = (sourceElement.binaryClass as ReflectKotlinClass).klass
|
||||||
val moduleName = klass.getAnnotation(KotlinClass::class.java).moduleName
|
val moduleName = klass.getAnnotation(KotlinClass::class.java).moduleName
|
||||||
"$" + sanitizeAsJavaIdentifier(moduleName)
|
"$" + JvmAbi.sanitizeAsJavaIdentifier(moduleName)
|
||||||
}
|
}
|
||||||
else {
|
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
|
override fun asString(): String = string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user