[decompiler] ensure names starting with numbers are escaped
^ KTIJ-25985
This commit is contained in:
+3
@@ -0,0 +1,3 @@
|
|||||||
|
object SpecialNames {
|
||||||
|
val `1M` = 1
|
||||||
|
}
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
PsiJetFileStubImpl[package=]
|
||||||
|
PACKAGE_DIRECTIVE
|
||||||
|
IMPORT_LIST
|
||||||
|
OBJECT_DECLARATION[classId=/SpecialNames, fqName=SpecialNames, isCompanion=false, isLocal=false, isObjectLiteral=false, isTopLevel=true, name=SpecialNames, superNames=[]]
|
||||||
|
MODIFIER_LIST[public]
|
||||||
|
CLASS_BODY
|
||||||
|
PROPERTY[fqName=SpecialNames.1M, hasDelegate=false, hasDelegateExpression=false, hasInitializer=false, hasReturnTypeRef=true, isExtension=false, isTopLevel=false, isVar=false, name=1M]
|
||||||
|
MODIFIER_LIST[public final]
|
||||||
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION[referencedName=kotlin]
|
||||||
|
REFERENCE_EXPRESSION[referencedName=Int]
|
||||||
+6
@@ -246,6 +246,12 @@ public class ClsStubBuilderTestGenerated extends AbstractClsStubBuilderTest {
|
|||||||
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/SecondaryConstructors/");
|
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/SecondaryConstructors/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("SpecialNames")
|
||||||
|
public void testSpecialNames() throws Exception {
|
||||||
|
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/SpecialNames/");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("SuspendLambda")
|
@TestMetadata("SuspendLambda")
|
||||||
public void testSuspendLambda() throws Exception {
|
public void testSuspendLambda() throws Exception {
|
||||||
|
|||||||
+6
@@ -246,6 +246,12 @@ public class ByDecompiledPsiStubBuilderTestGenerated extends AbstractByDecompile
|
|||||||
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/SecondaryConstructors/");
|
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/SecondaryConstructors/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("SpecialNames")
|
||||||
|
public void testSpecialNames() throws Exception {
|
||||||
|
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/SpecialNames/");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("SuspendLambda")
|
@TestMetadata("SuspendLambda")
|
||||||
public void testSuspendLambda() throws Exception {
|
public void testSuspendLambda() throws Exception {
|
||||||
|
|||||||
@@ -26,7 +26,10 @@ fun Name.render(): String {
|
|||||||
|
|
||||||
private fun Name.shouldBeEscaped(): Boolean {
|
private fun Name.shouldBeEscaped(): Boolean {
|
||||||
val string = asString()
|
val string = asString()
|
||||||
return string in KeywordStringsGenerated.KEYWORDS || string.any { !Character.isLetterOrDigit(it) && it != '_' }
|
return string in KeywordStringsGenerated.KEYWORDS ||
|
||||||
|
string.any { !Character.isLetterOrDigit(it) && it != '_' } ||
|
||||||
|
string.isEmpty() ||
|
||||||
|
!Character.isJavaIdentifierStart(string.codePointAt(0))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun FqNameUnsafe.render(): String {
|
fun FqNameUnsafe.render(): String {
|
||||||
|
|||||||
Reference in New Issue
Block a user