[JS] Migrate tests onto IR compiler with outputDir API instead of outputFile
^KT-61117 fixed
This commit is contained in:
committed by
Space Team
parent
e50f6e6bca
commit
08e3cb300a
@@ -23,17 +23,17 @@ import org.jetbrains.kotlin.incremental.js.IncrementalResultsConsumerImpl
|
||||
import org.jetbrains.kotlin.incremental.js.IrTranslationResultValue
|
||||
import org.jetbrains.kotlin.incremental.js.TranslationResultValue
|
||||
import org.jetbrains.kotlin.incremental.storage.*
|
||||
import org.jetbrains.kotlin.library.metadata.KlibMetadataProtoBuf
|
||||
import org.jetbrains.kotlin.library.metadata.KlibMetadataSerializerProtocol
|
||||
import org.jetbrains.kotlin.metadata.ProtoBuf
|
||||
import org.jetbrains.kotlin.metadata.deserialization.NameResolverImpl
|
||||
import org.jetbrains.kotlin.metadata.deserialization.getExtensionOrNull
|
||||
import org.jetbrains.kotlin.metadata.js.JsProtoBuf
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.parentOrNull
|
||||
import org.jetbrains.kotlin.serialization.SerializerExtensionProtocol
|
||||
import org.jetbrains.kotlin.serialization.deserialization.getClassId
|
||||
import org.jetbrains.kotlin.serialization.js.JsSerializerProtocol
|
||||
import org.jetbrains.kotlin.util.capitalizeDecapitalize.capitalizeAsciiOnly
|
||||
import java.io.DataInput
|
||||
import java.io.DataOutput
|
||||
@@ -371,7 +371,7 @@ private class ProtoDataProvider(private val serializerProtocol: SerializerExtens
|
||||
// TODO: remove this method once AbstractJsProtoComparisonTest is fixed
|
||||
fun getProtoData(sourceFile: File, metadata: ByteArray): Map<ClassId, ProtoData> {
|
||||
val classes = hashMapOf<ClassId, ProtoData>()
|
||||
val proto = ProtoBuf.PackageFragment.parseFrom(metadata, JsSerializerProtocol.extensionRegistry)
|
||||
val proto = ProtoBuf.PackageFragment.parseFrom(metadata, KlibMetadataSerializerProtocol.extensionRegistry)
|
||||
val nameResolver = NameResolverImpl(proto.strings, proto.qualifiedNames)
|
||||
|
||||
proto.class_List.forEach {
|
||||
@@ -380,7 +380,7 @@ fun getProtoData(sourceFile: File, metadata: ByteArray): Map<ClassId, ProtoData>
|
||||
}
|
||||
|
||||
proto.`package`.apply {
|
||||
val packageFqName = getExtensionOrNull(JsProtoBuf.packageFqName)?.let(nameResolver::getPackageFqName)?.let(::FqName) ?: FqName.ROOT
|
||||
val packageFqName = getExtensionOrNull(KlibMetadataProtoBuf.packageFqName)?.let(nameResolver::getPackageFqName)?.let(::FqName) ?: FqName.ROOT
|
||||
val packagePartClassId = ClassId(packageFqName, Name.identifier(sourceFile.nameWithoutExtension.capitalizeAsciiOnly() + "Kt"))
|
||||
classes[packagePartClassId] = PackagePartProtoData(this, nameResolver, packageFqName)
|
||||
}
|
||||
|
||||
@@ -21,8 +21,10 @@ import org.jetbrains.kotlin.incremental.ProtoCompareGenerated.ProtoBufClassKind
|
||||
import org.jetbrains.kotlin.incremental.ProtoCompareGenerated.ProtoBufPackageKind
|
||||
import org.jetbrains.kotlin.incremental.storage.ProtoMapValue
|
||||
import org.jetbrains.kotlin.metadata.ProtoBuf
|
||||
import org.jetbrains.kotlin.metadata.ProtoBuf.Type
|
||||
import org.jetbrains.kotlin.metadata.deserialization.Flags
|
||||
import org.jetbrains.kotlin.metadata.deserialization.NameResolver
|
||||
import org.jetbrains.kotlin.metadata.deserialization.TypeTable
|
||||
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmProtoBufUtil
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.protobuf.MessageLite
|
||||
@@ -260,10 +262,40 @@ class DifferenceCalculatorForClass(
|
||||
isClassAffected = true
|
||||
areSubclassesAffected = true
|
||||
|
||||
val oldSupertypes = oldProto.supertypeList.map { oldNameResolver.getClassId(it.className).asSingleFqName() }
|
||||
val newSupertypes = newProto.supertypeList.map { newNameResolver.getClassId(it.className).asSingleFqName() }
|
||||
val oldTypeTable = oldProto.typeTableOrNull?.let { TypeTable(it) }
|
||||
val newTypeTable = newProto.typeTableOrNull?.let { TypeTable(it) }
|
||||
|
||||
fun getSupertypes(supertypeList: List<Type>, nameResolver: NameResolver): List<FqName> {
|
||||
return supertypeList.map { nameResolver.getClassId(it.className).asSingleFqName() }
|
||||
}
|
||||
|
||||
fun getSupertypesById(supertypeIdList: List<Int>, typeTable: TypeTable?, nameResolver: NameResolver): List<FqName> {
|
||||
return supertypeIdList.mapNotNull { id ->
|
||||
typeTable?.get(id)?.className?.let {
|
||||
nameResolver.getClassId(it).asSingleFqName()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val oldSupertypes = getSupertypes(oldProto.supertypeList, oldNameResolver)
|
||||
val newSupertypes = getSupertypes(newProto.supertypeList, newNameResolver)
|
||||
|
||||
val oldSupertypesById = getSupertypesById(
|
||||
oldProto.supertypeIdList,
|
||||
oldTypeTable,
|
||||
oldNameResolver
|
||||
)
|
||||
|
||||
val newSupertypesById = getSupertypesById(
|
||||
newProto.supertypeIdList,
|
||||
newTypeTable,
|
||||
newNameResolver
|
||||
)
|
||||
|
||||
val changed = (oldSupertypes union newSupertypes) subtract (oldSupertypes intersect newSupertypes)
|
||||
changedSupertypes.addAll(changed)
|
||||
val changedById = (oldSupertypesById union newSupertypesById) subtract (oldSupertypesById intersect newSupertypesById)
|
||||
val elements: Set<FqName> = changed + changedById
|
||||
changedSupertypes.addAll(elements)
|
||||
}
|
||||
ProtoBufClassKind.JVM_EXT_CLASS_MODULE_NAME,
|
||||
ProtoBufClassKind.JS_EXT_CLASS_CONTAINING_FILE_ID -> {
|
||||
|
||||
Reference in New Issue
Block a user