kotlin.reflect.jvm.internal.impl.serialization.deserialization.builtins.BuiltInSerializerProtocol.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlin-reflect Show documentation
Show all versions of kotlin-reflect Show documentation
Kotlin Full Reflection Library
/*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package kotlin.reflect.jvm.internal.impl.serialization.deserialization.builtins
import kotlin.reflect.jvm.internal.impl.metadata.builtins.BuiltInsProtoBuf
import kotlin.reflect.jvm.internal.impl.name.FqName
import kotlin.reflect.jvm.internal.impl.protobuf.ExtensionRegistryLite
import kotlin.reflect.jvm.internal.impl.serialization.SerializerExtensionProtocol
object BuiltInSerializerProtocol : SerializerExtensionProtocol(
ExtensionRegistryLite.newInstance().apply(BuiltInsProtoBuf::registerAllExtensions),
BuiltInsProtoBuf.packageFqName,
BuiltInsProtoBuf.constructorAnnotation,
BuiltInsProtoBuf.classAnnotation,
BuiltInsProtoBuf.functionAnnotation,
BuiltInsProtoBuf.propertyAnnotation,
BuiltInsProtoBuf.propertyGetterAnnotation,
BuiltInsProtoBuf.propertySetterAnnotation,
BuiltInsProtoBuf.enumEntryAnnotation,
BuiltInsProtoBuf.compileTimeValue,
BuiltInsProtoBuf.parameterAnnotation,
BuiltInsProtoBuf.typeAnnotation,
BuiltInsProtoBuf.typeParameterAnnotation
) {
const val BUILTINS_FILE_EXTENSION = "kotlin_builtins"
fun getBuiltInsFilePath(fqName: FqName): String =
fqName.asString().replace('.', '/') + "/" + getBuiltInsFileName(
fqName
)
fun getBuiltInsFileName(fqName: FqName): String =
shortName(fqName) + "." + BUILTINS_FILE_EXTENSION
private fun shortName(fqName: FqName): String =
if (fqName.isRoot) "default-package" else fqName.shortName().asString()
}