[FIR] Move duplicating names and classIds to StandardClassIds
This commit is contained in:
committed by
teamcityserver
parent
4793674eae
commit
5c2a3bb78e
@@ -8,17 +8,14 @@ package org.jetbrains.kotlin.name
|
||||
import org.jetbrains.kotlin.builtins.StandardNames
|
||||
|
||||
object StandardClassIds {
|
||||
|
||||
val BASE_KOTLIN_PACKAGE = FqName("kotlin")
|
||||
val BASE_REFLECT_PACKAGE = BASE_KOTLIN_PACKAGE.child(Name.identifier("reflect"))
|
||||
val BASE_COLLECTIONS_PACKAGE = BASE_KOTLIN_PACKAGE.child(Name.identifier("collections"))
|
||||
val BASE_JVM_PACKAGE = BASE_KOTLIN_PACKAGE.child(Name.identifier("jvm"))
|
||||
private fun String.baseId() = ClassId(BASE_KOTLIN_PACKAGE, Name.identifier(this))
|
||||
private fun ClassId.unsignedId() = ClassId(BASE_KOTLIN_PACKAGE, Name.identifier("U" + shortClassName.identifier))
|
||||
private fun String.reflectId() = ClassId(BASE_REFLECT_PACKAGE, Name.identifier(this))
|
||||
private fun Name.primitiveArrayId() = ClassId(Array.packageFqName, Name.identifier(identifier + Array.shortClassName.identifier))
|
||||
private fun String.collectionsId() = ClassId(BASE_COLLECTIONS_PACKAGE, Name.identifier(this))
|
||||
private fun String.jvmId() = ClassId(BASE_JVM_PACKAGE, Name.identifier(this))
|
||||
val BASE_JVM_INTERNAL_PACKAGE = BASE_JVM_PACKAGE.child(Name.identifier("internal"))
|
||||
val BASE_ANNOTATION_PACKAGE = BASE_KOTLIN_PACKAGE.child(Name.identifier("annotation"))
|
||||
val BASE_INTERNAL_PACKAGE = BASE_KOTLIN_PACKAGE.child(Name.identifier("internal"))
|
||||
val BASE_INTERNAL_IR_PACKAGE = BASE_INTERNAL_PACKAGE.child(Name.identifier("ir"))
|
||||
|
||||
val Nothing = "Nothing".baseId()
|
||||
val Unit = "Unit".baseId()
|
||||
@@ -64,7 +61,6 @@ object StandardClassIds {
|
||||
fun byName(name: String) = name.baseId()
|
||||
fun reflectByName(name: String) = name.reflectId()
|
||||
|
||||
|
||||
val primitiveTypes = setOf(Boolean, Char, Byte, Short, Int, Long, Float, Double)
|
||||
|
||||
val primitiveArrayTypeByElementType = primitiveTypes.associateWith { id -> id.shortClassName.primitiveArrayId() }
|
||||
@@ -76,8 +72,7 @@ object StandardClassIds {
|
||||
|
||||
val constantAllowedTypes = primitiveTypes + unsignedTypes + String
|
||||
|
||||
val Continuation =
|
||||
ClassId(StandardNames.COROUTINES_PACKAGE_FQ_NAME, StandardNames.CONTINUATION_INTERFACE_FQ_NAME.shortName())
|
||||
val Continuation = ClassId(StandardNames.COROUTINES_PACKAGE_FQ_NAME, StandardNames.CONTINUATION_INTERFACE_FQ_NAME.shortName())
|
||||
|
||||
@Suppress("FunctionName")
|
||||
fun FunctionN(n: Int): ClassId {
|
||||
@@ -103,25 +98,73 @@ object StandardClassIds {
|
||||
val MapEntry = Map.createNestedClassId(Name.identifier("Entry"))
|
||||
val MutableMapEntry = MutableMap.createNestedClassId(Name.identifier("MutableEntry"))
|
||||
|
||||
val extensionFunctionType = "ExtensionFunctionType".baseId()
|
||||
|
||||
val Suppress = "Suppress".baseId()
|
||||
|
||||
val FlexibleNullability = ClassId(FqName("kotlin.internal.ir"), Name.identifier("FlexibleNullability"))
|
||||
val EnhancedNullability = ClassId(FqName("kotlin.jvm.internal"), Name.identifier("EnhancedNullability"))
|
||||
|
||||
val PublishedApi = "PublishedApi".baseId()
|
||||
|
||||
val SinceKotlin = "SinceKotlin".baseId()
|
||||
|
||||
val coroutineContext = CallableId(StandardNames.COROUTINES_PACKAGE_FQ_NAME, Name.identifier("coroutineContext"))
|
||||
val suspend = CallableId(BASE_KOTLIN_PACKAGE, Name.identifier("suspend"))
|
||||
|
||||
val JvmStatic = "JvmStatic".jvmId()
|
||||
val JvmName = "JvmName".jvmId()
|
||||
val JvmField = "JvmField".jvmId()
|
||||
|
||||
val Result = "Result".baseId()
|
||||
|
||||
object Annotations {
|
||||
val Suppress = "Suppress".baseId()
|
||||
val PublishedApi = "PublishedApi".baseId()
|
||||
val SinceKotlin = "SinceKotlin".baseId()
|
||||
val ExtensionFunctionType = "ExtensionFunctionType".baseId()
|
||||
val Deprecated = "Deprecated".baseId()
|
||||
val DeprecatedSinceKotlin = "DeprecatedSinceKotlin".baseId()
|
||||
val Repeatable = "Repeatable".annotationId()
|
||||
|
||||
val Retention = "Retention".annotationId()
|
||||
val Target = "Target".annotationId()
|
||||
|
||||
val JvmStatic = "JvmStatic".jvmId()
|
||||
val JvmName = "JvmName".jvmId()
|
||||
val JvmField = "JvmField".jvmId()
|
||||
val JvmDefault = "JvmDefault".jvmId()
|
||||
val JvmRepeatable = "JvmRepeatable".jvmId()
|
||||
|
||||
val FlexibleNullability = "FlexibleNullability".internalIrId()
|
||||
val EnhancedNullability = "EnhancedNullability".jvmInternalId()
|
||||
|
||||
|
||||
object Java {
|
||||
val Deprecated = "Deprecated".javaLangId()
|
||||
val Repeatable = "Repeatable".javaAnnotationId()
|
||||
val Retention = "Retention".javaAnnotationId()
|
||||
val Documented = "Documented".javaAnnotationId()
|
||||
val Target = "Target".javaAnnotationId()
|
||||
}
|
||||
|
||||
object ParameterNames {
|
||||
val value = Name.identifier("value")
|
||||
|
||||
val retentionValue = value
|
||||
val targetAllowedTargets = Name.identifier("allowedTargets")
|
||||
val jvmNameName = Name.identifier("name")
|
||||
|
||||
val deprecatedMessage = Name.identifier("message")
|
||||
val deprecatedLevel = Name.identifier("level")
|
||||
|
||||
val deprecatedSinceKotlinWarningSince = Name.identifier("warningSince")
|
||||
val deprecatedSinceKotlinErrorSince = Name.identifier("errorSince")
|
||||
val deprecatedSinceKotlinHiddenSince = Name.identifier("hiddenSince")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun <K, V> Map<K, V>.inverseMap() = entries.associate { (k, v) -> v to k }
|
||||
private fun String.baseId() = ClassId(StandardClassIds.BASE_KOTLIN_PACKAGE, Name.identifier(this))
|
||||
private fun ClassId.unsignedId() = ClassId(StandardClassIds.BASE_KOTLIN_PACKAGE, Name.identifier("U" + shortClassName.identifier))
|
||||
private fun String.reflectId() = ClassId(StandardClassIds.BASE_REFLECT_PACKAGE, Name.identifier(this))
|
||||
private fun Name.primitiveArrayId() = ClassId(StandardClassIds.Array.packageFqName, Name.identifier(identifier + StandardClassIds.Array.shortClassName.identifier))
|
||||
private fun String.collectionsId() = ClassId(StandardClassIds.BASE_COLLECTIONS_PACKAGE, Name.identifier(this))
|
||||
private fun String.annotationId() = ClassId(StandardClassIds.BASE_ANNOTATION_PACKAGE, Name.identifier(this))
|
||||
private fun String.jvmId() = ClassId(StandardClassIds.BASE_JVM_PACKAGE, Name.identifier(this))
|
||||
private fun String.jvmInternalId() = ClassId(StandardClassIds.BASE_JVM_INTERNAL_PACKAGE, Name.identifier(this))
|
||||
private fun String.internalId() = ClassId(StandardClassIds.BASE_INTERNAL_PACKAGE, Name.identifier(this))
|
||||
private fun String.internalIrId() = ClassId(StandardClassIds.BASE_INTERNAL_IR_PACKAGE, Name.identifier(this))
|
||||
|
||||
private val JAVA_LANG_PACKAGE = FqName("java.lang")
|
||||
private val JAVA_LANG_ANNOTATION_PACKAGE = JAVA_LANG_PACKAGE.child(Name.identifier("annotation"))
|
||||
|
||||
private fun String.javaLangId() = ClassId(JAVA_LANG_PACKAGE, Name.identifier(this))
|
||||
private fun String.javaAnnotationId() = ClassId(JAVA_LANG_ANNOTATION_PACKAGE, Name.identifier(this))
|
||||
|
||||
private fun <K, V> Map<K, V>.inverseMap(): Map<V, K> = entries.associate { (k, v) -> v to k }
|
||||
|
||||
Reference in New Issue
Block a user