[Interop][Metadata] Avoid unnecessary backticks
`Classifier.relativeFqName` returns fully-qualified name where parts may be backticked. We don't need backticks in case of metadata output because names in metadata are already "parsed".
This commit is contained in:
committed by
Sergey Bogolepov
parent
dde5eced87
commit
4fd2e67d68
+7
-7
@@ -60,11 +60,11 @@ data class Classifier(
|
|||||||
return this.copy(nestedNames = nestedNames + name)
|
return this.copy(nestedNames = nestedNames + name)
|
||||||
}
|
}
|
||||||
|
|
||||||
val relativeFqName: String get() = buildString {
|
fun getRelativeFqName(asSimpleName: Boolean = true): String = buildString {
|
||||||
append(topLevelName.asSimpleName())
|
append(topLevelName.run { if (asSimpleName) asSimpleName() else this })
|
||||||
nestedNames.forEach {
|
nestedNames.forEach {
|
||||||
append('.')
|
append('.')
|
||||||
append(it.asSimpleName())
|
append(it.run { if (asSimpleName) asSimpleName() else this })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ data class Classifier(
|
|||||||
append(pkg)
|
append(pkg)
|
||||||
append('.')
|
append('.')
|
||||||
}
|
}
|
||||||
append(relativeFqName)
|
append(getRelativeFqName())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,7 +263,7 @@ abstract class KotlinFile(
|
|||||||
|
|
||||||
override fun reference(classifier: Classifier): String = if (classifier.topLevelName in namesToBeDeclared) {
|
override fun reference(classifier: Classifier): String = if (classifier.topLevelName in namesToBeDeclared) {
|
||||||
if (classifier.pkg == this.pkg) {
|
if (classifier.pkg == this.pkg) {
|
||||||
classifier.relativeFqName
|
classifier.getRelativeFqName()
|
||||||
} else {
|
} else {
|
||||||
// Don't import if would clash with own declaration:
|
// Don't import if would clash with own declaration:
|
||||||
classifier.fqName
|
classifier.fqName
|
||||||
@@ -275,7 +275,7 @@ abstract class KotlinFile(
|
|||||||
} else {
|
} else {
|
||||||
if (tryImport(classifier)) {
|
if (tryImport(classifier)) {
|
||||||
// Is successfully imported:
|
// Is successfully imported:
|
||||||
classifier.relativeFqName
|
classifier.getRelativeFqName()
|
||||||
} else {
|
} else {
|
||||||
classifier.fqName
|
classifier.fqName
|
||||||
}
|
}
|
||||||
@@ -298,7 +298,7 @@ abstract class KotlinFile(
|
|||||||
|
|
||||||
if (!classifier.isTopLevel) {
|
if (!classifier.isTopLevel) {
|
||||||
throw IllegalArgumentException(
|
throw IllegalArgumentException(
|
||||||
"'${classifier.relativeFqName}' is not top-level thus can't be declared at file scope"
|
"'${classifier.getRelativeFqName()}' is not top-level thus can't be declared at file scope"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -172,7 +172,7 @@ private class ObjCMethodStubBuilder(
|
|||||||
val clazz = context.getKotlinClassFor(container.clazz, isMeta = false).type
|
val clazz = context.getKotlinClassFor(container.clazz, isMeta = false).type
|
||||||
|
|
||||||
annotations.add(0, deprecatedInit(
|
annotations.add(0, deprecatedInit(
|
||||||
clazz.classifier.relativeFqName,
|
clazz.classifier.getRelativeFqName(),
|
||||||
kotlinMethodParameters.map { it.name },
|
kotlinMethodParameters.map { it.name },
|
||||||
factory = true
|
factory = true
|
||||||
))
|
))
|
||||||
|
|||||||
+1
-1
@@ -70,7 +70,7 @@ val ClassStub.explicitPrimaryConstructor: ConstructorStub?
|
|||||||
get() = functions.filterIsInstance<ConstructorStub>().firstOrNull(ConstructorStub::isPrimary)
|
get() = functions.filterIsInstance<ConstructorStub>().firstOrNull(ConstructorStub::isPrimary)
|
||||||
|
|
||||||
fun ClassStub.nestedName(): String =
|
fun ClassStub.nestedName(): String =
|
||||||
classifier.relativeFqName.substringAfterLast('.')
|
classifier.getRelativeFqName().substringAfterLast('.')
|
||||||
|
|
||||||
fun ConstantStub.determineConstantAnnotationClassifier(): Classifier = when (this) {
|
fun ConstantStub.determineConstantAnnotationClassifier(): Classifier = when (this) {
|
||||||
is StringConstantStub -> "String"
|
is StringConstantStub -> "String"
|
||||||
|
|||||||
+1
-1
@@ -254,7 +254,7 @@ private class MappingExtensions(
|
|||||||
append('/')
|
append('/')
|
||||||
}
|
}
|
||||||
// Nested classes should dot-separated.
|
// Nested classes should dot-separated.
|
||||||
append(relativeFqName)
|
append(getRelativeFqName(asSimpleName = false))
|
||||||
}
|
}
|
||||||
|
|
||||||
val PropertyStub.flags: Flags
|
val PropertyStub.flags: Flags
|
||||||
|
|||||||
Reference in New Issue
Block a user