[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$/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/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/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/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/noarg/noarg.cli/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/plugins/sam-with-receiver/sam-with-receiver.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-base/testData" />
|
||||||
<option value="$PROJECT_DIR$/plugins/kapt3/kapt3-cli/testData" />
|
<option value="$PROJECT_DIR$/plugins/kapt3/kapt3-cli/testData" />
|
||||||
<option value="$PROJECT_DIR$/plugins/kapt3/kapt3-compiler/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/noarg/testData" />
|
||||||
<option value="$PROJECT_DIR$/plugins/parcelize/parcelize-compiler/testData" />
|
<option value="$PROJECT_DIR$/plugins/parcelize/parcelize-compiler/testData" />
|
||||||
<option value="$PROJECT_DIR$/plugins/lombok/testData" />
|
<option value="$PROJECT_DIR$/plugins/lombok/testData" />
|
||||||
<option value="$PROJECT_DIR$/plugins/sam-with-receiver/testData" />
|
<option value="$PROJECT_DIR$/plugins/sam-with-receiver/testData" />
|
||||||
|
<option value="$PROJECT_DIR$/plugins/kotlinx-serialization/testData" />
|
||||||
</array>
|
</array>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ val PROTO_PATHS: List<ProtoPath> = listOf(
|
|||||||
ProtoPath("compiler/util-klib-metadata/src/KlibMetadataProtoBuf.proto"),
|
ProtoPath("compiler/util-klib-metadata/src/KlibMetadataProtoBuf.proto"),
|
||||||
ProtoPath("compiler/ir/serialization.common/src/KotlinIr.proto", false),
|
ProtoPath("compiler/ir/serialization.common/src/KotlinIr.proto", false),
|
||||||
ProtoPath("compiler/ir/serialization.jvm/src/JvmIr.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")
|
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") {
|
testGroup("plugins/fir-plugin-prototype/fir-plugin-ic-test/tests-gen", "plugins/fir-plugin-prototype/fir-plugin-ic-test/testData") {
|
||||||
testClass<AbstractIncrementalFirJvmWithPluginCompilerRunnerTest> {
|
testClass<AbstractIncrementalFirJvmWithPluginCompilerRunnerTest> {
|
||||||
model("pureKotlin", extension = null, recursive = false, targetBackend = TargetBackend.JVM_IR)
|
model("pureKotlin", extension = null, recursive = false, targetBackend = TargetBackend.JVM_IR)
|
||||||
|
|||||||
@@ -6,8 +6,12 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<properties>
|
<properties>
|
||||||
<maven.version>3.0.5</maven.version>
|
<maven.version>3.0.5</maven.version>
|
||||||
<serialization.src>${basedir}/../../../plugins/kotlin-serialization/kotlin-serialization-compiler/src/</serialization.src>
|
<serialization.common.src>${basedir}/../../../plugins/kotlinx-serialization/kotlinx-serialization.common/src</serialization.common.src>
|
||||||
<serialization.resources>${basedir}/../../../plugins/kotlin-serialization/kotlin-serialization-compiler/resources/</serialization.resources>
|
<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>
|
<serialization.maven.plugin.src>${basedir}/src/main/kotlin</serialization.maven.plugin.src>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
@@ -53,7 +57,11 @@
|
|||||||
<goals><goal>add-source</goal></goals>
|
<goals><goal>add-source</goal></goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<sources>
|
<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>
|
<source>${serialization.maven.plugin.src}</source>
|
||||||
</sources>
|
</sources>
|
||||||
</configuration>
|
</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() {
|
private fun generateSyntheticInternalConstructor() {
|
||||||
val serializerDescriptor = serializableDescriptor.classSerializer ?: return
|
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
|
val constrDesc = serializableDescriptor.secondaryConstructors.find(ClassConstructorDescriptor::isSerializationCtor) ?: return
|
||||||
generateInternalConstructor(constrDesc)
|
generateInternalConstructor(constrDesc)
|
||||||
}
|
}
|
||||||
@@ -38,7 +38,7 @@ abstract class SerializableCodegen(
|
|||||||
|
|
||||||
private fun generateSyntheticMethods() {
|
private fun generateSyntheticMethods() {
|
||||||
val serializerDescriptor = serializableDescriptor.classSerializer ?: return
|
val serializerDescriptor = serializableDescriptor.classSerializer ?: return
|
||||||
if (serializableDescriptor.shouldHaveSpecificSyntheticMethods { SerializerCodegen.getSyntheticSaveMember(serializerDescriptor) }) {
|
if (serializableDescriptor.shouldHaveSpecificSyntheticMethods { SerializationDescriptorUtils.getSyntheticSaveMember(serializerDescriptor) }) {
|
||||||
val func =
|
val func =
|
||||||
serializableDescriptor.unsubstitutedMemberScope.getContributedFunctions(
|
serializableDescriptor.unsubstitutedMemberScope.getContributedFunctions(
|
||||||
Name.identifier(SerialEntityNames.WRITE_SELF_NAME.toString()),
|
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.ir.declarations.IrProperty
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
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.extensions.SerializationDescriptorSerializerPlugin
|
||||||
import org.jetbrains.kotlinx.serialization.compiler.resolve.*
|
import org.jetbrains.kotlinx.serialization.compiler.resolve.*
|
||||||
|
|
||||||
@@ -143,16 +145,4 @@ abstract class SerializerCodegen(
|
|||||||
property.returnType != null &&
|
property.returnType != null &&
|
||||||
isReturnTypeOk(property)
|
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(
|
internal fun InstructionAdapter.stackValueSerializerInstanceFromClass(
|
||||||
expressionCodegen: ExpressionCodegen,
|
expressionCodegen: ExpressionCodegen,
|
||||||
classCodegen: ClassBodyCodegen,
|
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.
|
* 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
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
object SerializationPackages {
|
object SerializationPackages {
|
||||||
internal val packageFqName = FqName("kotlinx.serialization")
|
val packageFqName = FqName("kotlinx.serialization")
|
||||||
internal val internalPackageFqName = FqName("kotlinx.serialization.internal")
|
val internalPackageFqName = FqName("kotlinx.serialization.internal")
|
||||||
internal val encodingPackageFqName = FqName("kotlinx.serialization.encoding")
|
val encodingPackageFqName = FqName("kotlinx.serialization.encoding")
|
||||||
internal val descriptorsPackageFqName = FqName("kotlinx.serialization.descriptors")
|
val descriptorsPackageFqName = FqName("kotlinx.serialization.descriptors")
|
||||||
internal val builtinsPackageFqName = FqName("kotlinx.serialization.builtins")
|
val builtinsPackageFqName = FqName("kotlinx.serialization.builtins")
|
||||||
|
|
||||||
val allPublicPackages = listOf(packageFqName, encodingPackageFqName, descriptorsPackageFqName, builtinsPackageFqName)
|
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
|
// Otherwise, there it might lead to exceptions from light classes when building them for serializer/serializable classes
|
||||||
val serializableAnnotationFqName = FqName("kotlinx.serialization.Serializable")
|
val serializableAnnotationFqName = FqName("kotlinx.serialization.Serializable")
|
||||||
val serializerAnnotationFqName = FqName("kotlinx.serialization.Serializer")
|
val serializerAnnotationFqName = FqName("kotlinx.serialization.Serializer")
|
||||||
internal val serialNameAnnotationFqName = FqName("kotlinx.serialization.SerialName")
|
val serialNameAnnotationFqName = FqName("kotlinx.serialization.SerialName")
|
||||||
internal val requiredAnnotationFqName = FqName("kotlinx.serialization.Required")
|
val requiredAnnotationFqName = FqName("kotlinx.serialization.Required")
|
||||||
val serialTransientFqName = FqName("kotlinx.serialization.Transient")
|
val serialTransientFqName = FqName("kotlinx.serialization.Transient")
|
||||||
// Also implicitly used in kotlin-native.compiler.backend.native/CodeGenerationInfo.kt
|
// Also implicitly used in kotlin-native.compiler.backend.native/CodeGenerationInfo.kt
|
||||||
internal val serialInfoFqName = FqName("kotlinx.serialization.SerialInfo")
|
val serialInfoFqName = FqName("kotlinx.serialization.SerialInfo")
|
||||||
internal val inheritableSerialInfoFqName = FqName("kotlinx.serialization.InheritableSerialInfo")
|
val inheritableSerialInfoFqName = FqName("kotlinx.serialization.InheritableSerialInfo")
|
||||||
internal val metaSerializableAnnotationFqName = FqName("kotlinx.serialization.MetaSerializable")
|
val metaSerializableAnnotationFqName = FqName("kotlinx.serialization.MetaSerializable")
|
||||||
internal val encodeDefaultFqName = FqName("kotlinx.serialization.EncodeDefault")
|
val encodeDefaultFqName = FqName("kotlinx.serialization.EncodeDefault")
|
||||||
|
|
||||||
internal val contextualFqName = FqName("kotlinx.serialization.ContextualSerialization") // this one is deprecated
|
val contextualFqName = FqName("kotlinx.serialization.ContextualSerialization") // this one is deprecated
|
||||||
internal val contextualOnFileFqName = FqName("kotlinx.serialization.UseContextualSerialization")
|
val contextualOnFileFqName = FqName("kotlinx.serialization.UseContextualSerialization")
|
||||||
internal val contextualOnPropertyFqName = FqName("kotlinx.serialization.Contextual")
|
val contextualOnPropertyFqName = FqName("kotlinx.serialization.Contextual")
|
||||||
internal val polymorphicFqName = FqName("kotlinx.serialization.Polymorphic")
|
val polymorphicFqName = FqName("kotlinx.serialization.Polymorphic")
|
||||||
internal val additionalSerializersFqName = FqName("kotlinx.serialization.UseSerializers")
|
val additionalSerializersFqName = FqName("kotlinx.serialization.UseSerializers")
|
||||||
}
|
}
|
||||||
|
|
||||||
object SerialEntityNames {
|
object SerialEntityNames {
|
||||||
@@ -109,10 +109,10 @@ object SerialEntityNames {
|
|||||||
|
|
||||||
// parameters
|
// parameters
|
||||||
val dummyParamName = Name.identifier("serializationConstructorMarker")
|
val dummyParamName = Name.identifier("serializationConstructorMarker")
|
||||||
internal const val typeArgPrefix = "typeSerial"
|
const val typeArgPrefix = "typeSerial"
|
||||||
|
|
||||||
internal val wrapIntoNullableExt = SerializationPackages.builtinsPackageFqName.child(Name.identifier("nullable"))
|
val wrapIntoNullableExt = SerializationPackages.builtinsPackageFqName.child(Name.identifier("nullable"))
|
||||||
internal val wrapIntoNullableCallableId = CallableId(SerializationPackages.builtinsPackageFqName, Name.identifier("nullable"))
|
val wrapIntoNullableCallableId = CallableId(SerializationPackages.builtinsPackageFqName, Name.identifier("nullable"))
|
||||||
}
|
}
|
||||||
|
|
||||||
object SpecialBuiltins {
|
object SpecialBuiltins {
|
||||||
@@ -146,7 +146,7 @@ object CallingConventions {
|
|||||||
const val addClassAnnotation = "pushClassAnnotation"
|
const val addClassAnnotation = "pushClassAnnotation"
|
||||||
}
|
}
|
||||||
|
|
||||||
internal object SerializationDependencies {
|
object SerializationDependencies {
|
||||||
val LAZY_FQ = FqName("kotlin.Lazy")
|
val LAZY_FQ = FqName("kotlin.Lazy")
|
||||||
val LAZY_FUNC_FQ = FqName("kotlin.lazy")
|
val LAZY_FUNC_FQ = FqName("kotlin.lazy")
|
||||||
val LAZY_MODE_FQ = FqName("kotlin.LazyThreadSafetyMode")
|
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.
|
* 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
|
package org.jetbrains.kotlinx.serialization.compiler.backend.common
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
|
import org.jetbrains.kotlin.backend.common.CompilationException
|
||||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||||
import org.jetbrains.kotlin.codegen.CompilationException
|
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||||
import org.jetbrains.kotlin.js.descriptorUtils.getJetTypeFqName
|
import org.jetbrains.kotlin.js.descriptorUtils.getJetTypeFqName
|
||||||
@@ -101,7 +101,7 @@ fun ClassDescriptor.serialName(): String {
|
|||||||
return annotations.serialNameValue ?: fqNameUnsafe.asString()
|
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
|
* Returns class descriptor for ContextSerializer or PolymorphicSerializer
|
||||||
@@ -244,7 +244,7 @@ fun findEnumTypeSerializer(module: ModuleDescriptor, kType: KotlinType): ClassDe
|
|||||||
else null
|
else null
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun KtPureClassOrObject.bodyPropertiesDescriptorsMap(
|
fun KtPureClassOrObject.bodyPropertiesDescriptorsMap(
|
||||||
bindingContext: BindingContext,
|
bindingContext: BindingContext,
|
||||||
filterUninitialized: Boolean = true
|
filterUninitialized: Boolean = true
|
||||||
): Map<PropertyDescriptor, KtProperty> = declarations
|
): Map<PropertyDescriptor, KtProperty> = declarations
|
||||||
@@ -254,13 +254,13 @@ internal fun KtPureClassOrObject.bodyPropertiesDescriptorsMap(
|
|||||||
.filter { if (filterUninitialized) it.delegateExpressionOrInitializer != null else true }
|
.filter { if (filterUninitialized) it.delegateExpressionOrInitializer != null else true }
|
||||||
.associateBy { (bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, it] as? PropertyDescriptor)!! }
|
.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
|
primaryConstructorParameters
|
||||||
.asSequence()
|
.asSequence()
|
||||||
.filter { it.hasValOrVar() }
|
.filter { it.hasValOrVar() }
|
||||||
.associateBy { bindingContext[BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, it]!! }
|
.associateBy { bindingContext[BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, it]!! }
|
||||||
|
|
||||||
internal fun KtPureClassOrObject.anonymousInitializers() = declarations
|
fun KtPureClassOrObject.anonymousInitializers() = declarations
|
||||||
.asSequence()
|
.asSequence()
|
||||||
.filterIsInstance<KtAnonymousInitializer>()
|
.filterIsInstance<KtAnonymousInitializer>()
|
||||||
.mapNotNull { it.body }
|
.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.
|
* 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.
|
* 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.backend.common.primaryConstructorPropertiesDescriptorsMap
|
||||||
import org.jetbrains.kotlinx.serialization.compiler.resolve.*
|
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 {
|
open class SerializationPluginDeclarationChecker : DeclarationChecker {
|
||||||
private var useLegacyEnumSerializerCached: Boolean? = null
|
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
|
get() = hasSerializableOrMetaAnnotationWithoutArgs && !isInternalSerializable && !hasCompanionObjectAsSerializer && kind != ClassKind.ENUM_CLASS && !isSealedSerializableInterface
|
||||||
+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.
|
* 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.LazyClassContext
|
||||||
import org.jetbrains.kotlin.resolve.lazy.declarations.ClassMemberDeclarationProvider
|
import org.jetbrains.kotlin.resolve.lazy.declarations.ClassMemberDeclarationProvider
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
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.*
|
import org.jetbrains.kotlinx.serialization.compiler.resolve.*
|
||||||
|
|
||||||
open class SerializationResolveExtension @JvmOverloads constructor(val metadataPlugin: SerializationDescriptorSerializerPlugin? = null) : SyntheticResolveExtension {
|
open class SerializationResolveExtension @JvmOverloads constructor(val metadataPlugin: SerializationDescriptorSerializerPlugin? = null) : SyntheticResolveExtension {
|
||||||
@@ -100,7 +100,7 @@ open class SerializationResolveExtension @JvmOverloads constructor(val metadataP
|
|||||||
) {
|
) {
|
||||||
if (thisDescriptor.isInternalSerializable) {
|
if (thisDescriptor.isInternalSerializable) {
|
||||||
// do not add synthetic deserialization constructor if .deserialize method is customized
|
// 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
|
if (thisDescriptor.isInlineClass()) return
|
||||||
result.add(KSerializerDescriptorResolver.createLoadConstructorDescriptor(thisDescriptor, bindingContext, metadataPlugin))
|
result.add(KSerializerDescriptorResolver.createLoadConstructorDescriptor(thisDescriptor, bindingContext, metadataPlugin))
|
||||||
}
|
}
|
||||||
+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.
|
* 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.serialInfoFqName
|
||||||
import org.jetbrains.kotlinx.serialization.compiler.resolve.SerializationAnnotations.serializableAnnotationFqName
|
import org.jetbrains.kotlinx.serialization.compiler.resolve.SerializationAnnotations.serializableAnnotationFqName
|
||||||
|
|
||||||
internal fun isAllowedToHaveAutoGeneratedSerializerMethods(
|
fun isAllowedToHaveAutoGeneratedSerializerMethods(
|
||||||
classDescriptor: ClassDescriptor,
|
classDescriptor: ClassDescriptor,
|
||||||
serializableClassDescriptor: ClassDescriptor
|
serializableClassDescriptor: ClassDescriptor
|
||||||
): Boolean {
|
): Boolean {
|
||||||
@@ -43,16 +43,16 @@ internal fun isAllowedToHaveAutoGeneratedSerializerMethods(
|
|||||||
(classDescriptor.typeConstructor.supertypes.any(::isKSerializer) && classDescriptor.declaredTypeParameters.isEmpty())
|
(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)
|
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)
|
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)
|
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 projectionType = Variance.INVARIANT
|
||||||
val types = listOf(TypeProjectionImpl(projectionType, argument))
|
val types = listOf(TypeProjectionImpl(projectionType, argument))
|
||||||
val descriptor = module.findClassAcrossModuleDependencies(ClassId.topLevel(baseSerializerInterface))
|
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)
|
return KotlinTypeFactory.simpleNotNullType(TypeAttributes.Empty, descriptor, types)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun extractKSerializerArgumentFromImplementation(implementationClass: ClassDescriptor): KotlinType? {
|
fun extractKSerializerArgumentFromImplementation(implementationClass: ClassDescriptor): KotlinType? {
|
||||||
val supertypes = implementationClass.typeConstructor.supertypes
|
val supertypes = implementationClass.typeConstructor.supertypes
|
||||||
val kSerializerSupertype = supertypes.find { isGeneratedKSerializer(it) }
|
val kSerializerSupertype = supertypes.find { isGeneratedKSerializer(it) }
|
||||||
?: supertypes.find { isKSerializer(it) }
|
?: supertypes.find { isKSerializer(it) }
|
||||||
@@ -68,33 +68,33 @@ internal fun extractKSerializerArgumentFromImplementation(implementationClass: C
|
|||||||
return kSerializerSupertype.arguments.first().type
|
return kSerializerSupertype.arguments.first().type
|
||||||
}
|
}
|
||||||
|
|
||||||
internal val DeclarationDescriptor.serializableWith: KotlinType?
|
val DeclarationDescriptor.serializableWith: KotlinType?
|
||||||
get() = annotations.serializableWith(module)
|
get() = annotations.serializableWith(module)
|
||||||
|
|
||||||
internal fun Annotations.serializableWith(module: ModuleDescriptor): KotlinType? =
|
fun Annotations.serializableWith(module: ModuleDescriptor): KotlinType? =
|
||||||
this.findAnnotationKotlinTypeValue(serializableAnnotationFqName, module, "with")
|
this.findAnnotationKotlinTypeValue(serializableAnnotationFqName, module, "with")
|
||||||
|
|
||||||
internal val DeclarationDescriptor.serializerForClass: KotlinType?
|
val DeclarationDescriptor.serializerForClass: KotlinType?
|
||||||
get() = annotations.findAnnotationKotlinTypeValue(SerializationAnnotations.serializerAnnotationFqName, module, "forClass")
|
get() = annotations.findAnnotationKotlinTypeValue(SerializationAnnotations.serializerAnnotationFqName, module, "forClass")
|
||||||
|
|
||||||
internal val ClassDescriptor.isSerialInfoAnnotation: Boolean
|
val ClassDescriptor.isSerialInfoAnnotation: Boolean
|
||||||
get() = annotations.hasAnnotation(serialInfoFqName)
|
get() = annotations.hasAnnotation(serialInfoFqName)
|
||||||
|| annotations.hasAnnotation(inheritableSerialInfoFqName)
|
|| annotations.hasAnnotation(inheritableSerialInfoFqName)
|
||||||
|| annotations.hasAnnotation(metaSerializableAnnotationFqName)
|
|| annotations.hasAnnotation(metaSerializableAnnotationFqName)
|
||||||
|
|
||||||
internal val ClassDescriptor.isInheritableSerialInfoAnnotation: Boolean
|
val ClassDescriptor.isInheritableSerialInfoAnnotation: Boolean
|
||||||
get() = annotations.hasAnnotation(inheritableSerialInfoFqName)
|
get() = annotations.hasAnnotation(inheritableSerialInfoFqName)
|
||||||
|
|
||||||
internal val Annotations.serialNameValue: String?
|
val Annotations.serialNameValue: String?
|
||||||
get() = findAnnotationConstantValue(SerializationAnnotations.serialNameAnnotationFqName, "value")
|
get() = findAnnotationConstantValue(SerializationAnnotations.serialNameAnnotationFqName, "value")
|
||||||
|
|
||||||
internal val Annotations.serialNameAnnotation: AnnotationDescriptor?
|
val Annotations.serialNameAnnotation: AnnotationDescriptor?
|
||||||
get() = findAnnotation(SerializationAnnotations.serialNameAnnotationFqName)
|
get() = findAnnotation(SerializationAnnotations.serialNameAnnotationFqName)
|
||||||
|
|
||||||
internal val Annotations.serialRequired: Boolean
|
val Annotations.serialRequired: Boolean
|
||||||
get() = hasAnnotation(SerializationAnnotations.requiredAnnotationFqName)
|
get() = hasAnnotation(SerializationAnnotations.requiredAnnotationFqName)
|
||||||
|
|
||||||
internal val Annotations.serialTransient: Boolean
|
val Annotations.serialTransient: Boolean
|
||||||
get() = hasAnnotation(SerializationAnnotations.serialTransientFqName)
|
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
|
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
|
get() = kind == ClassKind.OBJECT && hasSerializableOrMetaAnnotation
|
||||||
|
|
||||||
internal val ClassDescriptor.isInternallySerializableObject: Boolean
|
val ClassDescriptor.isInternallySerializableObject: Boolean
|
||||||
get() = kind == ClassKind.OBJECT && hasSerializableOrMetaAnnotationWithoutArgs
|
get() = kind == ClassKind.OBJECT && hasSerializableOrMetaAnnotationWithoutArgs
|
||||||
|
|
||||||
internal val ClassDescriptor.isSealedSerializableInterface: Boolean
|
val ClassDescriptor.isSealedSerializableInterface: Boolean
|
||||||
get() = kind == ClassKind.INTERFACE && modality == Modality.SEALED && hasSerializableOrMetaAnnotation
|
get() = kind == ClassKind.INTERFACE && modality == Modality.SEALED && hasSerializableOrMetaAnnotation
|
||||||
|
|
||||||
internal val ClassDescriptor.isInternalSerializable: Boolean //todo normal checking
|
val ClassDescriptor.isInternalSerializable: Boolean //todo normal checking
|
||||||
get() {
|
get() {
|
||||||
if (kind != ClassKind.CLASS) return false
|
if (kind != ClassKind.CLASS) return false
|
||||||
return hasSerializableOrMetaAnnotationWithoutArgs
|
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
|
kind == ClassKind.ENUM_CLASS && hasSerializableOrMetaAnnotationWithoutArgs
|
||||||
|
|
||||||
internal val ClassDescriptor.shouldHaveGeneratedSerializer: Boolean
|
val ClassDescriptor.shouldHaveGeneratedSerializer: Boolean
|
||||||
get() = (isInternalSerializable && (modality == Modality.FINAL || modality == Modality.OPEN))
|
get() = (isInternalSerializable && (modality == Modality.FINAL || modality == Modality.OPEN))
|
||||||
|| isEnumWithLegacyGeneratedSerializer()
|
|| isEnumWithLegacyGeneratedSerializer()
|
||||||
|
|
||||||
internal val ClassDescriptor.useGeneratedEnumSerializer: Boolean
|
val ClassDescriptor.useGeneratedEnumSerializer: Boolean
|
||||||
get() {
|
get() {
|
||||||
val functions = module.getPackage(SerializationPackages.internalPackageFqName).memberScope.getFunctionNames()
|
val functions = module.getPackage(SerializationPackages.internalPackageFqName).memberScope.getFunctionNames()
|
||||||
return !functions.contains(ENUM_SERIALIZER_FACTORY_FUNC_NAME) || !functions.contains(MARKED_ENUM_SERIALIZER_FACTORY_FUNC_NAME)
|
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)
|
check(this.kind == ClassKind.ENUM_CLASS)
|
||||||
return unsubstitutedMemberScope.getContributedDescriptors().asSequence()
|
return unsubstitutedMemberScope.getContributedDescriptors().asSequence()
|
||||||
.filterIsInstance<ClassDescriptor>()
|
.filterIsInstance<ClassDescriptor>()
|
||||||
@@ -153,16 +153,16 @@ internal fun ClassDescriptor.enumEntries(): List<ClassDescriptor> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check enum or its elements has any SerialInfo annotation
|
// 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 (kind != ClassKind.ENUM_CLASS) return false
|
||||||
if (annotations.hasAnySerialAnnotation) return true
|
if (annotations.hasAnySerialAnnotation) return true
|
||||||
return enumEntries().any { (it.annotations.hasAnySerialAnnotation) }
|
return enumEntries().any { (it.annotations.hasAnySerialAnnotation) }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal val Annotations.hasAnySerialAnnotation: Boolean
|
val Annotations.hasAnySerialAnnotation: Boolean
|
||||||
get() = serialNameValue != null || any { it.annotationClass?.isSerialInfoAnnotation == true }
|
get() = serialNameValue != null || any { it.annotationClass?.isSerialInfoAnnotation == true }
|
||||||
|
|
||||||
internal val ClassDescriptor.hasSerializableOrMetaAnnotation
|
val ClassDescriptor.hasSerializableOrMetaAnnotation
|
||||||
get() = hasSerializableAnnotation || hasMetaSerializableAnnotation
|
get() = hasSerializableAnnotation || hasMetaSerializableAnnotation
|
||||||
|
|
||||||
private val ClassDescriptor.hasSerializableAnnotation
|
private val ClassDescriptor.hasSerializableAnnotation
|
||||||
@@ -171,13 +171,13 @@ private val ClassDescriptor.hasSerializableAnnotation
|
|||||||
private val Annotations.hasSerializableAnnotation
|
private val Annotations.hasSerializableAnnotation
|
||||||
get() = hasAnnotation(serializableAnnotationFqName)
|
get() = hasAnnotation(serializableAnnotationFqName)
|
||||||
|
|
||||||
internal val ClassDescriptor.hasMetaSerializableAnnotation: Boolean
|
val ClassDescriptor.hasMetaSerializableAnnotation: Boolean
|
||||||
get() = annotations.any { it.isMetaSerializableAnnotation }
|
get() = annotations.any { it.isMetaSerializableAnnotation }
|
||||||
|
|
||||||
internal val AnnotationDescriptor.isMetaSerializableAnnotation: Boolean
|
val AnnotationDescriptor.isMetaSerializableAnnotation: Boolean
|
||||||
get() = annotationClass?.annotations?.hasAnnotation(metaSerializableAnnotationFqName) ?: false
|
get() = annotationClass?.annotations?.hasAnnotation(metaSerializableAnnotationFqName) ?: false
|
||||||
|
|
||||||
internal val ClassDescriptor.hasSerializableOrMetaAnnotationWithoutArgs: Boolean
|
val ClassDescriptor.hasSerializableOrMetaAnnotationWithoutArgs: Boolean
|
||||||
get() = hasSerializableAnnotationWithoutArgs
|
get() = hasSerializableAnnotationWithoutArgs
|
||||||
|| (!annotations.hasSerializableAnnotation && hasMetaSerializableAnnotation)
|
|| (!annotations.hasSerializableAnnotation && hasMetaSerializableAnnotation)
|
||||||
|
|
||||||
@@ -195,13 +195,13 @@ private fun Annotated.findSerializableAnnotationDeclaration(): KtAnnotationEntry
|
|||||||
return lazyDesc?.annotationEntry
|
return lazyDesc?.annotationEntry
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun Annotated.findSerializableOrMetaAnnotationDeclaration(): KtAnnotationEntry? {
|
fun Annotated.findSerializableOrMetaAnnotationDeclaration(): KtAnnotationEntry? {
|
||||||
val lazyDesc = (annotations.findAnnotation(serializableAnnotationFqName)
|
val lazyDesc = (annotations.findAnnotation(serializableAnnotationFqName)
|
||||||
?: annotations.firstOrNull { it.isMetaSerializableAnnotation }) as? LazyAnnotationDescriptor
|
?: annotations.firstOrNull { it.isMetaSerializableAnnotation }) as? LazyAnnotationDescriptor
|
||||||
return lazyDesc?.annotationEntry
|
return lazyDesc?.annotationEntry
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun Annotated.findAnnotationDeclaration(fqName: FqName): KtAnnotationEntry? {
|
fun Annotated.findAnnotationDeclaration(fqName: FqName): KtAnnotationEntry? {
|
||||||
val lazyDesc = annotations.findAnnotation(fqName) as? LazyAnnotationDescriptor
|
val lazyDesc = annotations.findAnnotation(fqName) as? LazyAnnotationDescriptor
|
||||||
return lazyDesc?.annotationEntry
|
return lazyDesc?.annotationEntry
|
||||||
}
|
}
|
||||||
@@ -209,10 +209,10 @@ internal fun Annotated.findAnnotationDeclaration(fqName: FqName): KtAnnotationEn
|
|||||||
// For abstract classes marked with @Serializable,
|
// For abstract classes marked with @Serializable,
|
||||||
// methods are generated anyway, although they shouldn't have
|
// methods are generated anyway, although they shouldn't have
|
||||||
// generated $serializer and use Polymorphic one.
|
// generated $serializer and use Polymorphic one.
|
||||||
internal fun ClassDescriptor.isAbstractOrSealedSerializableClass(): Boolean =
|
fun ClassDescriptor.isAbstractOrSealedSerializableClass(): Boolean =
|
||||||
isInternalSerializable && (modality == Modality.ABSTRACT || modality == Modality.SEALED)
|
isInternalSerializable && (modality == Modality.ABSTRACT || modality == Modality.SEALED)
|
||||||
|
|
||||||
internal fun ClassDescriptor.polymorphicSerializerIfApplicableAutomatically(): ClassDescriptor? {
|
fun ClassDescriptor.polymorphicSerializerIfApplicableAutomatically(): ClassDescriptor? {
|
||||||
val serializer = when {
|
val serializer = when {
|
||||||
kind == ClassKind.INTERFACE && modality == Modality.SEALED -> SpecialBuiltins.sealedSerializer
|
kind == ClassKind.INTERFACE && modality == Modality.SEALED -> SpecialBuiltins.sealedSerializer
|
||||||
kind == ClassKind.INTERFACE -> SpecialBuiltins.polymorphicSerializer
|
kind == ClassKind.INTERFACE -> SpecialBuiltins.polymorphicSerializer
|
||||||
@@ -224,7 +224,7 @@ internal fun ClassDescriptor.polymorphicSerializerIfApplicableAutomatically(): C
|
|||||||
}
|
}
|
||||||
|
|
||||||
// serializer that was declared for this type
|
// serializer that was declared for this type
|
||||||
internal val ClassDescriptor?.classSerializer: ClassDescriptor?
|
val ClassDescriptor?.classSerializer: ClassDescriptor?
|
||||||
get() = this?.let {
|
get() = this?.let {
|
||||||
// serializer annotation on class?
|
// serializer annotation on class?
|
||||||
serializableWith?.let { return it.toClassDescriptor }
|
serializableWith?.let { return it.toClassDescriptor }
|
||||||
@@ -242,21 +242,21 @@ internal val ClassDescriptor?.classSerializer: ClassDescriptor?
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
internal val ClassDescriptor.hasCompanionObjectAsSerializer: Boolean
|
val ClassDescriptor.hasCompanionObjectAsSerializer: Boolean
|
||||||
get() = isInternallySerializableObject || companionObjectDescriptor?.serializerForClass == this.defaultType
|
get() = isInternallySerializableObject || companionObjectDescriptor?.serializerForClass == this.defaultType
|
||||||
|
|
||||||
// returns only user-overriden Serializer
|
// returns only user-overriden Serializer
|
||||||
internal val KotlinType.overridenSerializer: KotlinType?
|
val KotlinType.overridenSerializer: KotlinType?
|
||||||
get() {
|
get() {
|
||||||
val desc = this.toClassDescriptor ?: return null
|
val desc = this.toClassDescriptor ?: return null
|
||||||
desc.serializableWith?.let { return it }
|
desc.serializableWith?.let { return it }
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
internal val KotlinType.genericIndex: Int?
|
val KotlinType.genericIndex: Int?
|
||||||
get() = (this.constructor.declarationDescriptor as? TypeParameterDescriptor)?.index
|
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.isSerializableObject) return thisDescriptor
|
||||||
if (!thisDescriptor.isCompanionObject) return null
|
if (!thisDescriptor.isCompanionObject) return null
|
||||||
val classDescriptor = (thisDescriptor.containingDeclaration as? ClassDescriptor) ?: return null
|
val classDescriptor = (thisDescriptor.containingDeclaration as? ClassDescriptor) ?: return null
|
||||||
@@ -264,7 +264,7 @@ internal fun getSerializableClassDescriptorByCompanion(thisDescriptor: ClassDesc
|
|||||||
return classDescriptor
|
return classDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun ClassDescriptor.needSerializerFactory(): Boolean {
|
fun ClassDescriptor.needSerializerFactory(): Boolean {
|
||||||
if (!(this.platform?.isNative() == true || this.platform.isJs())) return false
|
if (!(this.platform?.isNative() == true || this.platform.isJs())) return false
|
||||||
val serializableClass = getSerializableClassDescriptorByCompanion(this) ?: return false
|
val serializableClass = getSerializableClassDescriptorByCompanion(this) ?: return false
|
||||||
if (serializableClass.isSerializableObject) return true
|
if (serializableClass.isSerializableObject) return true
|
||||||
@@ -275,7 +275,7 @@ internal fun ClassDescriptor.needSerializerFactory(): Boolean {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun getSerializableClassDescriptorBySerializer(serializerDescriptor: ClassDescriptor): ClassDescriptor? {
|
fun getSerializableClassDescriptorBySerializer(serializerDescriptor: ClassDescriptor): ClassDescriptor? {
|
||||||
val serializerForClass = serializerDescriptor.serializerForClass
|
val serializerForClass = serializerDescriptor.serializerForClass
|
||||||
if (serializerForClass != null) return serializerForClass.toClassDescriptor
|
if (serializerForClass != null) return serializerForClass.toClassDescriptor
|
||||||
if (serializerDescriptor.name !in setOf(
|
if (serializerDescriptor.name !in setOf(
|
||||||
@@ -288,19 +288,19 @@ internal fun getSerializableClassDescriptorBySerializer(serializerDescriptor: Cl
|
|||||||
return classDescriptor
|
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
|
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
|
// 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
|
parameters.size == 2
|
||||||
|
|
||||||
internal fun ClassDescriptor.checkSaveMethodResult(type: KotlinType): Boolean =
|
fun ClassDescriptor.checkSaveMethodResult(type: KotlinType): Boolean =
|
||||||
KotlinBuiltIns.isUnit(type)
|
KotlinBuiltIns.isUnit(type)
|
||||||
|
|
||||||
// todo: serialization: do an actual check better that just number of parameters
|
// 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
|
parameters.size == 1
|
||||||
|
|
||||||
internal fun ClassDescriptor.checkLoadMethodResult(type: KotlinType): Boolean =
|
fun ClassDescriptor.checkLoadMethodResult(type: KotlinType): Boolean =
|
||||||
getSerializableClassDescriptorBySerializer(this)?.defaultType == type
|
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.
|
* 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.KotlinTypeFactory
|
||||||
import org.jetbrains.kotlin.types.TypeAttributes
|
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*/
|
/*kind == CallableMemberDescriptor.Kind.SYNTHESIZED does not work because DeserializedClassConstructorDescriptor loses its kind*/
|
||||||
return valueParameters.lastOrNull()?.run {
|
return valueParameters.lastOrNull()?.run {
|
||||||
name == SerialEntityNames.dummyParamName && type.constructor.declarationDescriptor?.classId == ClassId(
|
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...>>
|
// finds constructor (KSerializer<T0>, KSerializer<T1>...) on a KSerializer<T<T0, T1...>>
|
||||||
internal fun findSerializerConstructorForTypeArgumentsSerializers(
|
fun findSerializerConstructorForTypeArgumentsSerializers(
|
||||||
serializerDescriptor: ClassDescriptor,
|
serializerDescriptor: ClassDescriptor,
|
||||||
onlyIfSynthetic: Boolean = false
|
onlyIfSynthetic: Boolean = false
|
||||||
): ClassConstructorDescriptor? {
|
): ClassConstructorDescriptor? {
|
||||||
@@ -56,7 +56,7 @@ inline fun <reified R> Annotations.findAnnotationConstantValue(annotationFqName:
|
|||||||
inline fun <reified R> AnnotationDescriptor.findConstantValue(property: String): R? =
|
inline fun <reified R> AnnotationDescriptor.findConstantValue(property: String): R? =
|
||||||
allValueArguments.entries.singleOrNull { it.key.asString() == property }?.value?.value as? R
|
allValueArguments.entries.singleOrNull { it.key.asString() == property }?.value?.value as? R
|
||||||
|
|
||||||
internal fun Annotations.findAnnotationKotlinTypeValue(
|
fun Annotations.findAnnotationKotlinTypeValue(
|
||||||
annotationFqName: FqName,
|
annotationFqName: FqName,
|
||||||
moduleForResolve: ModuleDescriptor,
|
moduleForResolve: ModuleDescriptor,
|
||||||
property: String
|
property: String
|
||||||
@@ -66,7 +66,7 @@ internal fun Annotations.findAnnotationKotlinTypeValue(
|
|||||||
maybeKClass?.getArgumentType(moduleForResolve)
|
maybeKClass?.getArgumentType(moduleForResolve)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun ClassDescriptor.getKSerializerConstructorMarker(): ClassDescriptor =
|
fun ClassDescriptor.getKSerializerConstructorMarker(): ClassDescriptor =
|
||||||
module.findClassAcrossModuleDependencies(
|
module.findClassAcrossModuleDependencies(
|
||||||
ClassId(
|
ClassId(
|
||||||
SerializationPackages.internalPackageFqName,
|
SerializationPackages.internalPackageFqName,
|
||||||
@@ -74,7 +74,7 @@ internal fun ClassDescriptor.getKSerializerConstructorMarker(): ClassDescriptor
|
|||||||
)
|
)
|
||||||
)!!
|
)!!
|
||||||
|
|
||||||
internal fun ClassDescriptor.getKSerializer(): ClassDescriptor =
|
fun ClassDescriptor.getKSerializer(): ClassDescriptor =
|
||||||
module.findClassAcrossModuleDependencies(
|
module.findClassAcrossModuleDependencies(
|
||||||
ClassId(
|
ClassId(
|
||||||
SerializationPackages.packageFqName,
|
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))
|
SerializationPackages.internalPackageFqName.child(Name.identifier(classSimpleName))
|
||||||
|
|
||||||
internal fun ModuleDescriptor.getClassFromInternalSerializationPackage(classSimpleName: String) =
|
fun ModuleDescriptor.getClassFromInternalSerializationPackage(classSimpleName: String) =
|
||||||
requireNotNull(
|
requireNotNull(
|
||||||
findClassAcrossModuleDependencies(
|
findClassAcrossModuleDependencies(
|
||||||
ClassId(
|
ClassId(
|
||||||
@@ -95,7 +95,7 @@ internal fun ModuleDescriptor.getClassFromInternalSerializationPackage(classSimp
|
|||||||
)
|
)
|
||||||
) { "Can't locate class $classSimpleName from package ${SerializationPackages.internalPackageFqName}" }
|
) { "Can't locate class $classSimpleName from package ${SerializationPackages.internalPackageFqName}" }
|
||||||
|
|
||||||
internal fun ModuleDescriptor.getClassFromSerializationDescriptorsPackage(classSimpleName: String) =
|
fun ModuleDescriptor.getClassFromSerializationDescriptorsPackage(classSimpleName: String) =
|
||||||
requireNotNull(
|
requireNotNull(
|
||||||
findClassAcrossModuleDependencies(
|
findClassAcrossModuleDependencies(
|
||||||
ClassId(
|
ClassId(
|
||||||
@@ -105,10 +105,10 @@ internal fun ModuleDescriptor.getClassFromSerializationDescriptorsPackage(classS
|
|||||||
)
|
)
|
||||||
) { "Can't locate class $classSimpleName from package ${SerializationPackages.descriptorsPackageFqName}" }
|
) { "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))
|
SerializationPackages.packageFqName.child(Name.identifier(classSimpleName))
|
||||||
|
|
||||||
internal fun ModuleDescriptor.getClassFromSerializationPackage(classSimpleName: String) =
|
fun ModuleDescriptor.getClassFromSerializationPackage(classSimpleName: String) =
|
||||||
SerializationPackages.allPublicPackages.firstNotNullOfOrNull { pkg ->
|
SerializationPackages.allPublicPackages.firstNotNullOfOrNull { pkg ->
|
||||||
module.findClassAcrossModuleDependencies(ClassId(
|
module.findClassAcrossModuleDependencies(ClassId(
|
||||||
pkg,
|
pkg,
|
||||||
@@ -116,16 +116,16 @@ internal fun ModuleDescriptor.getClassFromSerializationPackage(classSimpleName:
|
|||||||
))
|
))
|
||||||
} ?: throw IllegalArgumentException("Can't locate class $classSimpleName")
|
} ?: throw IllegalArgumentException("Can't locate class $classSimpleName")
|
||||||
|
|
||||||
internal fun ClassDescriptor.getClassFromSerializationPackage(classSimpleName: String) =
|
fun ClassDescriptor.getClassFromSerializationPackage(classSimpleName: String) =
|
||||||
module.getClassFromSerializationPackage(classSimpleName)
|
module.getClassFromSerializationPackage(classSimpleName)
|
||||||
|
|
||||||
internal fun ClassDescriptor.getClassFromInternalSerializationPackage(classSimpleName: String) =
|
fun ClassDescriptor.getClassFromInternalSerializationPackage(classSimpleName: String) =
|
||||||
module.getClassFromInternalSerializationPackage(classSimpleName)
|
module.getClassFromInternalSerializationPackage(classSimpleName)
|
||||||
|
|
||||||
fun ClassDescriptor.toSimpleType(nullable: Boolean = false) =
|
fun ClassDescriptor.toSimpleType(nullable: Boolean = false) =
|
||||||
KotlinTypeFactory.simpleType(TypeAttributes.Empty, this.typeConstructor, emptyList(), nullable)
|
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()
|
annotations.asSequence()
|
||||||
.filter { it.type.toClassDescriptor?.isSerialInfoAnnotation == true }
|
.filter { it.type.toClassDescriptor?.isSerialInfoAnnotation == true }
|
||||||
.filterIsInstance<LazyAnnotationDescriptor>()
|
.filterIsInstance<LazyAnnotationDescriptor>()
|
||||||
+7
-7
@@ -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.
|
* 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() {
|
get() {
|
||||||
var goldenMask = 0
|
var goldenMask = 0
|
||||||
var requiredBit = 1
|
var requiredBit = 1
|
||||||
@@ -133,7 +133,7 @@ internal val ISerializableProperties<*>.goldenMask: Int
|
|||||||
return goldenMask
|
return goldenMask
|
||||||
}
|
}
|
||||||
|
|
||||||
internal val ISerializableProperties<*>.goldenMaskList: List<Int>
|
val ISerializableProperties<*>.goldenMaskList: List<Int>
|
||||||
get() {
|
get() {
|
||||||
val maskSlotCount = serializableProperties.bitMaskSlotCount()
|
val maskSlotCount = serializableProperties.bitMaskSlotCount()
|
||||||
val goldenMaskList = MutableList(maskSlotCount) { 0 }
|
val goldenMaskList = MutableList(maskSlotCount) { 0 }
|
||||||
@@ -148,10 +148,10 @@ internal val ISerializableProperties<*>.goldenMaskList: List<Int>
|
|||||||
return goldenMaskList
|
return goldenMaskList
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun List<ISerializableProperty>.bitMaskSlotCount() = size / 32 + 1
|
fun List<ISerializableProperty>.bitMaskSlotCount() = size / 32 + 1
|
||||||
internal fun bitMaskSlotAt(propertyIndex: Int) = propertyIndex / 32
|
fun bitMaskSlotAt(propertyIndex: Int) = propertyIndex / 32
|
||||||
|
|
||||||
internal fun BindingContext.serializablePropertiesFor(
|
fun BindingContext.serializablePropertiesFor(
|
||||||
classDescriptor: ClassDescriptor,
|
classDescriptor: ClassDescriptor,
|
||||||
serializationDescriptorSerializer: SerializationDescriptorSerializerPlugin? = null
|
serializationDescriptorSerializer: SerializationDescriptorSerializerPlugin? = null
|
||||||
): SerializableProperties {
|
): SerializableProperties {
|
||||||
@@ -160,7 +160,7 @@ internal fun BindingContext.serializablePropertiesFor(
|
|||||||
return props
|
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
|
if (descriptor !is DeserializedClassDescriptor) return props
|
||||||
val correctOrder: List<Name> = descriptor.classProto.getExtension(SerializationPluginMetadataExtensions.propertiesNamesInProgramOrder)
|
val correctOrder: List<Name> = descriptor.classProto.getExtension(SerializationPluginMetadataExtensions.propertiesNamesInProgramOrder)
|
||||||
.map { descriptor.c.nameResolver.getName(it) }
|
.map { descriptor.c.nameResolver.getName(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()
|
||||||
-5
@@ -17,18 +17,13 @@ import org.jetbrains.kotlin.fir.extensions.FirDeclarationGenerationExtension
|
|||||||
import org.jetbrains.kotlin.fir.moduleData
|
import org.jetbrains.kotlin.fir.moduleData
|
||||||
import org.jetbrains.kotlin.fir.resolve.defaultType
|
import org.jetbrains.kotlin.fir.resolve.defaultType
|
||||||
import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider
|
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.FirBasedSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.SymbolInternals
|
import org.jetbrains.kotlin.fir.symbols.SymbolInternals
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
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.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.fir.types.toFirResolvedTypeRef
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.types.Variance
|
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)
|
// FIXME KT-53096: this has to be shared (copied from plugin example)
|
||||||
+1
-11
@@ -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.
|
* 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
|
package org.jetbrains.kotlinx.serialization.compiler.fir
|
||||||
|
|
||||||
import org.jetbrains.kotlin.GeneratedDeclarationKey
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||||
import org.jetbrains.kotlin.descriptors.EffectiveVisibility
|
import org.jetbrains.kotlin.descriptors.EffectiveVisibility
|
||||||
import org.jetbrains.kotlin.descriptors.Modality
|
import org.jetbrains.kotlin.descriptors.Modality
|
||||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||||
import org.jetbrains.kotlin.fir.FirSession
|
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.copy
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin
|
import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin
|
||||||
import org.jetbrains.kotlin.fir.declarations.builder.*
|
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.*
|
||||||
import org.jetbrains.kotlin.fir.scopes.impl.toConeType
|
import org.jetbrains.kotlin.fir.scopes.impl.toConeType
|
||||||
import org.jetbrains.kotlin.fir.symbols.SymbolInternals
|
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.symbols.impl.*
|
||||||
import org.jetbrains.kotlin.fir.types.*
|
import org.jetbrains.kotlin.fir.types.*
|
||||||
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
|
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.ClassId
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.name.SpecialNames
|
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.SerialEntityNames
|
||||||
import org.jetbrains.kotlinx.serialization.compiler.resolve.SerializationPackages
|
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 generatedSerializerClassId = ClassId(SerializationPackages.internalPackageFqName, SerialEntityNames.GENERATED_SERIALIZER_CLASS)
|
||||||
val kSerializerClassId = ClassId(SerializationPackages.packageFqName, SerialEntityNames.KSERIALIZER_NAME)
|
val kSerializerClassId = ClassId(SerializationPackages.packageFqName, SerialEntityNames.KSERIALIZER_NAME)
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user