[Serialization] Reorganize module structure
This commit is contained in:
Generated
+1
-1
@@ -53,7 +53,7 @@
|
||||
<file url="file://$PROJECT_DIR$/libraries/tools/maven-archetypes/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/plugins/allopen/allopen.cli/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/plugins/kapt3/kapt3-compiler/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/plugins/kotlin-serialization/kotlin-serialization-compiler/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/plugins/kotlinx-serialization/kotlinx-serialization.cli/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/plugins/lombok/lombok.cli/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/plugins/noarg/noarg.cli/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/plugins/sam-with-receiver/sam-with-receiver.cli/resources" charset="UTF-8" />
|
||||
|
||||
+1
-1
@@ -79,11 +79,11 @@
|
||||
<option value="$PROJECT_DIR$/plugins/kapt3/kapt3-base/testData" />
|
||||
<option value="$PROJECT_DIR$/plugins/kapt3/kapt3-cli/testData" />
|
||||
<option value="$PROJECT_DIR$/plugins/kapt3/kapt3-compiler/testData" />
|
||||
<option value="$PROJECT_DIR$/plugins/kotlin-serialization/kotlin-serialization-compiler/testData" />
|
||||
<option value="$PROJECT_DIR$/plugins/noarg/testData" />
|
||||
<option value="$PROJECT_DIR$/plugins/parcelize/parcelize-compiler/testData" />
|
||||
<option value="$PROJECT_DIR$/plugins/lombok/testData" />
|
||||
<option value="$PROJECT_DIR$/plugins/sam-with-receiver/testData" />
|
||||
<option value="$PROJECT_DIR$/plugins/kotlinx-serialization/testData" />
|
||||
</array>
|
||||
</option>
|
||||
</component>
|
||||
|
||||
@@ -53,7 +53,7 @@ val PROTO_PATHS: List<ProtoPath> = listOf(
|
||||
ProtoPath("compiler/util-klib-metadata/src/KlibMetadataProtoBuf.proto"),
|
||||
ProtoPath("compiler/ir/serialization.common/src/KotlinIr.proto", false),
|
||||
ProtoPath("compiler/ir/serialization.jvm/src/JvmIr.proto", false),
|
||||
ProtoPath("plugins/kotlin-serialization/kotlin-serialization-compiler/src/class_extensions.proto", generateDebug = false)
|
||||
ProtoPath("plugins/kotlinx-serialization/kotlinx-serialization.k1/src/class_extensions.proto", generateDebug = false)
|
||||
)
|
||||
|
||||
private val EXT_OPTIONS_PROTO_PATH = ProtoPath("core/metadata/src/ext_options.proto")
|
||||
|
||||
@@ -207,23 +207,6 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
}
|
||||
|
||||
testGroup(
|
||||
"plugins/kotlin-serialization/kotlin-serialization-compiler/test",
|
||||
"plugins/kotlin-serialization/kotlin-serialization-compiler/testData"
|
||||
) {
|
||||
testClass<AbstractSerializationPluginDiagnosticTest> {
|
||||
model("diagnostics")
|
||||
}
|
||||
|
||||
testClass<AbstractSerializationPluginBytecodeListingTest> {
|
||||
model("codegen")
|
||||
}
|
||||
|
||||
testClass<AbstractSerializationIrBytecodeListingTest> {
|
||||
model("codegen")
|
||||
}
|
||||
}
|
||||
|
||||
testGroup("plugins/fir-plugin-prototype/fir-plugin-ic-test/tests-gen", "plugins/fir-plugin-prototype/fir-plugin-ic-test/testData") {
|
||||
testClass<AbstractIncrementalFirJvmWithPluginCompilerRunnerTest> {
|
||||
model("pureKotlin", extension = null, recursive = false, targetBackend = TargetBackend.JVM_IR)
|
||||
|
||||
@@ -6,8 +6,12 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<properties>
|
||||
<maven.version>3.0.5</maven.version>
|
||||
<serialization.src>${basedir}/../../../plugins/kotlin-serialization/kotlin-serialization-compiler/src/</serialization.src>
|
||||
<serialization.resources>${basedir}/../../../plugins/kotlin-serialization/kotlin-serialization-compiler/resources/</serialization.resources>
|
||||
<serialization.common.src>${basedir}/../../../plugins/kotlinx-serialization/kotlinx-serialization.common/src</serialization.common.src>
|
||||
<serialization.k1.src>${basedir}/../../../plugins/kotlinx-serialization/kotlinx-serialization.k1/src</serialization.k1.src>
|
||||
<serialization.k2.src>${basedir}/../../../plugins/kotlinx-serialization/kotlinx-serialization.k2/src</serialization.k2.src>
|
||||
<serialization.backend.src>${basedir}/../../../plugins/kotlinx-serialization/kotlinx-serialization.backend/src</serialization.backend.src>
|
||||
<serialization.cli.src>${basedir}/../../../plugins/kotlinx-serialization/kotlinx-serialization.cli/src</serialization.cli.src>
|
||||
<serialization.resources>${basedir}/../../../plugins/kotlinx-serialization/kotlinx-serialization.cli/resources</serialization.resources>
|
||||
<serialization.maven.plugin.src>${basedir}/src/main/kotlin</serialization.maven.plugin.src>
|
||||
</properties>
|
||||
|
||||
@@ -53,7 +57,11 @@
|
||||
<goals><goal>add-source</goal></goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>${serialization.src}</source>
|
||||
<source>${serialization.common.src}</source>
|
||||
<source>${serialization.k1.src}</source>
|
||||
<source>${serialization.k2.src}</source>
|
||||
<source>${serialization.backend.src}</source>
|
||||
<source>${serialization.cli.src}</source>
|
||||
<source>${serialization.maven.plugin.src}</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
description = "Kotlin Serialization Compiler Plugin"
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("jps-compatible")
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(intellijCore())
|
||||
compileOnly(commonDependency("org.jetbrains.intellij.deps:asm-all"))
|
||||
|
||||
compileOnly(project(":compiler:plugin-api"))
|
||||
compileOnly(project(":compiler:cli-common"))
|
||||
compileOnly(project(":compiler:frontend"))
|
||||
compileOnly(project(":compiler:backend"))
|
||||
compileOnly(project(":compiler:ir.backend.common"))
|
||||
compileOnly(project(":compiler:backend.jvm"))
|
||||
compileOnly(project(":compiler:ir.tree"))
|
||||
compileOnly(project(":js:js.frontend"))
|
||||
compileOnly(project(":js:js.translator"))
|
||||
compileOnly(project(":kotlin-util-klib-metadata"))
|
||||
|
||||
// FIR dependencies
|
||||
compileOnly(project(":compiler:fir:cones"))
|
||||
compileOnly(project(":compiler:fir:tree"))
|
||||
compileOnly(project(":compiler:fir:resolve"))
|
||||
// compileOnly(project(":compiler:fir:checkers"))
|
||||
// compileOnly(project(":compiler:fir:checkers:checkers.jvm"))
|
||||
// compileOnly(project(":compiler:fir:fir2ir"))
|
||||
// compileOnly(project(":compiler:ir.tree.impl"))
|
||||
compileOnly(project(":compiler:fir:entrypoint"))
|
||||
|
||||
runtimeOnly(kotlinStdlib())
|
||||
|
||||
testApi(projectTests(":compiler:tests-common"))
|
||||
testApi(projectTests(":compiler:test-infrastructure"))
|
||||
testApi(projectTests(":compiler:test-infrastructure-utils"))
|
||||
testApi(projectTests(":compiler:tests-compiler-utils"))
|
||||
testApi(projectTests(":compiler:tests-common-new"))
|
||||
testImplementation(projectTests(":generators:test-generator"))
|
||||
testApi(commonDependency("junit:junit"))
|
||||
testApiJUnit5(vintageEngine = true)
|
||||
|
||||
testImplementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.4.0-RC")
|
||||
testImplementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.0-RC")
|
||||
|
||||
testRuntimeOnly(intellijCore())
|
||||
testRuntimeOnly(project(":kotlin-reflect"))
|
||||
testRuntimeOnly(project(":core:descriptors.runtime"))
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
"main" { projectDefault() }
|
||||
"test" { projectDefault() }
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>> {
|
||||
kotlinOptions {
|
||||
freeCompilerArgs += "-opt-in=org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi"
|
||||
}
|
||||
}
|
||||
|
||||
optInToExperimentalCompilerApi()
|
||||
|
||||
runtimeJar()
|
||||
sourcesJar()
|
||||
javadocJar()
|
||||
testsJar()
|
||||
|
||||
projectTest(parallel = true, jUnitMode = JUnitMode.JUnit5) {
|
||||
workingDir = rootDir
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
val generateTests by generator("org.jetbrains.kotlinx.serialization.TestGeneratorKt")
|
||||
@@ -0,0 +1,64 @@
|
||||
description = "Kotlin Serialization Compiler Plugin"
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("jps-compatible")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
embedded(project(":kotlinx-serialization-compiler-plugin.common"))
|
||||
embedded(project(":kotlinx-serialization-compiler-plugin.k1"))
|
||||
embedded(project(":kotlinx-serialization-compiler-plugin.k2"))
|
||||
embedded(project(":kotlinx-serialization-compiler-plugin.backend"))
|
||||
embedded(project(":kotlinx-serialization-compiler-plugin.cli"))
|
||||
|
||||
testApi(project(":compiler:backend"))
|
||||
testApi(project(":compiler:cli"))
|
||||
testApi(project(":kotlinx-serialization-compiler-plugin.cli"))
|
||||
|
||||
testApi(projectTests(":compiler:tests-common"))
|
||||
testApi(projectTests(":compiler:test-infrastructure"))
|
||||
testApi(projectTests(":compiler:test-infrastructure-utils"))
|
||||
testApi(projectTests(":compiler:tests-compiler-utils"))
|
||||
testApi(projectTests(":compiler:tests-common-new"))
|
||||
testImplementation(projectTests(":generators:test-generator"))
|
||||
testApi(commonDependency("junit:junit"))
|
||||
testApiJUnit5(vintageEngine = true)
|
||||
|
||||
testImplementation(project(":kotlinx-serialization-compiler-plugin.common"))
|
||||
testImplementation(project(":kotlinx-serialization-compiler-plugin.k1"))
|
||||
testImplementation(project(":kotlinx-serialization-compiler-plugin.k2"))
|
||||
testImplementation(project(":kotlinx-serialization-compiler-plugin.backend"))
|
||||
testImplementation(project(":kotlinx-serialization-compiler-plugin.cli"))
|
||||
|
||||
testImplementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.4.0-RC")
|
||||
testImplementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.0-RC")
|
||||
|
||||
testRuntimeOnly(intellijCore())
|
||||
testRuntimeOnly(project(":kotlin-reflect"))
|
||||
testRuntimeOnly(project(":core:descriptors.runtime"))
|
||||
}
|
||||
|
||||
optInToExperimentalCompilerApi()
|
||||
|
||||
sourceSets {
|
||||
"main" { none() }
|
||||
"test" {
|
||||
projectDefault()
|
||||
generatedTestDir()
|
||||
}
|
||||
}
|
||||
|
||||
optInToExperimentalCompilerApi()
|
||||
|
||||
runtimeJar()
|
||||
sourcesJar()
|
||||
javadocJar()
|
||||
testsJar()
|
||||
|
||||
projectTest(parallel = true, jUnitMode = JUnitMode.JUnit5) {
|
||||
workingDir = rootDir
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
val generateTests by generator("org.jetbrains.kotlinx.serialization.TestGeneratorKt")
|
||||
@@ -0,0 +1,31 @@
|
||||
description = "Kotlin Serialization Compiler Plugin (Backend)"
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("jps-compatible")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":compiler:backend"))
|
||||
compileOnly(project(":compiler:ir.backend.common"))
|
||||
compileOnly(project(":compiler:backend.jvm"))
|
||||
compileOnly(project(":compiler:ir.tree"))
|
||||
compileOnly(project(":js:js.frontend"))
|
||||
compileOnly(project(":js:js.translator"))
|
||||
compileOnly(project(":kotlin-util-klib-metadata"))
|
||||
compileOnly(project(":compiler:cli-common"))
|
||||
|
||||
implementation(project(":kotlinx-serialization-compiler-plugin.common"))
|
||||
implementation(project(":kotlinx-serialization-compiler-plugin.k1"))
|
||||
|
||||
compileOnly(intellijCore())
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
"main" { projectDefault() }
|
||||
"test" { none() }
|
||||
}
|
||||
|
||||
runtimeJar()
|
||||
sourcesJar()
|
||||
javadocJar()
|
||||
+2
-2
@@ -30,7 +30,7 @@ abstract class SerializableCodegen(
|
||||
|
||||
private fun generateSyntheticInternalConstructor() {
|
||||
val serializerDescriptor = serializableDescriptor.classSerializer ?: return
|
||||
if (serializableDescriptor.shouldHaveSpecificSyntheticMethods { SerializerCodegen.getSyntheticLoadMember(serializerDescriptor) }) {
|
||||
if (serializableDescriptor.shouldHaveSpecificSyntheticMethods { SerializationDescriptorUtils.getSyntheticLoadMember(serializerDescriptor) }) {
|
||||
val constrDesc = serializableDescriptor.secondaryConstructors.find(ClassConstructorDescriptor::isSerializationCtor) ?: return
|
||||
generateInternalConstructor(constrDesc)
|
||||
}
|
||||
@@ -38,7 +38,7 @@ abstract class SerializableCodegen(
|
||||
|
||||
private fun generateSyntheticMethods() {
|
||||
val serializerDescriptor = serializableDescriptor.classSerializer ?: return
|
||||
if (serializableDescriptor.shouldHaveSpecificSyntheticMethods { SerializerCodegen.getSyntheticSaveMember(serializerDescriptor) }) {
|
||||
if (serializableDescriptor.shouldHaveSpecificSyntheticMethods { SerializationDescriptorUtils.getSyntheticSaveMember(serializerDescriptor) }) {
|
||||
val func =
|
||||
serializableDescriptor.unsubstitutedMemberScope.getContributedFunctions(
|
||||
Name.identifier(SerialEntityNames.WRITE_SELF_NAME.toString()),
|
||||
+2
-12
@@ -11,6 +11,8 @@ import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.ir.declarations.IrProperty
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlinx.serialization.compiler.backend.common.SerializationDescriptorUtils.getSyntheticLoadMember
|
||||
import org.jetbrains.kotlinx.serialization.compiler.backend.common.SerializationDescriptorUtils.getSyntheticSaveMember
|
||||
import org.jetbrains.kotlinx.serialization.compiler.extensions.SerializationDescriptorSerializerPlugin
|
||||
import org.jetbrains.kotlinx.serialization.compiler.resolve.*
|
||||
|
||||
@@ -143,16 +145,4 @@ abstract class SerializerCodegen(
|
||||
property.returnType != null &&
|
||||
isReturnTypeOk(property)
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun getSyntheticLoadMember(serializerDescriptor: ClassDescriptor): FunctionDescriptor? = getMemberToGenerate(
|
||||
serializerDescriptor, SerialEntityNames.LOAD,
|
||||
serializerDescriptor::checkLoadMethodResult, serializerDescriptor::checkLoadMethodParameters
|
||||
)
|
||||
|
||||
fun getSyntheticSaveMember(serializerDescriptor: ClassDescriptor): FunctionDescriptor? = getMemberToGenerate(
|
||||
serializerDescriptor, SerialEntityNames.SAVE,
|
||||
serializerDescriptor::checkSaveMethodResult, serializerDescriptor::checkSaveMethodParameters
|
||||
)
|
||||
}
|
||||
}
|
||||
-9
@@ -181,15 +181,6 @@ internal fun ImplementationBodyCodegen.generateMethod(
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
internal val enumSerializerId = ClassId(internalPackageFqName, Name.identifier(SpecialBuiltins.enumSerializer))
|
||||
internal val polymorphicSerializerId = ClassId(packageFqName, Name.identifier(SpecialBuiltins.polymorphicSerializer))
|
||||
internal val referenceArraySerializerId = ClassId(internalPackageFqName, Name.identifier(SpecialBuiltins.referenceArraySerializer))
|
||||
internal val objectSerializerId = ClassId(internalPackageFqName, Name.identifier(SpecialBuiltins.objectSerializer))
|
||||
internal val sealedSerializerId = ClassId(packageFqName, Name.identifier(SpecialBuiltins.sealedSerializer))
|
||||
internal val contextSerializerId = ClassId(packageFqName, Name.identifier(SpecialBuiltins.contextSerializer))
|
||||
|
||||
|
||||
internal fun InstructionAdapter.stackValueSerializerInstanceFromClass(
|
||||
expressionCodegen: ExpressionCodegen,
|
||||
classCodegen: ClassBodyCodegen,
|
||||
@@ -0,0 +1,31 @@
|
||||
description = "Kotlin Serialization Compiler Plugin (CLI)"
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("jps-compatible")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":compiler:util"))
|
||||
compileOnly(project(":compiler:cli"))
|
||||
compileOnly(project(":compiler:plugin-api"))
|
||||
compileOnly(project(":compiler:fir:entrypoint"))
|
||||
|
||||
implementation(project(":kotlinx-serialization-compiler-plugin.common"))
|
||||
implementation(project(":kotlinx-serialization-compiler-plugin.k1"))
|
||||
implementation(project(":kotlinx-serialization-compiler-plugin.k2"))
|
||||
implementation(project(":kotlinx-serialization-compiler-plugin.backend"))
|
||||
|
||||
compileOnly(intellijCore())
|
||||
}
|
||||
|
||||
optInToExperimentalCompilerApi()
|
||||
|
||||
sourceSets {
|
||||
"main" { projectDefault() }
|
||||
"test" { none() }
|
||||
}
|
||||
|
||||
runtimeJar()
|
||||
sourcesJar()
|
||||
javadocJar()
|
||||
@@ -0,0 +1,21 @@
|
||||
description = "Kotlin Serialization Compiler Plugin (Common)"
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("jps-compatible")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":compiler:util"))
|
||||
compileOnly(project(":core:compiler.common"))
|
||||
compileOnly(intellijCore())
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
"main" { projectDefault() }
|
||||
"test" { none() }
|
||||
}
|
||||
|
||||
runtimeJar()
|
||||
sourcesJar()
|
||||
javadocJar()
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright 2010-2022 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 org.jetbrains.kotlinx.serialization.compiler.fir
|
||||
|
||||
import org.jetbrains.kotlin.GeneratedDeclarationKey
|
||||
|
||||
object SerializationPluginKey : GeneratedDeclarationKey() {
|
||||
override fun toString(): String {
|
||||
return "KotlinxSerializationPlugin"
|
||||
}
|
||||
}
|
||||
+21
-21
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2022 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.
|
||||
*/
|
||||
|
||||
@@ -11,11 +11,11 @@ import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
object SerializationPackages {
|
||||
internal val packageFqName = FqName("kotlinx.serialization")
|
||||
internal val internalPackageFqName = FqName("kotlinx.serialization.internal")
|
||||
internal val encodingPackageFqName = FqName("kotlinx.serialization.encoding")
|
||||
internal val descriptorsPackageFqName = FqName("kotlinx.serialization.descriptors")
|
||||
internal val builtinsPackageFqName = FqName("kotlinx.serialization.builtins")
|
||||
val packageFqName = FqName("kotlinx.serialization")
|
||||
val internalPackageFqName = FqName("kotlinx.serialization.internal")
|
||||
val encodingPackageFqName = FqName("kotlinx.serialization.encoding")
|
||||
val descriptorsPackageFqName = FqName("kotlinx.serialization.descriptors")
|
||||
val builtinsPackageFqName = FqName("kotlinx.serialization.builtins")
|
||||
|
||||
val allPublicPackages = listOf(packageFqName, encodingPackageFqName, descriptorsPackageFqName, builtinsPackageFqName)
|
||||
}
|
||||
@@ -27,20 +27,20 @@ object SerializationAnnotations {
|
||||
// Otherwise, there it might lead to exceptions from light classes when building them for serializer/serializable classes
|
||||
val serializableAnnotationFqName = FqName("kotlinx.serialization.Serializable")
|
||||
val serializerAnnotationFqName = FqName("kotlinx.serialization.Serializer")
|
||||
internal val serialNameAnnotationFqName = FqName("kotlinx.serialization.SerialName")
|
||||
internal val requiredAnnotationFqName = FqName("kotlinx.serialization.Required")
|
||||
val serialNameAnnotationFqName = FqName("kotlinx.serialization.SerialName")
|
||||
val requiredAnnotationFqName = FqName("kotlinx.serialization.Required")
|
||||
val serialTransientFqName = FqName("kotlinx.serialization.Transient")
|
||||
// Also implicitly used in kotlin-native.compiler.backend.native/CodeGenerationInfo.kt
|
||||
internal val serialInfoFqName = FqName("kotlinx.serialization.SerialInfo")
|
||||
internal val inheritableSerialInfoFqName = FqName("kotlinx.serialization.InheritableSerialInfo")
|
||||
internal val metaSerializableAnnotationFqName = FqName("kotlinx.serialization.MetaSerializable")
|
||||
internal val encodeDefaultFqName = FqName("kotlinx.serialization.EncodeDefault")
|
||||
val serialInfoFqName = FqName("kotlinx.serialization.SerialInfo")
|
||||
val inheritableSerialInfoFqName = FqName("kotlinx.serialization.InheritableSerialInfo")
|
||||
val metaSerializableAnnotationFqName = FqName("kotlinx.serialization.MetaSerializable")
|
||||
val encodeDefaultFqName = FqName("kotlinx.serialization.EncodeDefault")
|
||||
|
||||
internal val contextualFqName = FqName("kotlinx.serialization.ContextualSerialization") // this one is deprecated
|
||||
internal val contextualOnFileFqName = FqName("kotlinx.serialization.UseContextualSerialization")
|
||||
internal val contextualOnPropertyFqName = FqName("kotlinx.serialization.Contextual")
|
||||
internal val polymorphicFqName = FqName("kotlinx.serialization.Polymorphic")
|
||||
internal val additionalSerializersFqName = FqName("kotlinx.serialization.UseSerializers")
|
||||
val contextualFqName = FqName("kotlinx.serialization.ContextualSerialization") // this one is deprecated
|
||||
val contextualOnFileFqName = FqName("kotlinx.serialization.UseContextualSerialization")
|
||||
val contextualOnPropertyFqName = FqName("kotlinx.serialization.Contextual")
|
||||
val polymorphicFqName = FqName("kotlinx.serialization.Polymorphic")
|
||||
val additionalSerializersFqName = FqName("kotlinx.serialization.UseSerializers")
|
||||
}
|
||||
|
||||
object SerialEntityNames {
|
||||
@@ -109,10 +109,10 @@ object SerialEntityNames {
|
||||
|
||||
// parameters
|
||||
val dummyParamName = Name.identifier("serializationConstructorMarker")
|
||||
internal const val typeArgPrefix = "typeSerial"
|
||||
const val typeArgPrefix = "typeSerial"
|
||||
|
||||
internal val wrapIntoNullableExt = SerializationPackages.builtinsPackageFqName.child(Name.identifier("nullable"))
|
||||
internal val wrapIntoNullableCallableId = CallableId(SerializationPackages.builtinsPackageFqName, Name.identifier("nullable"))
|
||||
val wrapIntoNullableExt = SerializationPackages.builtinsPackageFqName.child(Name.identifier("nullable"))
|
||||
val wrapIntoNullableCallableId = CallableId(SerializationPackages.builtinsPackageFqName, Name.identifier("nullable"))
|
||||
}
|
||||
|
||||
object SpecialBuiltins {
|
||||
@@ -146,7 +146,7 @@ object CallingConventions {
|
||||
const val addClassAnnotation = "pushClassAnnotation"
|
||||
}
|
||||
|
||||
internal object SerializationDependencies {
|
||||
object SerializationDependencies {
|
||||
val LAZY_FQ = FqName("kotlin.Lazy")
|
||||
val LAZY_FUNC_FQ = FqName("kotlin.lazy")
|
||||
val LAZY_MODE_FQ = FqName("kotlin.LazyThreadSafetyMode")
|
||||
@@ -0,0 +1,28 @@
|
||||
description = "Kotlin Serialization Compiler Plugin (K1)"
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("jps-compatible")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":core:compiler.common.jvm"))
|
||||
compileOnly(project(":compiler:frontend"))
|
||||
compileOnly(project(":js:js.frontend"))
|
||||
compileOnly(project(":compiler:cli-common"))
|
||||
compileOnly(project(":compiler:ir.backend.common")) // needed for CompilationException
|
||||
compileOnly(project(":core:deserialization.common.jvm")) // needed for CompilationException
|
||||
|
||||
implementation(project(":kotlinx-serialization-compiler-plugin.common"))
|
||||
|
||||
compileOnly(intellijCore())
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
"main" { projectDefault() }
|
||||
"test" { none() }
|
||||
}
|
||||
|
||||
runtimeJar()
|
||||
sourcesJar()
|
||||
javadocJar()
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2010-2022 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 org.jetbrains.kotlinx.serialization.compiler.backend.common
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.CodegenUtil
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlinx.serialization.compiler.resolve.*
|
||||
|
||||
object SerializationDescriptorUtils {
|
||||
fun getSyntheticLoadMember(serializerDescriptor: ClassDescriptor): FunctionDescriptor? = CodegenUtil.getMemberToGenerate(
|
||||
serializerDescriptor, SerialEntityNames.LOAD,
|
||||
serializerDescriptor::checkLoadMethodResult, serializerDescriptor::checkLoadMethodParameters
|
||||
)
|
||||
|
||||
fun getSyntheticSaveMember(serializerDescriptor: ClassDescriptor): FunctionDescriptor? = CodegenUtil.getMemberToGenerate(
|
||||
serializerDescriptor, SerialEntityNames.SAVE,
|
||||
serializerDescriptor::checkSaveMethodResult, serializerDescriptor::checkSaveMethodParameters
|
||||
)
|
||||
}
|
||||
+6
-6
@@ -1,13 +1,13 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2022 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 org.jetbrains.kotlinx.serialization.compiler.backend.common
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.backend.common.CompilationException
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.codegen.CompilationException
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.js.descriptorUtils.getJetTypeFqName
|
||||
@@ -101,7 +101,7 @@ fun ClassDescriptor.serialName(): String {
|
||||
return annotations.serialNameValue ?: fqNameUnsafe.asString()
|
||||
}
|
||||
|
||||
internal val ClassDescriptor.isStaticSerializable: Boolean get() = this.declaredTypeParameters.isEmpty()
|
||||
val ClassDescriptor.isStaticSerializable: Boolean get() = this.declaredTypeParameters.isEmpty()
|
||||
|
||||
/**
|
||||
* Returns class descriptor for ContextSerializer or PolymorphicSerializer
|
||||
@@ -244,7 +244,7 @@ fun findEnumTypeSerializer(module: ModuleDescriptor, kType: KotlinType): ClassDe
|
||||
else null
|
||||
}
|
||||
|
||||
internal fun KtPureClassOrObject.bodyPropertiesDescriptorsMap(
|
||||
fun KtPureClassOrObject.bodyPropertiesDescriptorsMap(
|
||||
bindingContext: BindingContext,
|
||||
filterUninitialized: Boolean = true
|
||||
): Map<PropertyDescriptor, KtProperty> = declarations
|
||||
@@ -254,13 +254,13 @@ internal fun KtPureClassOrObject.bodyPropertiesDescriptorsMap(
|
||||
.filter { if (filterUninitialized) it.delegateExpressionOrInitializer != null else true }
|
||||
.associateBy { (bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, it] as? PropertyDescriptor)!! }
|
||||
|
||||
internal fun KtPureClassOrObject.primaryConstructorPropertiesDescriptorsMap(bindingContext: BindingContext): Map<PropertyDescriptor, KtParameter> =
|
||||
fun KtPureClassOrObject.primaryConstructorPropertiesDescriptorsMap(bindingContext: BindingContext): Map<PropertyDescriptor, KtParameter> =
|
||||
primaryConstructorParameters
|
||||
.asSequence()
|
||||
.filter { it.hasValOrVar() }
|
||||
.associateBy { bindingContext[BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, it]!! }
|
||||
|
||||
internal fun KtPureClassOrObject.anonymousInitializers() = declarations
|
||||
fun KtPureClassOrObject.anonymousInitializers() = declarations
|
||||
.asSequence()
|
||||
.filterIsInstance<KtAnonymousInitializer>()
|
||||
.mapNotNull { it.body }
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright 2010-2022 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 org.jetbrains.kotlinx.serialization.compiler.backend.jvm
|
||||
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlinx.serialization.compiler.resolve.SerializationPackages
|
||||
import org.jetbrains.kotlinx.serialization.compiler.resolve.SpecialBuiltins
|
||||
|
||||
val enumSerializerId = ClassId(SerializationPackages.internalPackageFqName, Name.identifier(SpecialBuiltins.enumSerializer))
|
||||
val polymorphicSerializerId = ClassId(SerializationPackages.packageFqName, Name.identifier(SpecialBuiltins.polymorphicSerializer))
|
||||
val referenceArraySerializerId = ClassId(SerializationPackages.internalPackageFqName, Name.identifier(SpecialBuiltins.referenceArraySerializer))
|
||||
val objectSerializerId = ClassId(SerializationPackages.internalPackageFqName, Name.identifier(SpecialBuiltins.objectSerializer))
|
||||
val sealedSerializerId = ClassId(SerializationPackages.packageFqName, Name.identifier(SpecialBuiltins.sealedSerializer))
|
||||
val contextSerializerId = ClassId(SerializationPackages.packageFqName, Name.identifier(SpecialBuiltins.contextSerializer))
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2022 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.
|
||||
*/
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2022 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.
|
||||
*/
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.jetbrains.kotlinx.serialization.compiler.backend.common.bodyPropertie
|
||||
import org.jetbrains.kotlinx.serialization.compiler.backend.common.primaryConstructorPropertiesDescriptorsMap
|
||||
import org.jetbrains.kotlinx.serialization.compiler.resolve.*
|
||||
|
||||
internal val SERIALIZABLE_PROPERTIES: WritableSlice<ClassDescriptor, SerializableProperties> = Slices.createSimpleSlice()
|
||||
val SERIALIZABLE_PROPERTIES: WritableSlice<ClassDescriptor, SerializableProperties> = Slices.createSimpleSlice()
|
||||
|
||||
open class SerializationPluginDeclarationChecker : DeclarationChecker {
|
||||
private var useLegacyEnumSerializerCached: Boolean? = null
|
||||
@@ -476,5 +476,5 @@ open class SerializationPluginDeclarationChecker : DeclarationChecker {
|
||||
}
|
||||
}
|
||||
|
||||
internal val ClassDescriptor.serializableAnnotationIsUseless: Boolean
|
||||
val ClassDescriptor.serializableAnnotationIsUseless: Boolean
|
||||
get() = hasSerializableOrMetaAnnotationWithoutArgs && !isInternalSerializable && !hasCompanionObjectAsSerializer && kind != ClassKind.ENUM_CLASS && !isSealedSerializableInterface
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2022 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.
|
||||
*/
|
||||
|
||||
@@ -19,7 +19,7 @@ import org.jetbrains.kotlin.resolve.isInlineClass
|
||||
import org.jetbrains.kotlin.resolve.lazy.LazyClassContext
|
||||
import org.jetbrains.kotlin.resolve.lazy.declarations.ClassMemberDeclarationProvider
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlinx.serialization.compiler.backend.common.SerializerCodegen
|
||||
import org.jetbrains.kotlinx.serialization.compiler.backend.common.SerializationDescriptorUtils
|
||||
import org.jetbrains.kotlinx.serialization.compiler.resolve.*
|
||||
|
||||
open class SerializationResolveExtension @JvmOverloads constructor(val metadataPlugin: SerializationDescriptorSerializerPlugin? = null) : SyntheticResolveExtension {
|
||||
@@ -100,7 +100,7 @@ open class SerializationResolveExtension @JvmOverloads constructor(val metadataP
|
||||
) {
|
||||
if (thisDescriptor.isInternalSerializable) {
|
||||
// do not add synthetic deserialization constructor if .deserialize method is customized
|
||||
if (thisDescriptor.hasCompanionObjectAsSerializer && SerializerCodegen.getSyntheticLoadMember(thisDescriptor.companionObjectDescriptor!!) == null) return
|
||||
if (thisDescriptor.hasCompanionObjectAsSerializer && SerializationDescriptorUtils.getSyntheticLoadMember(thisDescriptor.companionObjectDescriptor!!) == null) return
|
||||
if (thisDescriptor.isInlineClass()) return
|
||||
result.add(KSerializerDescriptorResolver.createLoadConstructorDescriptor(thisDescriptor, bindingContext, metadataPlugin))
|
||||
}
|
||||
@@ -128,4 +128,4 @@ open class SerializationResolveExtension @JvmOverloads constructor(val metadataP
|
||||
KSerializerDescriptorResolver.generateDescriptorsForAnnotationImpl(thisDescriptor, fromSupertypes, result)
|
||||
KSerializerDescriptorResolver.generateSerializerProperties(thisDescriptor, fromSupertypes, name, result)
|
||||
}
|
||||
}
|
||||
}
|
||||
+49
-49
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2022 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.
|
||||
*/
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.jetbrains.kotlinx.serialization.compiler.resolve.SerializationAnnotat
|
||||
import org.jetbrains.kotlinx.serialization.compiler.resolve.SerializationAnnotations.serialInfoFqName
|
||||
import org.jetbrains.kotlinx.serialization.compiler.resolve.SerializationAnnotations.serializableAnnotationFqName
|
||||
|
||||
internal fun isAllowedToHaveAutoGeneratedSerializerMethods(
|
||||
fun isAllowedToHaveAutoGeneratedSerializerMethods(
|
||||
classDescriptor: ClassDescriptor,
|
||||
serializableClassDescriptor: ClassDescriptor
|
||||
): Boolean {
|
||||
@@ -43,16 +43,16 @@ internal fun isAllowedToHaveAutoGeneratedSerializerMethods(
|
||||
(classDescriptor.typeConstructor.supertypes.any(::isKSerializer) && classDescriptor.declaredTypeParameters.isEmpty())
|
||||
}
|
||||
|
||||
internal fun isKSerializer(type: KotlinType?): Boolean =
|
||||
fun isKSerializer(type: KotlinType?): Boolean =
|
||||
type != null && KotlinBuiltIns.isConstructedFromGivenClass(type, SerialEntityNames.KSERIALIZER_NAME_FQ)
|
||||
|
||||
internal fun isGeneratedKSerializer(type: KotlinType?): Boolean =
|
||||
fun isGeneratedKSerializer(type: KotlinType?): Boolean =
|
||||
type != null && KotlinBuiltIns.isConstructedFromGivenClass(type, SerialEntityNames.GENERATED_SERIALIZER_FQ)
|
||||
|
||||
internal fun ClassDescriptor.getGeneratedSerializerDescriptor(): ClassDescriptor =
|
||||
fun ClassDescriptor.getGeneratedSerializerDescriptor(): ClassDescriptor =
|
||||
module.getClassFromInternalSerializationPackage(SerialEntityNames.GENERATED_SERIALIZER_CLASS.identifier)
|
||||
|
||||
internal fun ClassDescriptor.createSerializerTypeFor(argument: SimpleType, baseSerializerInterface: FqName): SimpleType {
|
||||
fun ClassDescriptor.createSerializerTypeFor(argument: SimpleType, baseSerializerInterface: FqName): SimpleType {
|
||||
val projectionType = Variance.INVARIANT
|
||||
val types = listOf(TypeProjectionImpl(projectionType, argument))
|
||||
val descriptor = module.findClassAcrossModuleDependencies(ClassId.topLevel(baseSerializerInterface))
|
||||
@@ -60,7 +60,7 @@ internal fun ClassDescriptor.createSerializerTypeFor(argument: SimpleType, baseS
|
||||
return KotlinTypeFactory.simpleNotNullType(TypeAttributes.Empty, descriptor, types)
|
||||
}
|
||||
|
||||
internal fun extractKSerializerArgumentFromImplementation(implementationClass: ClassDescriptor): KotlinType? {
|
||||
fun extractKSerializerArgumentFromImplementation(implementationClass: ClassDescriptor): KotlinType? {
|
||||
val supertypes = implementationClass.typeConstructor.supertypes
|
||||
val kSerializerSupertype = supertypes.find { isGeneratedKSerializer(it) }
|
||||
?: supertypes.find { isKSerializer(it) }
|
||||
@@ -68,33 +68,33 @@ internal fun extractKSerializerArgumentFromImplementation(implementationClass: C
|
||||
return kSerializerSupertype.arguments.first().type
|
||||
}
|
||||
|
||||
internal val DeclarationDescriptor.serializableWith: KotlinType?
|
||||
val DeclarationDescriptor.serializableWith: KotlinType?
|
||||
get() = annotations.serializableWith(module)
|
||||
|
||||
internal fun Annotations.serializableWith(module: ModuleDescriptor): KotlinType? =
|
||||
fun Annotations.serializableWith(module: ModuleDescriptor): KotlinType? =
|
||||
this.findAnnotationKotlinTypeValue(serializableAnnotationFqName, module, "with")
|
||||
|
||||
internal val DeclarationDescriptor.serializerForClass: KotlinType?
|
||||
val DeclarationDescriptor.serializerForClass: KotlinType?
|
||||
get() = annotations.findAnnotationKotlinTypeValue(SerializationAnnotations.serializerAnnotationFqName, module, "forClass")
|
||||
|
||||
internal val ClassDescriptor.isSerialInfoAnnotation: Boolean
|
||||
val ClassDescriptor.isSerialInfoAnnotation: Boolean
|
||||
get() = annotations.hasAnnotation(serialInfoFqName)
|
||||
|| annotations.hasAnnotation(inheritableSerialInfoFqName)
|
||||
|| annotations.hasAnnotation(metaSerializableAnnotationFqName)
|
||||
|
||||
internal val ClassDescriptor.isInheritableSerialInfoAnnotation: Boolean
|
||||
val ClassDescriptor.isInheritableSerialInfoAnnotation: Boolean
|
||||
get() = annotations.hasAnnotation(inheritableSerialInfoFqName)
|
||||
|
||||
internal val Annotations.serialNameValue: String?
|
||||
val Annotations.serialNameValue: String?
|
||||
get() = findAnnotationConstantValue(SerializationAnnotations.serialNameAnnotationFqName, "value")
|
||||
|
||||
internal val Annotations.serialNameAnnotation: AnnotationDescriptor?
|
||||
val Annotations.serialNameAnnotation: AnnotationDescriptor?
|
||||
get() = findAnnotation(SerializationAnnotations.serialNameAnnotationFqName)
|
||||
|
||||
internal val Annotations.serialRequired: Boolean
|
||||
val Annotations.serialRequired: Boolean
|
||||
get() = hasAnnotation(SerializationAnnotations.requiredAnnotationFqName)
|
||||
|
||||
internal val Annotations.serialTransient: Boolean
|
||||
val Annotations.serialTransient: Boolean
|
||||
get() = hasAnnotation(SerializationAnnotations.serialTransientFqName)
|
||||
|
||||
// ----------------------------------------
|
||||
@@ -109,42 +109,42 @@ val KotlinType?.toClassDescriptor: ClassDescriptor?
|
||||
}
|
||||
}
|
||||
|
||||
internal val ClassDescriptor.shouldHaveGeneratedMethodsInCompanion: Boolean
|
||||
val ClassDescriptor.shouldHaveGeneratedMethodsInCompanion: Boolean
|
||||
get() = this.isSerializableObject || this.isSerializableEnum() || (this.kind == ClassKind.CLASS && hasSerializableOrMetaAnnotation) || this.isSealedSerializableInterface
|
||||
|
||||
internal val ClassDescriptor.isSerializableObject: Boolean
|
||||
val ClassDescriptor.isSerializableObject: Boolean
|
||||
get() = kind == ClassKind.OBJECT && hasSerializableOrMetaAnnotation
|
||||
|
||||
internal val ClassDescriptor.isInternallySerializableObject: Boolean
|
||||
val ClassDescriptor.isInternallySerializableObject: Boolean
|
||||
get() = kind == ClassKind.OBJECT && hasSerializableOrMetaAnnotationWithoutArgs
|
||||
|
||||
internal val ClassDescriptor.isSealedSerializableInterface: Boolean
|
||||
val ClassDescriptor.isSealedSerializableInterface: Boolean
|
||||
get() = kind == ClassKind.INTERFACE && modality == Modality.SEALED && hasSerializableOrMetaAnnotation
|
||||
|
||||
internal val ClassDescriptor.isInternalSerializable: Boolean //todo normal checking
|
||||
val ClassDescriptor.isInternalSerializable: Boolean //todo normal checking
|
||||
get() {
|
||||
if (kind != ClassKind.CLASS) return false
|
||||
return hasSerializableOrMetaAnnotationWithoutArgs
|
||||
}
|
||||
|
||||
internal fun ClassDescriptor.isSerializableEnum(): Boolean = kind == ClassKind.ENUM_CLASS && hasSerializableOrMetaAnnotation
|
||||
fun ClassDescriptor.isSerializableEnum(): Boolean = kind == ClassKind.ENUM_CLASS && hasSerializableOrMetaAnnotation
|
||||
|
||||
internal fun ClassDescriptor.isEnumWithLegacyGeneratedSerializer(): Boolean = isInternallySerializableEnum() && useGeneratedEnumSerializer
|
||||
fun ClassDescriptor.isEnumWithLegacyGeneratedSerializer(): Boolean = isInternallySerializableEnum() && useGeneratedEnumSerializer
|
||||
|
||||
internal fun ClassDescriptor.isInternallySerializableEnum(): Boolean =
|
||||
fun ClassDescriptor.isInternallySerializableEnum(): Boolean =
|
||||
kind == ClassKind.ENUM_CLASS && hasSerializableOrMetaAnnotationWithoutArgs
|
||||
|
||||
internal val ClassDescriptor.shouldHaveGeneratedSerializer: Boolean
|
||||
val ClassDescriptor.shouldHaveGeneratedSerializer: Boolean
|
||||
get() = (isInternalSerializable && (modality == Modality.FINAL || modality == Modality.OPEN))
|
||||
|| isEnumWithLegacyGeneratedSerializer()
|
||||
|
||||
internal val ClassDescriptor.useGeneratedEnumSerializer: Boolean
|
||||
val ClassDescriptor.useGeneratedEnumSerializer: Boolean
|
||||
get() {
|
||||
val functions = module.getPackage(SerializationPackages.internalPackageFqName).memberScope.getFunctionNames()
|
||||
return !functions.contains(ENUM_SERIALIZER_FACTORY_FUNC_NAME) || !functions.contains(MARKED_ENUM_SERIALIZER_FACTORY_FUNC_NAME)
|
||||
}
|
||||
|
||||
internal fun ClassDescriptor.enumEntries(): List<ClassDescriptor> {
|
||||
fun ClassDescriptor.enumEntries(): List<ClassDescriptor> {
|
||||
check(this.kind == ClassKind.ENUM_CLASS)
|
||||
return unsubstitutedMemberScope.getContributedDescriptors().asSequence()
|
||||
.filterIsInstance<ClassDescriptor>()
|
||||
@@ -153,16 +153,16 @@ internal fun ClassDescriptor.enumEntries(): List<ClassDescriptor> {
|
||||
}
|
||||
|
||||
// check enum or its elements has any SerialInfo annotation
|
||||
internal fun ClassDescriptor.isEnumWithSerialInfoAnnotation(): Boolean {
|
||||
fun ClassDescriptor.isEnumWithSerialInfoAnnotation(): Boolean {
|
||||
if (kind != ClassKind.ENUM_CLASS) return false
|
||||
if (annotations.hasAnySerialAnnotation) return true
|
||||
return enumEntries().any { (it.annotations.hasAnySerialAnnotation) }
|
||||
}
|
||||
|
||||
internal val Annotations.hasAnySerialAnnotation: Boolean
|
||||
val Annotations.hasAnySerialAnnotation: Boolean
|
||||
get() = serialNameValue != null || any { it.annotationClass?.isSerialInfoAnnotation == true }
|
||||
|
||||
internal val ClassDescriptor.hasSerializableOrMetaAnnotation
|
||||
val ClassDescriptor.hasSerializableOrMetaAnnotation
|
||||
get() = hasSerializableAnnotation || hasMetaSerializableAnnotation
|
||||
|
||||
private val ClassDescriptor.hasSerializableAnnotation
|
||||
@@ -171,13 +171,13 @@ private val ClassDescriptor.hasSerializableAnnotation
|
||||
private val Annotations.hasSerializableAnnotation
|
||||
get() = hasAnnotation(serializableAnnotationFqName)
|
||||
|
||||
internal val ClassDescriptor.hasMetaSerializableAnnotation: Boolean
|
||||
val ClassDescriptor.hasMetaSerializableAnnotation: Boolean
|
||||
get() = annotations.any { it.isMetaSerializableAnnotation }
|
||||
|
||||
internal val AnnotationDescriptor.isMetaSerializableAnnotation: Boolean
|
||||
val AnnotationDescriptor.isMetaSerializableAnnotation: Boolean
|
||||
get() = annotationClass?.annotations?.hasAnnotation(metaSerializableAnnotationFqName) ?: false
|
||||
|
||||
internal val ClassDescriptor.hasSerializableOrMetaAnnotationWithoutArgs: Boolean
|
||||
val ClassDescriptor.hasSerializableOrMetaAnnotationWithoutArgs: Boolean
|
||||
get() = hasSerializableAnnotationWithoutArgs
|
||||
|| (!annotations.hasSerializableAnnotation && hasMetaSerializableAnnotation)
|
||||
|
||||
@@ -195,13 +195,13 @@ private fun Annotated.findSerializableAnnotationDeclaration(): KtAnnotationEntry
|
||||
return lazyDesc?.annotationEntry
|
||||
}
|
||||
|
||||
internal fun Annotated.findSerializableOrMetaAnnotationDeclaration(): KtAnnotationEntry? {
|
||||
fun Annotated.findSerializableOrMetaAnnotationDeclaration(): KtAnnotationEntry? {
|
||||
val lazyDesc = (annotations.findAnnotation(serializableAnnotationFqName)
|
||||
?: annotations.firstOrNull { it.isMetaSerializableAnnotation }) as? LazyAnnotationDescriptor
|
||||
return lazyDesc?.annotationEntry
|
||||
}
|
||||
|
||||
internal fun Annotated.findAnnotationDeclaration(fqName: FqName): KtAnnotationEntry? {
|
||||
fun Annotated.findAnnotationDeclaration(fqName: FqName): KtAnnotationEntry? {
|
||||
val lazyDesc = annotations.findAnnotation(fqName) as? LazyAnnotationDescriptor
|
||||
return lazyDesc?.annotationEntry
|
||||
}
|
||||
@@ -209,10 +209,10 @@ internal fun Annotated.findAnnotationDeclaration(fqName: FqName): KtAnnotationEn
|
||||
// For abstract classes marked with @Serializable,
|
||||
// methods are generated anyway, although they shouldn't have
|
||||
// generated $serializer and use Polymorphic one.
|
||||
internal fun ClassDescriptor.isAbstractOrSealedSerializableClass(): Boolean =
|
||||
fun ClassDescriptor.isAbstractOrSealedSerializableClass(): Boolean =
|
||||
isInternalSerializable && (modality == Modality.ABSTRACT || modality == Modality.SEALED)
|
||||
|
||||
internal fun ClassDescriptor.polymorphicSerializerIfApplicableAutomatically(): ClassDescriptor? {
|
||||
fun ClassDescriptor.polymorphicSerializerIfApplicableAutomatically(): ClassDescriptor? {
|
||||
val serializer = when {
|
||||
kind == ClassKind.INTERFACE && modality == Modality.SEALED -> SpecialBuiltins.sealedSerializer
|
||||
kind == ClassKind.INTERFACE -> SpecialBuiltins.polymorphicSerializer
|
||||
@@ -224,7 +224,7 @@ internal fun ClassDescriptor.polymorphicSerializerIfApplicableAutomatically(): C
|
||||
}
|
||||
|
||||
// serializer that was declared for this type
|
||||
internal val ClassDescriptor?.classSerializer: ClassDescriptor?
|
||||
val ClassDescriptor?.classSerializer: ClassDescriptor?
|
||||
get() = this?.let {
|
||||
// serializer annotation on class?
|
||||
serializableWith?.let { return it.toClassDescriptor }
|
||||
@@ -242,21 +242,21 @@ internal val ClassDescriptor?.classSerializer: ClassDescriptor?
|
||||
return null
|
||||
}
|
||||
|
||||
internal val ClassDescriptor.hasCompanionObjectAsSerializer: Boolean
|
||||
val ClassDescriptor.hasCompanionObjectAsSerializer: Boolean
|
||||
get() = isInternallySerializableObject || companionObjectDescriptor?.serializerForClass == this.defaultType
|
||||
|
||||
// returns only user-overriden Serializer
|
||||
internal val KotlinType.overridenSerializer: KotlinType?
|
||||
val KotlinType.overridenSerializer: KotlinType?
|
||||
get() {
|
||||
val desc = this.toClassDescriptor ?: return null
|
||||
desc.serializableWith?.let { return it }
|
||||
return null
|
||||
}
|
||||
|
||||
internal val KotlinType.genericIndex: Int?
|
||||
val KotlinType.genericIndex: Int?
|
||||
get() = (this.constructor.declarationDescriptor as? TypeParameterDescriptor)?.index
|
||||
|
||||
internal fun getSerializableClassDescriptorByCompanion(thisDescriptor: ClassDescriptor): ClassDescriptor? {
|
||||
fun getSerializableClassDescriptorByCompanion(thisDescriptor: ClassDescriptor): ClassDescriptor? {
|
||||
if (thisDescriptor.isSerializableObject) return thisDescriptor
|
||||
if (!thisDescriptor.isCompanionObject) return null
|
||||
val classDescriptor = (thisDescriptor.containingDeclaration as? ClassDescriptor) ?: return null
|
||||
@@ -264,7 +264,7 @@ internal fun getSerializableClassDescriptorByCompanion(thisDescriptor: ClassDesc
|
||||
return classDescriptor
|
||||
}
|
||||
|
||||
internal fun ClassDescriptor.needSerializerFactory(): Boolean {
|
||||
fun ClassDescriptor.needSerializerFactory(): Boolean {
|
||||
if (!(this.platform?.isNative() == true || this.platform.isJs())) return false
|
||||
val serializableClass = getSerializableClassDescriptorByCompanion(this) ?: return false
|
||||
if (serializableClass.isSerializableObject) return true
|
||||
@@ -275,7 +275,7 @@ internal fun ClassDescriptor.needSerializerFactory(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
internal fun getSerializableClassDescriptorBySerializer(serializerDescriptor: ClassDescriptor): ClassDescriptor? {
|
||||
fun getSerializableClassDescriptorBySerializer(serializerDescriptor: ClassDescriptor): ClassDescriptor? {
|
||||
val serializerForClass = serializerDescriptor.serializerForClass
|
||||
if (serializerForClass != null) return serializerForClass.toClassDescriptor
|
||||
if (serializerDescriptor.name !in setOf(
|
||||
@@ -288,19 +288,19 @@ internal fun getSerializableClassDescriptorBySerializer(serializerDescriptor: Cl
|
||||
return classDescriptor
|
||||
}
|
||||
|
||||
internal fun ClassDescriptor.checkSerializableClassPropertyResult(prop: PropertyDescriptor): Boolean =
|
||||
fun ClassDescriptor.checkSerializableClassPropertyResult(prop: PropertyDescriptor): Boolean =
|
||||
prop.returnType!!.isSubtypeOf(getClassFromSerializationPackage(SerialEntityNames.SERIAL_DESCRIPTOR_CLASS).toSimpleType(false)) // todo: cache lookup
|
||||
|
||||
// todo: serialization: do an actual check better that just number of parameters
|
||||
internal fun ClassDescriptor.checkSaveMethodParameters(parameters: List<ValueParameterDescriptor>): Boolean =
|
||||
fun ClassDescriptor.checkSaveMethodParameters(parameters: List<ValueParameterDescriptor>): Boolean =
|
||||
parameters.size == 2
|
||||
|
||||
internal fun ClassDescriptor.checkSaveMethodResult(type: KotlinType): Boolean =
|
||||
fun ClassDescriptor.checkSaveMethodResult(type: KotlinType): Boolean =
|
||||
KotlinBuiltIns.isUnit(type)
|
||||
|
||||
// todo: serialization: do an actual check better that just number of parameters
|
||||
internal fun ClassDescriptor.checkLoadMethodParameters(parameters: List<ValueParameterDescriptor>): Boolean =
|
||||
fun ClassDescriptor.checkLoadMethodParameters(parameters: List<ValueParameterDescriptor>): Boolean =
|
||||
parameters.size == 1
|
||||
|
||||
internal fun ClassDescriptor.checkLoadMethodResult(type: KotlinType): Boolean =
|
||||
fun ClassDescriptor.checkLoadMethodResult(type: KotlinType): Boolean =
|
||||
getSerializableClassDescriptorBySerializer(this)?.defaultType == type
|
||||
+14
-14
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2022 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.
|
||||
*/
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.KotlinTypeFactory
|
||||
import org.jetbrains.kotlin.types.TypeAttributes
|
||||
|
||||
internal fun ClassConstructorDescriptor.isSerializationCtor(): Boolean {
|
||||
fun ClassConstructorDescriptor.isSerializationCtor(): Boolean {
|
||||
/*kind == CallableMemberDescriptor.Kind.SYNTHESIZED does not work because DeserializedClassConstructorDescriptor loses its kind*/
|
||||
return valueParameters.lastOrNull()?.run {
|
||||
name == SerialEntityNames.dummyParamName && type.constructor.declarationDescriptor?.classId == ClassId(
|
||||
@@ -33,7 +33,7 @@ internal fun ClassConstructorDescriptor.isSerializationCtor(): Boolean {
|
||||
}
|
||||
|
||||
// finds constructor (KSerializer<T0>, KSerializer<T1>...) on a KSerializer<T<T0, T1...>>
|
||||
internal fun findSerializerConstructorForTypeArgumentsSerializers(
|
||||
fun findSerializerConstructorForTypeArgumentsSerializers(
|
||||
serializerDescriptor: ClassDescriptor,
|
||||
onlyIfSynthetic: Boolean = false
|
||||
): ClassConstructorDescriptor? {
|
||||
@@ -56,7 +56,7 @@ inline fun <reified R> Annotations.findAnnotationConstantValue(annotationFqName:
|
||||
inline fun <reified R> AnnotationDescriptor.findConstantValue(property: String): R? =
|
||||
allValueArguments.entries.singleOrNull { it.key.asString() == property }?.value?.value as? R
|
||||
|
||||
internal fun Annotations.findAnnotationKotlinTypeValue(
|
||||
fun Annotations.findAnnotationKotlinTypeValue(
|
||||
annotationFqName: FqName,
|
||||
moduleForResolve: ModuleDescriptor,
|
||||
property: String
|
||||
@@ -66,7 +66,7 @@ internal fun Annotations.findAnnotationKotlinTypeValue(
|
||||
maybeKClass?.getArgumentType(moduleForResolve)
|
||||
}
|
||||
|
||||
internal fun ClassDescriptor.getKSerializerConstructorMarker(): ClassDescriptor =
|
||||
fun ClassDescriptor.getKSerializerConstructorMarker(): ClassDescriptor =
|
||||
module.findClassAcrossModuleDependencies(
|
||||
ClassId(
|
||||
SerializationPackages.internalPackageFqName,
|
||||
@@ -74,7 +74,7 @@ internal fun ClassDescriptor.getKSerializerConstructorMarker(): ClassDescriptor
|
||||
)
|
||||
)!!
|
||||
|
||||
internal fun ClassDescriptor.getKSerializer(): ClassDescriptor =
|
||||
fun ClassDescriptor.getKSerializer(): ClassDescriptor =
|
||||
module.findClassAcrossModuleDependencies(
|
||||
ClassId(
|
||||
SerializationPackages.packageFqName,
|
||||
@@ -82,10 +82,10 @@ internal fun ClassDescriptor.getKSerializer(): ClassDescriptor =
|
||||
)
|
||||
)!!
|
||||
|
||||
internal fun getInternalPackageFqn(classSimpleName: String): FqName =
|
||||
fun getInternalPackageFqn(classSimpleName: String): FqName =
|
||||
SerializationPackages.internalPackageFqName.child(Name.identifier(classSimpleName))
|
||||
|
||||
internal fun ModuleDescriptor.getClassFromInternalSerializationPackage(classSimpleName: String) =
|
||||
fun ModuleDescriptor.getClassFromInternalSerializationPackage(classSimpleName: String) =
|
||||
requireNotNull(
|
||||
findClassAcrossModuleDependencies(
|
||||
ClassId(
|
||||
@@ -95,7 +95,7 @@ internal fun ModuleDescriptor.getClassFromInternalSerializationPackage(classSimp
|
||||
)
|
||||
) { "Can't locate class $classSimpleName from package ${SerializationPackages.internalPackageFqName}" }
|
||||
|
||||
internal fun ModuleDescriptor.getClassFromSerializationDescriptorsPackage(classSimpleName: String) =
|
||||
fun ModuleDescriptor.getClassFromSerializationDescriptorsPackage(classSimpleName: String) =
|
||||
requireNotNull(
|
||||
findClassAcrossModuleDependencies(
|
||||
ClassId(
|
||||
@@ -105,10 +105,10 @@ internal fun ModuleDescriptor.getClassFromSerializationDescriptorsPackage(classS
|
||||
)
|
||||
) { "Can't locate class $classSimpleName from package ${SerializationPackages.descriptorsPackageFqName}" }
|
||||
|
||||
internal fun getSerializationPackageFqn(classSimpleName: String): FqName =
|
||||
fun getSerializationPackageFqn(classSimpleName: String): FqName =
|
||||
SerializationPackages.packageFqName.child(Name.identifier(classSimpleName))
|
||||
|
||||
internal fun ModuleDescriptor.getClassFromSerializationPackage(classSimpleName: String) =
|
||||
fun ModuleDescriptor.getClassFromSerializationPackage(classSimpleName: String) =
|
||||
SerializationPackages.allPublicPackages.firstNotNullOfOrNull { pkg ->
|
||||
module.findClassAcrossModuleDependencies(ClassId(
|
||||
pkg,
|
||||
@@ -116,16 +116,16 @@ internal fun ModuleDescriptor.getClassFromSerializationPackage(classSimpleName:
|
||||
))
|
||||
} ?: throw IllegalArgumentException("Can't locate class $classSimpleName")
|
||||
|
||||
internal fun ClassDescriptor.getClassFromSerializationPackage(classSimpleName: String) =
|
||||
fun ClassDescriptor.getClassFromSerializationPackage(classSimpleName: String) =
|
||||
module.getClassFromSerializationPackage(classSimpleName)
|
||||
|
||||
internal fun ClassDescriptor.getClassFromInternalSerializationPackage(classSimpleName: String) =
|
||||
fun ClassDescriptor.getClassFromInternalSerializationPackage(classSimpleName: String) =
|
||||
module.getClassFromInternalSerializationPackage(classSimpleName)
|
||||
|
||||
fun ClassDescriptor.toSimpleType(nullable: Boolean = false) =
|
||||
KotlinTypeFactory.simpleType(TypeAttributes.Empty, this.typeConstructor, emptyList(), nullable)
|
||||
|
||||
internal fun Annotated.annotationsWithArguments(): List<Triple<ClassDescriptor, List<ValueArgument>, List<ValueParameterDescriptor>>> =
|
||||
fun Annotated.annotationsWithArguments(): List<Triple<ClassDescriptor, List<ValueArgument>, List<ValueParameterDescriptor>>> =
|
||||
annotations.asSequence()
|
||||
.filter { it.type.toClassDescriptor?.isSerialInfoAnnotation == true }
|
||||
.filterIsInstance<LazyAnnotationDescriptor>()
|
||||
+8
-8
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2022 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.
|
||||
*/
|
||||
|
||||
@@ -120,7 +120,7 @@ fun PropertyDescriptor.declaresDefaultValue(): Boolean {
|
||||
}
|
||||
|
||||
|
||||
internal val ISerializableProperties<*>.goldenMask: Int
|
||||
val ISerializableProperties<*>.goldenMask: Int
|
||||
get() {
|
||||
var goldenMask = 0
|
||||
var requiredBit = 1
|
||||
@@ -133,7 +133,7 @@ internal val ISerializableProperties<*>.goldenMask: Int
|
||||
return goldenMask
|
||||
}
|
||||
|
||||
internal val ISerializableProperties<*>.goldenMaskList: List<Int>
|
||||
val ISerializableProperties<*>.goldenMaskList: List<Int>
|
||||
get() {
|
||||
val maskSlotCount = serializableProperties.bitMaskSlotCount()
|
||||
val goldenMaskList = MutableList(maskSlotCount) { 0 }
|
||||
@@ -148,10 +148,10 @@ internal val ISerializableProperties<*>.goldenMaskList: List<Int>
|
||||
return goldenMaskList
|
||||
}
|
||||
|
||||
internal fun List<ISerializableProperty>.bitMaskSlotCount() = size / 32 + 1
|
||||
internal fun bitMaskSlotAt(propertyIndex: Int) = propertyIndex / 32
|
||||
fun List<ISerializableProperty>.bitMaskSlotCount() = size / 32 + 1
|
||||
fun bitMaskSlotAt(propertyIndex: Int) = propertyIndex / 32
|
||||
|
||||
internal fun BindingContext.serializablePropertiesFor(
|
||||
fun BindingContext.serializablePropertiesFor(
|
||||
classDescriptor: ClassDescriptor,
|
||||
serializationDescriptorSerializer: SerializationDescriptorSerializerPlugin? = null
|
||||
): SerializableProperties {
|
||||
@@ -160,10 +160,10 @@ internal fun BindingContext.serializablePropertiesFor(
|
||||
return props
|
||||
}
|
||||
|
||||
internal fun <P: ISerializableProperty> restoreCorrectOrderFromClassProtoExtension(descriptor: ClassDescriptor, props: List<P>): List<P> {
|
||||
fun <P: ISerializableProperty> restoreCorrectOrderFromClassProtoExtension(descriptor: ClassDescriptor, props: List<P>): List<P> {
|
||||
if (descriptor !is DeserializedClassDescriptor) return props
|
||||
val correctOrder: List<Name> = descriptor.classProto.getExtension(SerializationPluginMetadataExtensions.propertiesNamesInProgramOrder)
|
||||
.map { descriptor.c.nameResolver.getName(it) }
|
||||
val propsMap = props.associateBy { it.originalDescriptorName }
|
||||
return correctOrder.map { propsMap.getValue(it) }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
description = "Kotlin Serialization Compiler Plugin (K2)"
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("jps-compatible")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":compiler:fir:cones"))
|
||||
compileOnly(project(":compiler:fir:tree"))
|
||||
compileOnly(project(":compiler:fir:resolve"))
|
||||
compileOnly(project(":compiler:fir:entrypoint"))
|
||||
|
||||
implementation(project(":kotlinx-serialization-compiler-plugin.common"))
|
||||
|
||||
compileOnly(intellijCore())
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
"main" { projectDefault() }
|
||||
"test" { none() }
|
||||
}
|
||||
|
||||
runtimeJar()
|
||||
sourcesJar()
|
||||
javadocJar()
|
||||
+1
-6
@@ -17,18 +17,13 @@ import org.jetbrains.kotlin.fir.extensions.FirDeclarationGenerationExtension
|
||||
import org.jetbrains.kotlin.fir.moduleData
|
||||
import org.jetbrains.kotlin.fir.resolve.defaultType
|
||||
import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.toConeType
|
||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.SymbolInternals
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.constructClassLikeType
|
||||
import org.jetbrains.kotlin.fir.types.toFirResolvedTypeRef
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
import org.jetbrains.kotlinx.serialization.compiler.resolve.SerialEntityNames
|
||||
|
||||
|
||||
// FIXME KT-53096: this has to be shared (copied from plugin example)
|
||||
@@ -76,4 +71,4 @@ fun newSimpleValueParameter(firSession: FirSession, typeRef: FirResolvedTypeRef,
|
||||
isCrossinline = false
|
||||
isNoinline = false
|
||||
isVararg = false
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -7,9 +7,9 @@ package org.jetbrains.kotlinx.serialization.compiler.fir
|
||||
|
||||
import org.jetbrains.kotlin.fir.extensions.FirExtensionRegistrar
|
||||
|
||||
class FirSerializationExtensionRegistrar: FirExtensionRegistrar() {
|
||||
class FirSerializationExtensionRegistrar : FirExtensionRegistrar() {
|
||||
override fun ExtensionRegistrarContext.configurePlugin() {
|
||||
+::SerializationFirResolveExtension
|
||||
+::SerializationFirSupertypesExtension
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-12
@@ -1,17 +1,15 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2022 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 org.jetbrains.kotlinx.serialization.compiler.fir
|
||||
|
||||
import org.jetbrains.kotlin.GeneratedDeclarationKey
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.EffectiveVisibility
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.getContainingDeclarationSymbol
|
||||
import org.jetbrains.kotlin.fir.copy
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin
|
||||
import org.jetbrains.kotlin.fir.declarations.builder.*
|
||||
@@ -28,7 +26,6 @@ import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider
|
||||
import org.jetbrains.kotlin.fir.scopes.*
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.toConeType
|
||||
import org.jetbrains.kotlin.fir.symbols.SymbolInternals
|
||||
import org.jetbrains.kotlin.fir.symbols.constructStarProjectedType
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
|
||||
@@ -36,16 +33,9 @@ import org.jetbrains.kotlin.name.CallableId
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
import org.jetbrains.kotlinx.serialization.compiler.resolve.SerialEntityNames
|
||||
import org.jetbrains.kotlinx.serialization.compiler.resolve.SerializationPackages
|
||||
|
||||
object SerializationPluginKey : GeneratedDeclarationKey() {
|
||||
override fun toString(): String {
|
||||
return "KotlinxSerializationPlugin"
|
||||
}
|
||||
}
|
||||
|
||||
val generatedSerializerClassId = ClassId(SerializationPackages.internalPackageFqName, SerialEntityNames.GENERATED_SERIALIZER_CLASS)
|
||||
val kSerializerClassId = ClassId(SerializationPackages.packageFqName, SerialEntityNames.KSERIALIZER_NAME)
|
||||
|
||||
@@ -339,4 +329,4 @@ class SerializationFirResolveExtension(session: FirSession) : FirDeclarationGene
|
||||
override fun FirDeclarationPredicateRegistrar.registerPredicates() {
|
||||
register(FirSerializationPredicates.annotatedWithSerializable)
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user