Remove SerializedResourcePaths and BuiltInsSerializedResourcePaths

Most of members now only make sense for JS, move the rest to
BuiltInSerializerProtocol
This commit is contained in:
Alexander Udalov
2016-02-17 15:37:14 +03:00
committed by Alexander Udalov
parent 4bacabe354
commit f82ec6711d
16 changed files with 38 additions and 122 deletions
@@ -30,7 +30,7 @@ class KotlinJavascriptClassDataFinder(
) : ClassDataFinder {
override fun findClassData(classId: ClassId): ClassDataWithSource? {
val stream = loadResource(KotlinJavascriptSerializedResourcePaths.getClassMetadataPath(classId)) ?: return null
val classProto = ProtoBuf.Class.parseFrom(stream, KotlinJavascriptSerializedResourcePaths.extensionRegistry)
val classProto = ProtoBuf.Class.parseFrom(stream, JsSerializerProtocol.extensionRegistry)
return ClassDataWithSource(ClassData(nameResolver, classProto))
}
}
@@ -39,7 +39,7 @@ class KotlinJavascriptPackageFragment(
override fun computeMemberScope(): DeserializedPackageMemberScope {
val packageStream = loadResourceSure(KotlinJavascriptSerializedResourcePaths.getPackageFilePath(fqName))
val packageProto = ProtoBuf.Package.parseFrom(packageStream, KotlinJavascriptSerializedResourcePaths.extensionRegistry)
val packageProto = ProtoBuf.Package.parseFrom(packageStream, JsSerializerProtocol.extensionRegistry)
return DeserializedPackageMemberScope(
this, packageProto, nameResolver, packagePartSource = null, components = components, classNames = { loadClassNames() }
)
@@ -47,7 +47,7 @@ class KotlinJavascriptPackageFragment(
private fun loadClassNames(): Collection<Name> {
val classesStream = loadResourceSure(KotlinJavascriptSerializedResourcePaths.getClassesInPackageFilePath(fqName))
val classesProto = JsProtoBuf.Classes.parseFrom(classesStream, KotlinJavascriptSerializedResourcePaths.extensionRegistry)
val classesProto = JsProtoBuf.Classes.parseFrom(classesStream, JsSerializerProtocol.extensionRegistry)
return classesProto.classNameList?.map { id -> nameResolver.getName(id) } ?: listOf()
}
}
@@ -16,19 +16,11 @@
package org.jetbrains.kotlin.serialization.js
import com.google.protobuf.ExtensionRegistryLite
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.serialization.SerializedResourcePaths
object KotlinJavascriptSerializedResourcePaths : SerializedResourcePaths {
override val extensionRegistry: ExtensionRegistryLite = ExtensionRegistryLite.newInstance()
init {
JsProtoBuf.registerAllExtensions(extensionRegistry)
}
object KotlinJavascriptSerializedResourcePaths {
private val CLASSES_FILE_EXTENSION = "kotlin_classes"
private val STRING_TABLE_FILE_EXTENSION = "kotlin_string_table"
@@ -36,15 +28,15 @@ object KotlinJavascriptSerializedResourcePaths : SerializedResourcePaths {
fqName.toPath().withSepIfNotEmpty() + shortName(fqName) + "." + CLASSES_FILE_EXTENSION
override fun getClassMetadataPath(classId: ClassId): String {
fun getClassMetadataPath(classId: ClassId): String {
return classId.packageFqName.toPath().withSepIfNotEmpty() + classId.relativeClassName.asString() +
"." + KotlinJavascriptSerializationUtil.CLASS_METADATA_FILE_EXTENSION
}
override fun getPackageFilePath(fqName: FqName): String =
fun getPackageFilePath(fqName: FqName): String =
getPackageClassFqName(fqName).toPath() + "." + KotlinJavascriptSerializationUtil.CLASS_METADATA_FILE_EXTENSION
override fun getStringTableFilePath(fqName: FqName): String =
fun getStringTableFilePath(fqName: FqName): String =
fqName.toPath().withSepIfNotEmpty() + shortName(fqName) + "." + STRING_TABLE_FILE_EXTENSION
private fun FqName.toPath() = this.asString().replace('.', '/')
@@ -16,12 +16,14 @@
package org.jetbrains.kotlin.serialization.js
import com.google.protobuf.ExtensionRegistryLite
import org.jetbrains.kotlin.serialization.KotlinSerializerExtensionBase
import org.jetbrains.kotlin.serialization.SerializerExtensionProtocol
class KotlinJavascriptSerializerExtension : KotlinSerializerExtensionBase(JsSerializerProtocol)
object JsSerializerProtocol : SerializerExtensionProtocol(
ExtensionRegistryLite.newInstance().apply { JsProtoBuf.registerAllExtensions(this) },
JsProtoBuf.constructorAnnotation, JsProtoBuf.classAnnotation, JsProtoBuf.functionAnnotation, JsProtoBuf.propertyAnnotation,
JsProtoBuf.enumEntryAnnotation, JsProtoBuf.compileTimeValue, JsProtoBuf.parameterAnnotation, JsProtoBuf.typeAnnotation,
JsProtoBuf.typeParameterAnnotation