js: cleanup 'public', property access syntax
This commit is contained in:
+4
-4
@@ -21,8 +21,8 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.serialization.DescriptorSerializer
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
|
||||
public object ClassSerializationUtil {
|
||||
public interface Sink {
|
||||
object ClassSerializationUtil {
|
||||
interface Sink {
|
||||
fun writeClass(classDescriptor: ClassDescriptor, classProto: ProtoBuf.Class)
|
||||
}
|
||||
|
||||
@@ -32,10 +32,10 @@ public object ClassSerializationUtil {
|
||||
val classProto = serializer.classProto(classDescriptor).build() ?: error("Class not serialized: $classDescriptor")
|
||||
sink.writeClass(classDescriptor, classProto)
|
||||
|
||||
serializeClasses(classDescriptor.getUnsubstitutedInnerClassesScope().getContributedDescriptors(), serializer, sink, skip)
|
||||
serializeClasses(classDescriptor.unsubstitutedInnerClassesScope.getContributedDescriptors(), serializer, sink, skip)
|
||||
}
|
||||
|
||||
public fun serializeClasses(descriptors: Collection<DeclarationDescriptor>, serializer: DescriptorSerializer, sink: Sink, skip: (DeclarationDescriptor) -> Boolean) {
|
||||
fun serializeClasses(descriptors: Collection<DeclarationDescriptor>, serializer: DescriptorSerializer, sink: Sink, skip: (DeclarationDescriptor) -> Boolean) {
|
||||
for (descriptor in descriptors) {
|
||||
if (descriptor is ClassDescriptor) {
|
||||
serializeClass(descriptor, serializer, sink, skip)
|
||||
|
||||
+2
-2
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.serialization.deserialization.NameResolverImpl
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import java.io.InputStream
|
||||
|
||||
public class KotlinJavascriptPackageFragment(
|
||||
class KotlinJavascriptPackageFragment(
|
||||
fqName: FqName,
|
||||
storageManager: StorageManager,
|
||||
module: ModuleDescriptor,
|
||||
@@ -36,7 +36,7 @@ public class KotlinJavascriptPackageFragment(
|
||||
|
||||
override val classIdToProto: Map<ClassId, ProtoBuf.Class>? get() = null
|
||||
|
||||
protected override fun loadClassNames(packageProto: ProtoBuf.Package): Collection<Name> {
|
||||
override fun loadClassNames(packageProto: ProtoBuf.Package): Collection<Name> {
|
||||
val classesStream = loadResourceSure(KotlinJavascriptSerializedResourcePaths.getClassesInPackageFilePath(fqName))
|
||||
val classesProto = JsProtoBuf.Classes.parseFrom(classesStream, serializedResourcePaths.extensionRegistry)
|
||||
return classesProto.classNameList?.map { id -> nameResolver.getName(id) } ?: listOf()
|
||||
|
||||
+9
-10
@@ -35,8 +35,8 @@ import java.util.*
|
||||
import java.util.zip.GZIPInputStream
|
||||
import java.util.zip.GZIPOutputStream
|
||||
|
||||
public object KotlinJavascriptSerializationUtil {
|
||||
public val CLASS_METADATA_FILE_EXTENSION: String = "kjsm"
|
||||
object KotlinJavascriptSerializationUtil {
|
||||
val CLASS_METADATA_FILE_EXTENSION: String = "kjsm"
|
||||
|
||||
private val PACKAGE_DEFAULT_BYTES = run {
|
||||
val stream = ByteArrayOutputStream()
|
||||
@@ -57,8 +57,7 @@ public object KotlinJavascriptSerializationUtil {
|
||||
stream.toByteArray()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
public fun createPackageFragmentProvider(moduleDescriptor: ModuleDescriptor, metadata: ByteArray, storageManager: StorageManager): PackageFragmentProvider? {
|
||||
@JvmStatic fun createPackageFragmentProvider(moduleDescriptor: ModuleDescriptor, metadata: ByteArray, storageManager: StorageManager): PackageFragmentProvider? {
|
||||
val contentMap = metadata.toContentMap()
|
||||
|
||||
val packageFqNames = getPackages(contentMap).map { FqName(it) }.toSet()
|
||||
@@ -82,7 +81,7 @@ public object KotlinJavascriptSerializationUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public fun contentMapToByteArray(contentMap: Map<String, ByteArray>): ByteArray {
|
||||
fun contentMapToByteArray(contentMap: Map<String, ByteArray>): ByteArray {
|
||||
val contentBuilder = JsProtoBuf.Library.newBuilder()
|
||||
contentMap.forEach {
|
||||
val entry = JsProtoBuf.Library.FileEntry.newBuilder().setPath(it.key).setContent(ByteString.copyFrom(it.value)).build()
|
||||
@@ -97,7 +96,7 @@ public object KotlinJavascriptSerializationUtil {
|
||||
return byteStream.toByteArray()
|
||||
}
|
||||
|
||||
public fun metadataAsString(moduleName: String, moduleDescriptor: ModuleDescriptor): String =
|
||||
fun metadataAsString(moduleName: String, moduleDescriptor: ModuleDescriptor): String =
|
||||
KotlinJavascriptMetadataUtils.formatMetadataAsString(moduleName, moduleDescriptor.toBinaryMetadata())
|
||||
|
||||
fun serializePackage(module: ModuleDescriptor, fqName: FqName, writeFun: (String, ByteArray) -> Unit) {
|
||||
@@ -152,7 +151,7 @@ public object KotlinJavascriptSerializationUtil {
|
||||
val builder = JsProtoBuf.Classes.newBuilder()
|
||||
|
||||
for (descriptor in DescriptorSerializer.sort(classes)) {
|
||||
builder.addClassName(stringTable.getSimpleNameIndex(descriptor.getName()))
|
||||
builder.addClassName(stringTable.getSimpleNameIndex(descriptor.name))
|
||||
}
|
||||
|
||||
val classesProto = builder.build()
|
||||
@@ -168,7 +167,7 @@ public object KotlinJavascriptSerializationUtil {
|
||||
return KotlinJavascriptSerializedResourcePaths.getClassMetadataPath(classDescriptor.classId)
|
||||
}
|
||||
|
||||
public fun toContentMap(module: ModuleDescriptor): Map<String, ByteArray> {
|
||||
fun toContentMap(module: ModuleDescriptor): Map<String, ByteArray> {
|
||||
val contentMap = hashMapOf<String, ByteArray>()
|
||||
|
||||
getPackagesFqNames(module).forEach {
|
||||
@@ -221,7 +220,7 @@ public object KotlinJavascriptSerializationUtil {
|
||||
KotlinJavascriptSerializationUtil.contentMapToByteArray(toContentMap(this))
|
||||
}
|
||||
|
||||
public fun KotlinJavascriptMetadata.forEachFile(operation: (filePath: String, fileContent: ByteArray) -> Unit): Unit =
|
||||
fun KotlinJavascriptMetadata.forEachFile(operation: (filePath: String, fileContent: ByteArray) -> Unit): Unit =
|
||||
this.body.toContentMap().forEach { operation(it.key, it.value) }
|
||||
|
||||
private fun ByteArray.toContentMap(): Map<String, ByteArray> {
|
||||
@@ -230,7 +229,7 @@ private fun ByteArray.toContentMap(): Map<String, ByteArray> {
|
||||
gzipInputStream.close()
|
||||
|
||||
val contentMap: MutableMap<String, ByteArray> = hashMapOf()
|
||||
content.getEntryList().forEach { entry -> contentMap[entry.getPath()] = entry.getContent().toByteArray() }
|
||||
content.entryList.forEach { entry -> contentMap[entry.path] = entry.content.toByteArray() }
|
||||
|
||||
return contentMap
|
||||
}
|
||||
+5
-5
@@ -60,17 +60,17 @@ private val PACKAGE_CLASS_NAME_SUFFIX: String = "Package"
|
||||
private val DEFAULT_PACKAGE_CLASS_NAME: String = "_Default" + PACKAGE_CLASS_NAME_SUFFIX
|
||||
private val DEFAULT_PACKAGE_METAFILE_NAME: String = DEFAULT_PACKAGE_CLASS_NAME + "." + KotlinJavascriptSerializationUtil.CLASS_METADATA_FILE_EXTENSION
|
||||
|
||||
public fun FqName.isPackageClassFqName(): Boolean = !this.isRoot && getPackageClassFqName(this.parent()) == this
|
||||
fun FqName.isPackageClassFqName(): Boolean = !this.isRoot && getPackageClassFqName(this.parent()) == this
|
||||
|
||||
public fun isDefaultPackageMetafile(fileName: String): Boolean = fileName == DEFAULT_PACKAGE_METAFILE_NAME
|
||||
fun isDefaultPackageMetafile(fileName: String): Boolean = fileName == DEFAULT_PACKAGE_METAFILE_NAME
|
||||
|
||||
public fun isPackageMetadataFile(fileName: String): Boolean =
|
||||
fun isPackageMetadataFile(fileName: String): Boolean =
|
||||
KotlinJavascriptSerializedResourcePaths.getPackageFilePath(getPackageFqName(fileName)) == fileName
|
||||
|
||||
public fun isStringTableFile(fileName: String): Boolean =
|
||||
fun isStringTableFile(fileName: String): Boolean =
|
||||
KotlinJavascriptSerializedResourcePaths.getStringTableFilePath(getPackageFqName(fileName)) == fileName
|
||||
|
||||
public fun isClassesInPackageFile(fileName: String): Boolean =
|
||||
fun isClassesInPackageFile(fileName: String): Boolean =
|
||||
KotlinJavascriptSerializedResourcePaths.getClassesInPackageFilePath(getPackageFqName(fileName)) == fileName
|
||||
|
||||
private fun getPackageFqName(fileName: String): FqName = FqName(getPackageName(fileName))
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.serialization.js
|
||||
import org.jetbrains.kotlin.serialization.KotlinSerializerExtensionBase
|
||||
import org.jetbrains.kotlin.serialization.SerializerExtensionProtocol
|
||||
|
||||
public class KotlinJavascriptSerializerExtension : KotlinSerializerExtensionBase(JsSerializerProtocol)
|
||||
class KotlinJavascriptSerializerExtension : KotlinSerializerExtensionBase(JsSerializerProtocol)
|
||||
|
||||
object JsSerializerProtocol : SerializerExtensionProtocol(
|
||||
JsProtoBuf.constructorAnnotation, JsProtoBuf.classAnnotation, JsProtoBuf.functionAnnotation, JsProtoBuf.propertyAnnotation,
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.serialization.deserialization.*
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import java.io.InputStream
|
||||
|
||||
public fun createKotlinJavascriptPackageFragmentProvider(
|
||||
fun createKotlinJavascriptPackageFragmentProvider(
|
||||
storageManager: StorageManager,
|
||||
module: ModuleDescriptor,
|
||||
packageFqNames: Set<FqName>,
|
||||
|
||||
Reference in New Issue
Block a user