[Parcelize] Reorganize module structure of Parcelize plugin
Also mark parcelize as compatible with K2
This commit is contained in:
committed by
teamcity
parent
2a7dc1cc0c
commit
259862d294
+3
@@ -25,6 +25,8 @@ import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettingsImpl
|
||||
import org.jetbrains.kotlin.fir.*
|
||||
import org.jetbrains.kotlin.fir.analysis.checkersComponent
|
||||
import org.jetbrains.kotlin.fir.analysis.extensions.additionalCheckers
|
||||
import org.jetbrains.kotlin.fir.backend.jvm.FirJvmTypeMapper
|
||||
import org.jetbrains.kotlin.fir.extensions.*
|
||||
import org.jetbrains.kotlin.fir.resolve.providers.FirDependenciesSymbolProvider
|
||||
@@ -135,6 +137,7 @@ internal object LLFirSessionFactory {
|
||||
register(FirJvmTypeMapper::class, FirJvmTypeMapper(this))
|
||||
|
||||
configureSession?.invoke(this)
|
||||
extensionService.additionalCheckers.forEach(session.checkersComponent::register)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import org.jetbrains.kotlin.ideaExt.idea
|
||||
|
||||
description = "Parcelize compiler plugin"
|
||||
|
||||
plugins {
|
||||
@@ -13,21 +11,18 @@ val layoutLib by configurations.creating
|
||||
val layoutLibApi by configurations.creating
|
||||
|
||||
dependencies {
|
||||
testApi(intellijCore())
|
||||
|
||||
compileOnly(project(":compiler:util"))
|
||||
compileOnly(project(":compiler:plugin-api"))
|
||||
compileOnly(project(":compiler:frontend"))
|
||||
compileOnly(project(":compiler:frontend.java"))
|
||||
compileOnly(project(":compiler:backend"))
|
||||
compileOnly(project(":compiler:ir.backend.common"))
|
||||
compileOnly(project(":compiler:backend.jvm"))
|
||||
compileOnly(project(":compiler:ir.tree.impl"))
|
||||
compileOnly(intellijCore())
|
||||
compileOnly(commonDependency("org.jetbrains.intellij.deps:asm-all"))
|
||||
embedded(project(":plugins:parcelize:parcelize-compiler:parcelize.common")) { isTransitive = false }
|
||||
embedded(project(":plugins:parcelize:parcelize-compiler:parcelize.k1")) { isTransitive = false }
|
||||
embedded(project(":plugins:parcelize:parcelize-compiler:parcelize.k2")) { isTransitive = false }
|
||||
embedded(project(":plugins:parcelize:parcelize-compiler:parcelize.backend")) { isTransitive = false }
|
||||
embedded(project(":plugins:parcelize:parcelize-compiler:parcelize.cli")) { isTransitive = false }
|
||||
|
||||
testApiJUnit5()
|
||||
|
||||
testApi(intellijCore())
|
||||
|
||||
testApi(project(":plugins:parcelize:parcelize-compiler:parcelize.cli"))
|
||||
|
||||
testApi(project(":compiler:util"))
|
||||
testApi(project(":compiler:backend"))
|
||||
testApi(project(":compiler:ir.backend.common"))
|
||||
@@ -45,7 +40,6 @@ dependencies {
|
||||
testApi(project(":compiler:fir:checkers"))
|
||||
testApi(project(":compiler:fir:checkers:checkers.jvm"))
|
||||
testApi(project(":compiler:fir:checkers:checkers.js"))
|
||||
testApi(project(":plugins:parcelize:parcelize-compiler:parcelize-fir"))
|
||||
testRuntimeOnly(project(":compiler:fir:fir-serialization"))
|
||||
|
||||
testCompileOnly(project(":kotlin-reflect-api"))
|
||||
@@ -66,27 +60,17 @@ dependencies {
|
||||
layoutLibApi("com.android.tools.layoutlib:layoutlib-api:26.5.0") { isTransitive = false }
|
||||
}
|
||||
|
||||
val generationRoot = projectDir.resolve("tests-gen")
|
||||
|
||||
sourceSets {
|
||||
"main" { projectDefault() }
|
||||
"main" { none() }
|
||||
"test" {
|
||||
projectDefault()
|
||||
this.java.srcDir(generationRoot.name)
|
||||
}
|
||||
}
|
||||
|
||||
if (kotlinBuildProperties.isInJpsBuildIdeaSync) {
|
||||
apply(plugin = "idea")
|
||||
idea {
|
||||
this.module.generatedSourceDirs.add(generationRoot)
|
||||
generatedTestDir()
|
||||
}
|
||||
}
|
||||
|
||||
runtimeJar()
|
||||
javadocJar()
|
||||
sourcesJar()
|
||||
|
||||
javadocJar()
|
||||
testsJar()
|
||||
|
||||
projectTest(jUnitMode = JUnitMode.JUnit5) {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
description = "Parcelize compiler plugin (Backend)"
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("jps-compatible")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(":plugins:parcelize:parcelize-compiler:parcelize.common"))
|
||||
implementation(project(":plugins:parcelize:parcelize-compiler:parcelize.k1"))
|
||||
implementation(project(":plugins:parcelize:parcelize-compiler:parcelize.k2"))
|
||||
|
||||
compileOnly(project(":compiler:backend"))
|
||||
compileOnly(project(":compiler:ir.backend.common"))
|
||||
compileOnly(project(":compiler:backend.jvm"))
|
||||
compileOnly(project(":compiler:ir.tree.impl"))
|
||||
compileOnly(project(":compiler:fir:tree"))
|
||||
compileOnly(project(":compiler:fir:fir2ir"))
|
||||
compileOnly(intellijCore())
|
||||
compileOnly(commonDependency("org.jetbrains.intellij.deps:asm-all"))
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
"main" { projectDefault() }
|
||||
"test" { none() }
|
||||
}
|
||||
|
||||
runtimeJar()
|
||||
javadocJar()
|
||||
sourcesJar()
|
||||
+2
-13
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* 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.kotlin.parcelize
|
||||
+1
-14
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2019 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.
|
||||
*/
|
||||
|
||||
@@ -12,12 +12,10 @@ import org.jetbrains.kotlin.codegen.FunctionGenerationStrategy.CodegenBased
|
||||
import org.jetbrains.kotlin.codegen.context.ClassContext
|
||||
import org.jetbrains.kotlin.codegen.extensions.ExpressionCodegenExtension
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.descriptors.impl.ClassDescriptorImpl
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.parcelize.ParcelizeNames.NEW_ARRAY_NAME
|
||||
import org.jetbrains.kotlin.parcelize.ParcelizeNames.TYPE_PARCELER_FQ_NAMES
|
||||
import org.jetbrains.kotlin.parcelize.ParcelizeResolveExtension.Companion.createMethod
|
||||
import org.jetbrains.kotlin.parcelize.ParcelizeSyntheticComponent.ComponentKind.*
|
||||
import org.jetbrains.kotlin.parcelize.serializers.*
|
||||
@@ -426,14 +424,3 @@ open class ParcelizeCodegenExtension : ParcelizeExtensionBase, ExpressionCodegen
|
||||
.firstOrNull()
|
||||
}
|
||||
}
|
||||
|
||||
internal fun getTypeParcelers(annotations: Annotations): List<TypeParcelerMapping> {
|
||||
val serializers = mutableListOf<TypeParcelerMapping>()
|
||||
|
||||
for (annotation in annotations.filter { it.fqName in TYPE_PARCELER_FQ_NAMES }) {
|
||||
val (mappedType, parcelerType) = annotation.type.arguments.takeIf { it.size == 2 } ?: continue
|
||||
serializers += TypeParcelerMapping(mappedType.type, parcelerType.type)
|
||||
}
|
||||
|
||||
return serializers
|
||||
}
|
||||
+1
-1
@@ -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.
|
||||
*/
|
||||
|
||||
+1
-1
@@ -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.
|
||||
*/
|
||||
package org.jetbrains.kotlin.parcelize.ir
|
||||
+1
-1
@@ -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.
|
||||
*/
|
||||
package org.jetbrains.kotlin.parcelize.ir
|
||||
+1
-1
@@ -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.
|
||||
*/
|
||||
|
||||
+3
-2
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -36,7 +36,8 @@ fun AndroidIrBuilder.writeParcelWith(
|
||||
}
|
||||
|
||||
// Creates a serializer from a pair of parcel methods of the form reader()T and writer(T)V.
|
||||
class IrSimpleParcelSerializer(private val reader: IrSimpleFunctionSymbol, private val writer: IrSimpleFunctionSymbol) : IrParcelSerializer {
|
||||
class IrSimpleParcelSerializer(private val reader: IrSimpleFunctionSymbol, private val writer: IrSimpleFunctionSymbol) :
|
||||
IrParcelSerializer {
|
||||
override fun AndroidIrBuilder.readParcel(parcel: IrValueDeclaration): IrExpression {
|
||||
return irCall(reader).apply { dispatchReceiver = irGet(parcel) }
|
||||
}
|
||||
+1
-1
@@ -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.
|
||||
*/
|
||||
|
||||
+1
-1
@@ -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.
|
||||
*/
|
||||
|
||||
+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.
|
||||
*/
|
||||
|
||||
+1
-1
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
description = "Parcelize compiler plugin (CLI)"
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("jps-compatible")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(project(":plugins:parcelize:parcelize-compiler:parcelize.common"))
|
||||
api(project(":plugins:parcelize:parcelize-compiler:parcelize.k1"))
|
||||
api(project(":plugins:parcelize:parcelize-compiler:parcelize.k2"))
|
||||
api(project(":plugins:parcelize:parcelize-compiler:parcelize.backend"))
|
||||
|
||||
compileOnly(project(":compiler:plugin-api"))
|
||||
compileOnly(project(":compiler:backend"))
|
||||
compileOnly(project(":compiler:ir.backend.common"))
|
||||
compileOnly(intellijCore())
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
"main" { projectDefault() }
|
||||
"test" { none() }
|
||||
}
|
||||
|
||||
runtimeJar()
|
||||
javadocJar()
|
||||
sourcesJar()
|
||||
+5
-2
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -34,6 +34,9 @@ class ParcelizeComponentRegistrar : ComponentRegistrar {
|
||||
override fun registerProjectComponents(project: MockProject, configuration: CompilerConfiguration) {
|
||||
registerParcelizeComponents(project)
|
||||
}
|
||||
|
||||
override val supportsK2: Boolean
|
||||
get() = true
|
||||
}
|
||||
|
||||
class ParcelizeDeclarationCheckerComponentContainerContributor : StorageComponentContainerContributor {
|
||||
@@ -47,4 +50,4 @@ class ParcelizeDeclarationCheckerComponentContainerContributor : StorageComponen
|
||||
container.useInstance(ParcelizeAnnotationChecker())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
description = "Parcelize compiler plugin (Common)"
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("jps-compatible")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":compiler:util"))
|
||||
compileOnly(project(":core:compiler.common"))
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
"main" { projectDefault() }
|
||||
"test" { none() }
|
||||
}
|
||||
|
||||
runtimeJar()
|
||||
javadocJar()
|
||||
sourcesJar()
|
||||
+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.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
description = "Parcelize compiler plugin (Backend)"
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("jps-compatible")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(":plugins:parcelize:parcelize-compiler:parcelize.common"))
|
||||
|
||||
compileOnly(project(":compiler:util"))
|
||||
compileOnly(project(":compiler:frontend"))
|
||||
compileOnly(project(":compiler:frontend.java"))
|
||||
compileOnly(project(":compiler:backend")) // for KotlinTypeMapper
|
||||
compileOnly(intellijCore())
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
"main" { projectDefault() }
|
||||
"test" { none() }
|
||||
}
|
||||
|
||||
runtimeJar()
|
||||
javadocJar()
|
||||
sourcesJar()
|
||||
+12
@@ -36,6 +36,7 @@ import org.jetbrains.kotlin.parcelize.ParcelizeNames.PARCEL_ID
|
||||
import org.jetbrains.kotlin.parcelize.ParcelizeNames.WRITE_TO_PARCEL_NAME
|
||||
import org.jetbrains.kotlin.parcelize.ParcelizeSyntheticComponent.ComponentKind.DESCRIBE_CONTENTS
|
||||
import org.jetbrains.kotlin.parcelize.ParcelizeSyntheticComponent.ComponentKind.WRITE_TO_PARCEL
|
||||
import org.jetbrains.kotlin.parcelize.serializers.TypeParcelerMapping
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.*
|
||||
@@ -209,3 +210,14 @@ fun Annotated.hasAnyAnnotation(fqNames: List<FqName>): Boolean {
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
fun getTypeParcelers(annotations: Annotations): List<TypeParcelerMapping> {
|
||||
val serializers = mutableListOf<TypeParcelerMapping>()
|
||||
|
||||
for (annotation in annotations.filter { it.fqName in ParcelizeNames.TYPE_PARCELER_FQ_NAMES }) {
|
||||
val (mappedType, parcelerType) = annotation.type.arguments.takeIf { it.size == 2 } ?: continue
|
||||
serializers += TypeParcelerMapping(mappedType.type, parcelerType.type)
|
||||
}
|
||||
|
||||
return serializers
|
||||
}
|
||||
+2
-32
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* 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.kotlin.parcelize.serializers
|
||||
@@ -26,18 +15,15 @@ import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor
|
||||
import org.jetbrains.kotlin.load.kotlin.TypeMappingMode
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.parcelize.ParcelizeNames.PARCELABLE_FQN
|
||||
import org.jetbrains.kotlin.parcelize.ParcelizeNames.RAW_VALUE_ANNOTATION_FQ_NAMES
|
||||
import org.jetbrains.kotlin.parcelize.findAnyAnnotation
|
||||
import org.jetbrains.kotlin.parcelize.hasAnyAnnotation
|
||||
import org.jetbrains.kotlin.parcelize.isParcelize
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
import org.jetbrains.kotlin.resolve.source.PsiSourceElement
|
||||
import org.jetbrains.kotlin.synthetic.isVisibleOutside
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.isError
|
||||
import org.jetbrains.kotlin.types.typeUtil.builtIns
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
@@ -45,8 +31,6 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
import java.util.*
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
internal typealias TypeParcelerMapping = Pair<KotlinType, KotlinType>
|
||||
|
||||
interface ParcelSerializer {
|
||||
val asmType: Type
|
||||
|
||||
@@ -448,17 +432,3 @@ interface ParcelSerializer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal fun KotlinType.isParcelable() = matchesFqNameWithSupertypes(PARCELABLE_FQN.asString())
|
||||
|
||||
private fun KotlinType.matchesFqName(fqName: String): Boolean {
|
||||
return this.constructor.declarationDescriptor?.fqNameSafe?.asString() == fqName
|
||||
}
|
||||
|
||||
private fun KotlinType.matchesFqNameWithSupertypes(fqName: String): Boolean {
|
||||
if (this.matchesFqName(fqName)) {
|
||||
return true
|
||||
}
|
||||
|
||||
return TypeUtils.getAllSupertypes(this).any { it.matchesFqName(fqName) }
|
||||
}
|
||||
+7
-18
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* 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.kotlin.parcelize.serializers
|
||||
@@ -29,8 +18,8 @@ import org.jetbrains.org.objectweb.asm.Label
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
|
||||
internal val PARCEL_TYPE = Type.getObjectType("android/os/Parcel")
|
||||
internal val PARCELER_TYPE = Type.getObjectType("kotlinx/parcelize/Parceler")
|
||||
val PARCEL_TYPE = Type.getObjectType("android/os/Parcel")
|
||||
val PARCELER_TYPE = Type.getObjectType("kotlinx/parcelize/Parceler")
|
||||
|
||||
internal class GenericParcelSerializer(override val asmType: Type) : ParcelSerializer {
|
||||
override fun writeValue(v: InstructionAdapter) {
|
||||
@@ -482,7 +471,7 @@ internal class ObjectParcelSerializer(
|
||||
}
|
||||
}
|
||||
|
||||
internal class ZeroParameterClassSerializer(
|
||||
class ZeroParameterClassSerializer(
|
||||
override val asmType: Type,
|
||||
type: KotlinType
|
||||
) : ParcelSerializer {
|
||||
@@ -588,7 +577,7 @@ internal class GenericParcelableParcelSerializer(override val asmType: Type, pri
|
||||
}
|
||||
}
|
||||
|
||||
internal class NullAwareParcelSerializerWrapper(private val delegate: ParcelSerializer) : ParcelSerializer {
|
||||
class NullAwareParcelSerializerWrapper(private val delegate: ParcelSerializer) : ParcelSerializer {
|
||||
override val asmType: Type
|
||||
get() = delegate.asmType
|
||||
|
||||
@@ -845,4 +834,4 @@ internal class Method<out T : String?>(val name: String, val signature: T) {
|
||||
companion object {
|
||||
operator fun invoke(name: String) = Method(name, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2019 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.
|
||||
*/
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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.kotlin.parcelize.serializers
|
||||
|
||||
import org.jetbrains.kotlin.parcelize.ParcelizeNames
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
|
||||
typealias TypeParcelerMapping = Pair<KotlinType, KotlinType>
|
||||
|
||||
fun KotlinType.isParcelable() = matchesFqNameWithSupertypes(ParcelizeNames.PARCELABLE_FQN.asString())
|
||||
|
||||
fun KotlinType.matchesFqNameWithSupertypes(fqName: String): Boolean {
|
||||
if (this.matchesFqName(fqName)) {
|
||||
return true
|
||||
}
|
||||
|
||||
return TypeUtils.getAllSupertypes(this).any { it.matchesFqName(fqName) }
|
||||
}
|
||||
|
||||
fun KotlinType.matchesFqName(fqName: String): Boolean {
|
||||
return this.constructor.declarationDescriptor?.fqNameSafe?.asString() == fqName
|
||||
}
|
||||
+2
-6
@@ -1,4 +1,4 @@
|
||||
description = "Parcelize FIR compiler plugin"
|
||||
description = "Parcelize compiler plugin (Backend)"
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
@@ -6,9 +6,7 @@ plugins {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testApi(intellijCore())
|
||||
|
||||
compileOnly(project(":plugins:parcelize:parcelize-compiler"))
|
||||
implementation(project(":plugins:parcelize:parcelize-compiler:parcelize.common"))
|
||||
|
||||
compileOnly(intellijCore())
|
||||
compileOnly(project(":compiler:fir:cones"))
|
||||
@@ -16,7 +14,6 @@ dependencies {
|
||||
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.backend.common"))
|
||||
compileOnly(project(":compiler:ir.tree.impl"))
|
||||
compileOnly(project(":compiler:fir:entrypoint"))
|
||||
@@ -28,7 +25,6 @@ sourceSets {
|
||||
"test" { none() }
|
||||
}
|
||||
|
||||
|
||||
runtimeJar()
|
||||
javadocJar()
|
||||
sourcesJar()
|
||||
@@ -111,7 +111,6 @@ val distCompilerPluginProjects = listOf(
|
||||
":kotlin-allopen-compiler-plugin",
|
||||
":kotlin-android-extensions-runtime",
|
||||
":plugins:parcelize:parcelize-compiler",
|
||||
":plugins:parcelize:parcelize-compiler:parcelize-fir",
|
||||
":plugins:parcelize:parcelize-runtime",
|
||||
":kotlin-noarg-compiler-plugin",
|
||||
":kotlin-sam-with-receiver-compiler-plugin",
|
||||
|
||||
+5
-1
@@ -339,7 +339,11 @@ include ":compiler:test-infrastructure",
|
||||
":compiler:tests-common-new"
|
||||
|
||||
include ":plugins:parcelize:parcelize-compiler",
|
||||
":plugins:parcelize:parcelize-compiler:parcelize-fir",
|
||||
":plugins:parcelize:parcelize-compiler:parcelize.common",
|
||||
":plugins:parcelize:parcelize-compiler:parcelize.k1",
|
||||
":plugins:parcelize:parcelize-compiler:parcelize.k2",
|
||||
":plugins:parcelize:parcelize-compiler:parcelize.backend",
|
||||
":plugins:parcelize:parcelize-compiler:parcelize.cli",
|
||||
":plugins:parcelize:parcelize-runtime",
|
||||
":kotlin-parcelize-compiler"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user