Delete sources of parcelize IDE plugin
They are moved to intellij community repo, so those sources in kotlin repository are actually redundant
This commit is contained in:
committed by
teamcityserver
parent
b0f38bd996
commit
a093052b77
@@ -1,53 +0,0 @@
|
|||||||
description = "IDE support for the Parcelize compiler plugin"
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
kotlin("jvm")
|
|
||||||
id("jps-compatible")
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
compile(project(":compiler:util"))
|
|
||||||
compile(project(":compiler:plugin-api"))
|
|
||||||
compile(project(":compiler:frontend"))
|
|
||||||
compile(project(":compiler:frontend.java"))
|
|
||||||
compile(project(":compiler:light-classes"))
|
|
||||||
compile(project(":idea"))
|
|
||||||
compile(project(":idea:idea-gradle"))
|
|
||||||
compile(project(":plugins:parcelize:parcelize-compiler"))
|
|
||||||
compile(project(":plugins:parcelize:parcelize-runtime"))
|
|
||||||
|
|
||||||
compile(intellijDep())
|
|
||||||
compile(intellijPluginDep("gradle"))
|
|
||||||
compileOnly(intellijPluginDep("java")) { includeJars("java-api", "java-impl") }
|
|
||||||
|
|
||||||
testApi(projectTests(":idea"))
|
|
||||||
testApi(projectTests(":plugins:parcelize:parcelize-compiler"))
|
|
||||||
|
|
||||||
testRuntime(project(":allopen-ide-plugin"))
|
|
||||||
testRuntime(project(":noarg-ide-plugin"))
|
|
||||||
testRuntime(project(":kotlin-scripting-idea")) { isTransitive = false }
|
|
||||||
testRuntime(project(":kotlin-scripting-compiler-impl"))
|
|
||||||
testRuntime(project(":sam-with-receiver-ide-plugin"))
|
|
||||||
testRuntime(project(":kotlinx-serialization-ide-plugin"))
|
|
||||||
|
|
||||||
testRuntime(toolsJar())
|
|
||||||
|
|
||||||
testRuntimeOnly(intellijPluginDep("java"))
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceSets {
|
|
||||||
"main" { projectDefault() }
|
|
||||||
"test" { projectDefault() }
|
|
||||||
}
|
|
||||||
|
|
||||||
runtimeJar()
|
|
||||||
javadocJar()
|
|
||||||
sourcesJar()
|
|
||||||
|
|
||||||
testsJar {}
|
|
||||||
|
|
||||||
projectTest(parallel = true) {
|
|
||||||
dependsOn(":dist")
|
|
||||||
workingDir = rootDir
|
|
||||||
useAndroidJar()
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
parcelize.fix.annotate.containing.class.with.parcelize=Annotate containing class with ''@Parcelize''
|
|
||||||
parcelize.fix.add.ignored.on.parcel.annotation=Add ''@IgnoredOnParcel'' annotation
|
|
||||||
parcelize.fix.add.empty.primary.constructor=Add empty primary constructor
|
|
||||||
parcelize.fix.add.parcelable.supertype=Add ''Parcelable'' supertype
|
|
||||||
parcelize.fix.remove.redundant.type.parceler.annotation=Remove redundant ''@TypeParceler'' annotation
|
|
||||||
parcelize.fix.migrate.to.parceler.companion.object=Migrate to ''Parceler'' companion object
|
|
||||||
parcelize.fix.remove.custom.creator.property=Remove custom ''CREATOR'' property
|
|
||||||
parcelize.fix.remove.custom.write.to.parcel.function=Remove custom ''writeToParcel()'' function
|
|
||||||
-21
@@ -1,21 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2020 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.ide
|
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement
|
|
||||||
import org.jetbrains.kotlin.parcelize.ParcelizeAnnotationChecker
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.checkers.CallCheckerContext
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
|
||||||
|
|
||||||
class IdeParcelizeAnnotationChecker : ParcelizeAnnotationChecker() {
|
|
||||||
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
|
|
||||||
if (!ParcelizeAvailability.isAvailable(resolvedCall.call.callElement)) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
super.check(resolvedCall, reportOn, context)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-15
@@ -1,15 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2020 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.ide
|
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement
|
|
||||||
import org.jetbrains.kotlin.parcelize.ParcelizeCodegenExtension
|
|
||||||
|
|
||||||
class IdeParcelizeCodegenExtension : ParcelizeCodegenExtension() {
|
|
||||||
override fun isAvailable(element: PsiElement): Boolean {
|
|
||||||
return ParcelizeAvailability.isAvailable(element)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-21
@@ -1,21 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2020 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.ide
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
|
||||||
import org.jetbrains.kotlin.parcelize.ParcelizeDeclarationChecker
|
|
||||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
|
||||||
import org.jetbrains.kotlin.resolve.checkers.DeclarationCheckerContext
|
|
||||||
|
|
||||||
class IdeParcelizeDeclarationChecker : ParcelizeDeclarationChecker() {
|
|
||||||
override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) {
|
|
||||||
if (!ParcelizeAvailability.isAvailable(declaration)) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
super.check(declaration, descriptor, context)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-26
@@ -1,26 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2020 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.ide
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.container.StorageComponentContainer
|
|
||||||
import org.jetbrains.kotlin.container.useInstance
|
|
||||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
|
||||||
import org.jetbrains.kotlin.extensions.StorageComponentContainerContributor
|
|
||||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
|
||||||
import org.jetbrains.kotlin.platform.jvm.isJvm
|
|
||||||
|
|
||||||
class IdeParcelizeDeclarationCheckerComponentContainerContributor : StorageComponentContainerContributor {
|
|
||||||
override fun registerModuleComponents(
|
|
||||||
container: StorageComponentContainer,
|
|
||||||
platform: TargetPlatform,
|
|
||||||
moduleDescriptor: ModuleDescriptor,
|
|
||||||
) {
|
|
||||||
if (platform.isJvm()) {
|
|
||||||
container.useInstance(IdeParcelizeDeclarationChecker())
|
|
||||||
container.useInstance(IdeParcelizeAnnotationChecker())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-15
@@ -1,15 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2020 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.ide
|
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement
|
|
||||||
import org.jetbrains.kotlin.parcelize.ParcelizeResolveExtension
|
|
||||||
|
|
||||||
class IdeParcelizeResolveExtension : ParcelizeResolveExtension() {
|
|
||||||
override fun isAvailable(element: PsiElement): Boolean {
|
|
||||||
return ParcelizeAvailability.isAvailable(element)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-20
@@ -1,20 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2020 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.ide
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NonNls
|
|
||||||
import org.jetbrains.annotations.PropertyKey
|
|
||||||
import org.jetbrains.kotlin.util.AbstractKotlinBundle
|
|
||||||
|
|
||||||
@NonNls
|
|
||||||
private const val BUNDLE = "messages.KotlinParcelizeBundle"
|
|
||||||
|
|
||||||
object KotlinParcelizeBundle : AbstractKotlinBundle(BUNDLE) {
|
|
||||||
@JvmStatic
|
|
||||||
fun message(@NonNls @PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any): String =
|
|
||||||
@Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
|
|
||||||
getMessage(key, *params)
|
|
||||||
}
|
|
||||||
-37
@@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2020 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.ide
|
|
||||||
|
|
||||||
import com.intellij.openapi.application.ApplicationManager
|
|
||||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil
|
|
||||||
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil
|
|
||||||
import com.intellij.openapi.module.Module
|
|
||||||
import com.intellij.psi.PsiElement
|
|
||||||
import org.jetbrains.kotlin.idea.util.module
|
|
||||||
import org.jetbrains.plugins.gradle.service.project.GradleProjectResolverUtil
|
|
||||||
import org.jetbrains.plugins.gradle.util.GradleConstants
|
|
||||||
|
|
||||||
object ParcelizeAvailability {
|
|
||||||
fun isAvailable(element: PsiElement): Boolean {
|
|
||||||
if (ApplicationManager.getApplication().isUnitTestMode) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
val module = element.module ?: return false
|
|
||||||
return isAvailable(module)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun isAvailable(module: Module): Boolean {
|
|
||||||
if (ApplicationManager.getApplication().isUnitTestMode) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
val path = ExternalSystemApiUtil.getExternalProjectPath(module) ?: return false
|
|
||||||
val externalProjectInfo = ExternalSystemUtil.getExternalProjectInfo(module.project, GradleConstants.SYSTEM_ID, path) ?: return false
|
|
||||||
val moduleData = GradleProjectResolverUtil.findModule(externalProjectInfo.externalProjectStructure, path) ?: return false
|
|
||||||
return ExternalSystemApiUtil.find(moduleData, ParcelizeIdeModel.KEY)?.data?.isEnabled ?: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-46
@@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2020 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.ide
|
|
||||||
|
|
||||||
import com.intellij.openapi.externalSystem.model.DataNode
|
|
||||||
import com.intellij.openapi.externalSystem.model.Key
|
|
||||||
import com.intellij.openapi.externalSystem.model.ProjectKeys
|
|
||||||
import com.intellij.openapi.externalSystem.model.project.AbstractExternalEntityData
|
|
||||||
import com.intellij.openapi.externalSystem.model.project.ModuleData
|
|
||||||
import com.intellij.openapi.externalSystem.service.project.manage.AbstractProjectDataService
|
|
||||||
import com.intellij.serialization.PropertyMapping
|
|
||||||
import org.gradle.tooling.model.idea.IdeaModule
|
|
||||||
import org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension
|
|
||||||
import org.jetbrains.plugins.gradle.util.GradleConstants
|
|
||||||
|
|
||||||
class ParcelizeIdeModel @PropertyMapping("isEnabled") constructor(
|
|
||||||
val isEnabled: Boolean
|
|
||||||
) : AbstractExternalEntityData(GradleConstants.SYSTEM_ID) {
|
|
||||||
companion object {
|
|
||||||
val KEY = Key.create(ParcelizeIdeModel::class.java, ProjectKeys.CONTENT_ROOT.processingWeight + 1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ParcelizeIdeModelDataService : AbstractProjectDataService<ParcelizeIdeModel, Void>() {
|
|
||||||
override fun getTargetDataKey() = ParcelizeIdeModel.KEY
|
|
||||||
}
|
|
||||||
|
|
||||||
@Suppress("unused")
|
|
||||||
class ParcelizeProjectResolverExtension : AbstractProjectResolverExtension() {
|
|
||||||
override fun getExtraProjectModelClasses() = setOf(ParcelizeGradleModel::class.java)
|
|
||||||
override fun getToolingExtensionsClasses() = setOf(ParcelizeModelBuilderService::class.java, Unit::class.java)
|
|
||||||
|
|
||||||
override fun populateModuleExtraModels(gradleModule: IdeaModule, ideModule: DataNode<ModuleData>) {
|
|
||||||
val parcelizeModel = resolverCtx.getExtraProject(gradleModule, ParcelizeGradleModel::class.java)
|
|
||||||
|
|
||||||
if (parcelizeModel != null && parcelizeModel.isEnabled) {
|
|
||||||
ideModule.createChild(ParcelizeIdeModel.KEY, ParcelizeIdeModel(isEnabled = parcelizeModel.isEnabled))
|
|
||||||
}
|
|
||||||
|
|
||||||
super.populateModuleExtraModels(gradleModule, ideModule)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
-95
@@ -1,95 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2019 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.ide
|
|
||||||
|
|
||||||
import com.intellij.psi.impl.light.LightFieldBuilder
|
|
||||||
import org.jetbrains.kotlin.parcelize.serializers.ParcelizeExtensionBase
|
|
||||||
import org.jetbrains.kotlin.asJava.UltraLightClassModifierExtension
|
|
||||||
import org.jetbrains.kotlin.asJava.classes.KtUltraLightClass
|
|
||||||
import org.jetbrains.kotlin.asJava.classes.createGeneratedMethodFromDescriptor
|
|
||||||
import org.jetbrains.kotlin.asJava.elements.KtLightField
|
|
||||||
import org.jetbrains.kotlin.asJava.elements.KtLightFieldImpl
|
|
||||||
import org.jetbrains.kotlin.asJava.elements.KtLightMethod
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
|
||||||
import org.jetbrains.kotlin.idea.util.module
|
|
||||||
import org.jetbrains.kotlin.parcelize.ParcelizeSyntheticComponent
|
|
||||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
|
||||||
import org.jetbrains.kotlin.util.isAnnotated
|
|
||||||
import org.jetbrains.kotlin.util.isOrdinaryClass
|
|
||||||
|
|
||||||
class ParcelizeUltraLightClassModifierExtension : ParcelizeExtensionBase, UltraLightClassModifierExtension {
|
|
||||||
private fun tryGetParcelizeClass(declaration: KtDeclaration, descriptor: Lazy<DeclarationDescriptor?>): ClassDescriptor? {
|
|
||||||
if (!declaration.isOrdinaryClass || !declaration.isAnnotated) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
val module = declaration.module
|
|
||||||
if (module == null || !ParcelizeAvailability.isAvailable(module)) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
val descriptorValue = descriptor.value ?: return null
|
|
||||||
val parcelizeClass = (descriptorValue as? ClassDescriptor) ?: descriptorValue.containingDeclaration as? ClassDescriptor
|
|
||||||
|
|
||||||
if (parcelizeClass == null || !parcelizeClass.isParcelizeClassDescriptor) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
return parcelizeClass
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun interceptFieldsBuilding(
|
|
||||||
declaration: KtDeclaration,
|
|
||||||
descriptor: Lazy<DeclarationDescriptor?>,
|
|
||||||
containingDeclaration: KtUltraLightClass,
|
|
||||||
fieldsList: MutableList<KtLightField>
|
|
||||||
) {
|
|
||||||
val parcelizeClass = tryGetParcelizeClass(declaration, descriptor) ?: return
|
|
||||||
if (parcelizeClass.hasCreatorField()) return
|
|
||||||
|
|
||||||
val fieldWrapper = KtLightFieldImpl.KtLightFieldForSourceDeclaration(
|
|
||||||
origin = null,
|
|
||||||
computeDelegate = {
|
|
||||||
LightFieldBuilder("CREATOR", "android.os.Parcelable.Creator", containingDeclaration).also {
|
|
||||||
it.setModifiers("public", "static", "final")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
containingClass = containingDeclaration,
|
|
||||||
dummyDelegate = null
|
|
||||||
)
|
|
||||||
|
|
||||||
fieldsList.add(fieldWrapper)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun interceptMethodsBuilding(
|
|
||||||
declaration: KtDeclaration,
|
|
||||||
descriptor: Lazy<DeclarationDescriptor?>,
|
|
||||||
containingDeclaration: KtUltraLightClass,
|
|
||||||
methodsList: MutableList<KtLightMethod>
|
|
||||||
) {
|
|
||||||
val parcelizeClass = tryGetParcelizeClass(declaration, descriptor) ?: return
|
|
||||||
|
|
||||||
with(parcelizeClass) {
|
|
||||||
if (hasSyntheticDescribeContents()) {
|
|
||||||
findFunction(ParcelizeSyntheticComponent.ComponentKind.DESCRIBE_CONTENTS)?.let {
|
|
||||||
methodsList.add(
|
|
||||||
containingDeclaration.createGeneratedMethodFromDescriptor(it)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasSyntheticWriteToParcel()) {
|
|
||||||
findFunction(ParcelizeSyntheticComponent.ComponentKind.WRITE_TO_PARCEL)?.let {
|
|
||||||
methodsList.add(
|
|
||||||
containingDeclaration.createGeneratedMethodFromDescriptor(it)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-53
@@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.parcelize.ide.quickfixes
|
|
||||||
|
|
||||||
import com.intellij.codeInsight.intention.IntentionAction
|
|
||||||
import com.intellij.openapi.editor.Editor
|
|
||||||
import com.intellij.openapi.project.Project
|
|
||||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
|
||||||
import org.jetbrains.kotlin.idea.core.ShortenReferences
|
|
||||||
import org.jetbrains.kotlin.idea.quickfix.KotlinQuickFixAction
|
|
||||||
import org.jetbrains.kotlin.idea.quickfix.KotlinSingleIntentionActionFactory
|
|
||||||
import org.jetbrains.kotlin.psi.KtElement
|
|
||||||
import org.jetbrains.kotlin.psi.KtFile
|
|
||||||
import org.jetbrains.kotlin.psi.KtPsiFactory
|
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
|
|
||||||
|
|
||||||
abstract class AbstractParcelizeQuickFix<T : KtElement>(element: T) : KotlinQuickFixAction<T>(element) {
|
|
||||||
protected companion object {
|
|
||||||
fun <T : KtElement> T.shortenReferences() = ShortenReferences.DEFAULT.process(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getFamilyName() = text
|
|
||||||
|
|
||||||
abstract fun invoke(ktPsiFactory: KtPsiFactory, element: T)
|
|
||||||
|
|
||||||
final override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
|
||||||
val clazz = element ?: return
|
|
||||||
val ktPsiFactory = KtPsiFactory(project, markGenerated = true)
|
|
||||||
invoke(ktPsiFactory, clazz)
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class AbstractFactory(private val f: Diagnostic.() -> IntentionAction?) : KotlinSingleIntentionActionFactory() {
|
|
||||||
companion object {
|
|
||||||
inline fun <reified T : KtElement> Diagnostic.findElement() = psiElement.getNonStrictParentOfType<T>()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun createAction(diagnostic: Diagnostic) = f(diagnostic)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-40
@@ -1,40 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.parcelize.ide.quickfixes
|
|
||||||
|
|
||||||
import kotlinx.parcelize.Parcelize
|
|
||||||
import org.jetbrains.kotlin.idea.util.addAnnotation
|
|
||||||
import org.jetbrains.kotlin.name.FqName
|
|
||||||
import org.jetbrains.kotlin.parcelize.diagnostic.ErrorsParcelize
|
|
||||||
import org.jetbrains.kotlin.parcelize.ide.KotlinParcelizeBundle
|
|
||||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
|
||||||
import org.jetbrains.kotlin.psi.KtPsiFactory
|
|
||||||
|
|
||||||
class AnnotateWithParcelizeQuickFix(clazz: KtClassOrObject) : AbstractParcelizeQuickFix<KtClassOrObject>(clazz) {
|
|
||||||
object Factory : AbstractFactory(
|
|
||||||
{
|
|
||||||
val targetClass = ErrorsParcelize.CLASS_SHOULD_BE_PARCELIZE.cast(this).a
|
|
||||||
AnnotateWithParcelizeQuickFix(targetClass)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
override fun getText() = KotlinParcelizeBundle.message("parcelize.fix.annotate.containing.class.with.parcelize")
|
|
||||||
|
|
||||||
override fun invoke(ktPsiFactory: KtPsiFactory, element: KtClassOrObject) {
|
|
||||||
element.addAnnotation(FqName(Parcelize::class.java.name))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-291
@@ -1,291 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.parcelize.ide.quickfixes
|
|
||||||
|
|
||||||
import com.intellij.openapi.diagnostic.Logger
|
|
||||||
import kotlinx.parcelize.Parceler
|
|
||||||
import org.jetbrains.kotlin.parcelize.ANDROID_PARCELABLE_CREATOR_CLASS_FQNAME
|
|
||||||
import org.jetbrains.kotlin.parcelize.ANDROID_PARCEL_CLASS_FQNAME
|
|
||||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
|
||||||
import org.jetbrains.kotlin.builtins.StandardNames
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.resolveToCall
|
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
|
|
||||||
import org.jetbrains.kotlin.idea.core.getOrCreateCompanionObject
|
|
||||||
import org.jetbrains.kotlin.idea.intentions.branchedTransformations.unwrapBlockOrParenthesis
|
|
||||||
import org.jetbrains.kotlin.idea.util.findAnnotation
|
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens
|
|
||||||
import org.jetbrains.kotlin.load.java.JvmAbi.JVM_FIELD_ANNOTATION_FQ_NAME
|
|
||||||
import org.jetbrains.kotlin.name.FqName
|
|
||||||
import org.jetbrains.kotlin.name.Name
|
|
||||||
import org.jetbrains.kotlin.parcelize.ide.KotlinParcelizeBundle
|
|
||||||
import org.jetbrains.kotlin.psi.*
|
|
||||||
import org.jetbrains.kotlin.psi.addRemoveModifier.setModifierList
|
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.containingClass
|
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject
|
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
|
||||||
import org.jetbrains.kotlin.psi.typeRefHelpers.setReceiverTypeReference
|
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.getAllSuperClassifiers
|
|
||||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
|
||||||
import org.jetbrains.kotlin.resolve.source.KotlinSourceElement
|
|
||||||
import org.jetbrains.kotlin.types.TypeUtils
|
|
||||||
|
|
||||||
class ParcelMigrateToParcelizeQuickFix(function: KtClass) : AbstractParcelizeQuickFix<KtClass>(function) {
|
|
||||||
companion object {
|
|
||||||
private val PARCELER_FQNAME = FqName(Parceler::class.java.name)
|
|
||||||
private val PARCELER_WRITE_FUNCTION_NAME = Name.identifier("write")
|
|
||||||
private val PARCELER_CREATE_FUNCTION_NAME = Name.identifier("create")
|
|
||||||
private val LOG = Logger.getInstance(ParcelMigrateToParcelizeQuickFix::class.java)
|
|
||||||
|
|
||||||
private fun KtClass.findParcelerCompanionObject(): Pair<KtObjectDeclaration, ClassDescriptor>? {
|
|
||||||
for (obj in companionObjects) {
|
|
||||||
val objDescriptor = obj.resolveToDescriptorIfAny() ?: continue
|
|
||||||
for (superClassifier in objDescriptor.getAllSuperClassifiers()) {
|
|
||||||
val superClass = superClassifier as? ClassDescriptor ?: continue
|
|
||||||
if (superClass.fqNameSafe == PARCELER_FQNAME) return Pair(obj, objDescriptor)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun KtNamedFunction.doesLookLikeWriteToParcelOverride(): Boolean {
|
|
||||||
return name == "writeToParcel"
|
|
||||||
&& hasModifier(KtTokens.OVERRIDE_KEYWORD)
|
|
||||||
&& receiverTypeReference == null
|
|
||||||
&& valueParameters.size == 2
|
|
||||||
&& typeParameters.size == 0
|
|
||||||
&& valueParameters[0].typeReference?.getFqName() == ANDROID_PARCEL_CLASS_FQNAME.asString()
|
|
||||||
&& valueParameters[1].typeReference?.getFqName() == StandardNames.FqNames._int.asString()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun KtNamedFunction.doesLookLikeNewArrayOverride(): Boolean {
|
|
||||||
return name == "newArray"
|
|
||||||
&& hasModifier(KtTokens.OVERRIDE_KEYWORD)
|
|
||||||
&& receiverTypeReference == null
|
|
||||||
&& valueParameters.size == 1
|
|
||||||
&& typeParameters.size == 0
|
|
||||||
&& valueParameters[0].typeReference?.getFqName() == StandardNames.FqNames._int.asString()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun KtNamedFunction.doesLookLikeDescribeContentsOverride(): Boolean {
|
|
||||||
return name == "describeContents"
|
|
||||||
&& hasModifier(KtTokens.OVERRIDE_KEYWORD)
|
|
||||||
&& receiverTypeReference == null
|
|
||||||
&& valueParameters.size == 0
|
|
||||||
&& typeParameters.size == 0
|
|
||||||
&& typeReference?.getFqName() == StandardNames.FqNames._int.asString()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun KtClass.findWriteToParcelOverride() = findFunction { doesLookLikeWriteToParcelOverride() }
|
|
||||||
private fun KtClass.findDescribeContentsOverride() = findFunction { doesLookLikeDescribeContentsOverride() }
|
|
||||||
private fun KtObjectDeclaration.findNewArrayOverride() = findFunction { doesLookLikeNewArrayOverride() }
|
|
||||||
|
|
||||||
private fun KtClass.findCreatorClass(): KtClassOrObject? {
|
|
||||||
for (companion in companionObjects) {
|
|
||||||
if (companion.name == "CREATOR") {
|
|
||||||
return companion
|
|
||||||
}
|
|
||||||
|
|
||||||
val creatorProperty = companion.declarations.asSequence()
|
|
||||||
.filterIsInstance<KtProperty>()
|
|
||||||
.firstOrNull { it.name == "CREATOR" }
|
|
||||||
?: continue
|
|
||||||
|
|
||||||
creatorProperty.findAnnotation(JVM_FIELD_ANNOTATION_FQ_NAME) ?: continue
|
|
||||||
|
|
||||||
val initializer = creatorProperty.initializer ?: continue
|
|
||||||
when (initializer) {
|
|
||||||
is KtObjectLiteralExpression -> return initializer.objectDeclaration
|
|
||||||
is KtCallExpression -> {
|
|
||||||
val constructedClass = (initializer.resolveToCall()
|
|
||||||
?.resultingDescriptor as? ConstructorDescriptor)?.constructedClass
|
|
||||||
if (constructedClass != null) {
|
|
||||||
val sourceElement = constructedClass.source as? KotlinSourceElement
|
|
||||||
(sourceElement?.psi as? KtClassOrObject)?.let { return it }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun KtNamedFunction.doesLookLikeCreateFromParcelOverride(): Boolean {
|
|
||||||
return name == "createFromParcel"
|
|
||||||
&& hasModifier(KtTokens.OVERRIDE_KEYWORD)
|
|
||||||
&& receiverTypeReference == null
|
|
||||||
&& valueParameters.size == 1
|
|
||||||
&& typeParameters.size == 0
|
|
||||||
&& valueParameters[0].typeReference?.getFqName() == ANDROID_PARCEL_CLASS_FQNAME.asString()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun findCreateFromParcel(creator: KtClassOrObject) = creator.findFunction { doesLookLikeCreateFromParcelOverride() }
|
|
||||||
|
|
||||||
private fun KtNamedFunction.doesLookLikeWriteImplementation(): Boolean {
|
|
||||||
val containingParcelableClassFqName = containingClassOrObject?.containingClass()?.fqName?.asString()
|
|
||||||
|
|
||||||
return name == PARCELER_WRITE_FUNCTION_NAME.asString()
|
|
||||||
&& hasModifier(KtTokens.OVERRIDE_KEYWORD)
|
|
||||||
&& receiverTypeReference?.getFqName() == containingParcelableClassFqName
|
|
||||||
&& valueParameters.size == 2
|
|
||||||
&& typeParameters.size == 0
|
|
||||||
&& valueParameters[0].typeReference?.getFqName() == ANDROID_PARCEL_CLASS_FQNAME.asString()
|
|
||||||
&& valueParameters[1].typeReference?.getFqName() == StandardNames.FqNames._int.asString()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun KtNamedFunction.doesLookLikeCreateImplementation(): Boolean {
|
|
||||||
return name == PARCELER_CREATE_FUNCTION_NAME.asString()
|
|
||||||
&& hasModifier(KtTokens.OVERRIDE_KEYWORD)
|
|
||||||
&& receiverTypeReference == null
|
|
||||||
&& valueParameters.size == 1
|
|
||||||
&& typeParameters.size == 0
|
|
||||||
&& valueParameters[0].typeReference?.getFqName() == ANDROID_PARCEL_CLASS_FQNAME.asString()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun KtObjectDeclaration.findCreateImplementation() = findFunction { doesLookLikeCreateImplementation() }
|
|
||||||
private fun KtObjectDeclaration.findWriteImplementation() = findFunction { doesLookLikeWriteImplementation() }
|
|
||||||
|
|
||||||
private fun KtClassOrObject.findFunction(f: KtNamedFunction.() -> Boolean) =
|
|
||||||
declarations.asSequence().filterIsInstance<KtNamedFunction>().firstOrNull(f)
|
|
||||||
|
|
||||||
private fun KtTypeReference.getFqName(): String? = analyze(BodyResolveMode.PARTIAL)[BindingContext.TYPE, this]
|
|
||||||
?.constructor?.declarationDescriptor?.fqNameSafe?.asString()
|
|
||||||
}
|
|
||||||
|
|
||||||
object FactoryForWrite : AbstractFactory({ findElement<KtClass>()?.let { ParcelMigrateToParcelizeQuickFix(it) } })
|
|
||||||
|
|
||||||
object FactoryForCREATOR : AbstractFactory({
|
|
||||||
findElement<KtObjectDeclaration>()?.getStrictParentOfType<KtClass>()
|
|
||||||
?.let { ParcelMigrateToParcelizeQuickFix(it) }
|
|
||||||
})
|
|
||||||
|
|
||||||
override fun getText() = KotlinParcelizeBundle.message("parcelize.fix.migrate.to.parceler.companion.object")
|
|
||||||
|
|
||||||
@Suppress("PARAMETER_NAME_CHANGED_ON_OVERRIDE")
|
|
||||||
override fun invoke(ktPsiFactory: KtPsiFactory, parcelableClass: KtClass) {
|
|
||||||
val parcelerObject = parcelableClass.findParcelerCompanionObject()?.first ?: parcelableClass.getOrCreateCompanionObject()
|
|
||||||
val bindingContext = parcelerObject.analyze(BodyResolveMode.PARTIAL)
|
|
||||||
|
|
||||||
val parcelerTypeArg = parcelableClass.name ?: run {
|
|
||||||
LOG.error("Parceler class should not be an anonymous class")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
val parcelerObjectDescriptor = bindingContext[BindingContext.CLASS, parcelerObject] ?: run {
|
|
||||||
LOG.error("Unable to resolve parceler object for ${parcelableClass.name ?: "<unnamed Parcelable class>"}")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!parcelerObjectDescriptor.getAllSuperClassifiers().any { it.fqNameSafe == PARCELER_FQNAME }) {
|
|
||||||
val entryText = PARCELER_FQNAME.asString() + "<" + parcelerTypeArg + ">"
|
|
||||||
parcelerObject.addSuperTypeListEntry(ktPsiFactory.createSuperTypeEntry(entryText)).shortenReferences()
|
|
||||||
}
|
|
||||||
|
|
||||||
val oldWriteToParcelFunction = parcelableClass.findWriteToParcelOverride()
|
|
||||||
val oldCreateFromParcelFunction = parcelableClass.findCreatorClass()?.let { findCreateFromParcel(it) }
|
|
||||||
|
|
||||||
for (superTypeEntry in parcelerObject.superTypeListEntries) {
|
|
||||||
val superClass =
|
|
||||||
bindingContext[BindingContext.TYPE, superTypeEntry.typeReference]?.constructor?.declarationDescriptor ?: continue
|
|
||||||
if (superClass.getAllSuperClassifiers().any { it.fqNameSafe == ANDROID_PARCELABLE_CREATOR_CLASS_FQNAME }) {
|
|
||||||
parcelerObject.removeSuperTypeListEntry(superTypeEntry)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parcelerObject.name == "CREATOR") {
|
|
||||||
parcelerObject.nameIdentifier?.delete()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (oldWriteToParcelFunction != null) {
|
|
||||||
parcelerObject.findWriteImplementation()?.delete() // Remove old implementation
|
|
||||||
|
|
||||||
val newFunction = oldWriteToParcelFunction.copy() as KtFunction
|
|
||||||
oldWriteToParcelFunction.delete()
|
|
||||||
|
|
||||||
newFunction.setName(PARCELER_WRITE_FUNCTION_NAME.asString())
|
|
||||||
newFunction.setModifierList(ktPsiFactory.createModifierList(KtTokens.OVERRIDE_KEYWORD))
|
|
||||||
newFunction.setReceiverTypeReference(ktPsiFactory.createType(parcelerTypeArg))
|
|
||||||
newFunction.valueParameterList?.apply {
|
|
||||||
assert(parameters.size == 2)
|
|
||||||
val parcelParameterName = parameters[0].name ?: "parcel"
|
|
||||||
val flagsParameterName = parameters[1].name ?: "flags"
|
|
||||||
|
|
||||||
repeat(parameters.size) { removeParameter(0) }
|
|
||||||
addParameter(ktPsiFactory.createParameter("$parcelParameterName : ${ANDROID_PARCEL_CLASS_FQNAME.asString()}"))
|
|
||||||
addParameter(ktPsiFactory.createParameter("$flagsParameterName : Int"))
|
|
||||||
}
|
|
||||||
|
|
||||||
parcelerObject.addDeclaration(newFunction).valueParameterList?.shortenReferences()
|
|
||||||
} else if (parcelerObject.findWriteImplementation() == null) {
|
|
||||||
val writeFunction = "fun $parcelerTypeArg.write(parcel: ${ANDROID_PARCEL_CLASS_FQNAME.asString()}, flags: Int) = TODO()"
|
|
||||||
parcelerObject.addDeclaration(ktPsiFactory.createFunction(writeFunction)).valueParameterList?.shortenReferences()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (oldCreateFromParcelFunction != null) {
|
|
||||||
parcelerObject.findCreateImplementation()?.delete() // Remove old implementation
|
|
||||||
|
|
||||||
val newFunction = oldCreateFromParcelFunction.copy() as KtFunction
|
|
||||||
if (oldCreateFromParcelFunction.containingClassOrObject == parcelerObject) {
|
|
||||||
oldCreateFromParcelFunction.delete()
|
|
||||||
}
|
|
||||||
|
|
||||||
newFunction.setName(PARCELER_CREATE_FUNCTION_NAME.asString())
|
|
||||||
newFunction.setModifierList(ktPsiFactory.createModifierList(KtTokens.OVERRIDE_KEYWORD))
|
|
||||||
newFunction.setReceiverTypeReference(null)
|
|
||||||
newFunction.valueParameterList?.apply {
|
|
||||||
assert(parameters.size == 1)
|
|
||||||
val parcelParameterName = parameters[0].name ?: "parcel"
|
|
||||||
|
|
||||||
removeParameter(0)
|
|
||||||
addParameter(ktPsiFactory.createParameter("$parcelParameterName : ${ANDROID_PARCEL_CLASS_FQNAME.asString()}"))
|
|
||||||
}
|
|
||||||
|
|
||||||
parcelerObject.addDeclaration(newFunction).valueParameterList?.shortenReferences()
|
|
||||||
} else if (parcelerObject.findCreateImplementation() == null) {
|
|
||||||
val createFunction = "override fun create(parcel: ${ANDROID_PARCEL_CLASS_FQNAME.asString()}): $parcelerTypeArg = TODO()"
|
|
||||||
parcelerObject.addDeclaration(ktPsiFactory.createFunction(createFunction)).valueParameterList?.shortenReferences()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Always use the default newArray() implementation
|
|
||||||
parcelerObject.findNewArrayOverride()?.delete()
|
|
||||||
|
|
||||||
parcelableClass.findDescribeContentsOverride()?.let { describeContentsFunction ->
|
|
||||||
val returnExpr = describeContentsFunction.bodyExpression?.unwrapBlockOrParenthesis()
|
|
||||||
if (returnExpr is KtReturnExpression && returnExpr.getTargetLabel() == null) {
|
|
||||||
val returnValue = returnExpr.analyze()[BindingContext.COMPILE_TIME_VALUE, returnExpr.returnedExpression]
|
|
||||||
?.getValue(TypeUtils.NO_EXPECTED_TYPE)
|
|
||||||
if (returnValue == 0) {
|
|
||||||
// There are no additional overrides in the hierarchy
|
|
||||||
if (bindingContext[BindingContext.FUNCTION, describeContentsFunction]?.overriddenDescriptors?.size == 1) {
|
|
||||||
describeContentsFunction.delete()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (property in parcelerObject.declarations.asSequence().filterIsInstance<KtProperty>().filter { it.name == "CREATOR" }) {
|
|
||||||
if (property.findAnnotation(JVM_FIELD_ANNOTATION_FQ_NAME) != null) {
|
|
||||||
property.delete()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-35
@@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.parcelize.ide.quickfixes
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.parcelize.ide.KotlinParcelizeBundle
|
|
||||||
import org.jetbrains.kotlin.psi.KtProperty
|
|
||||||
import org.jetbrains.kotlin.psi.KtPsiFactory
|
|
||||||
|
|
||||||
class ParcelRemoveCustomCreatorProperty(property: KtProperty) : AbstractParcelizeQuickFix<KtProperty>(property) {
|
|
||||||
object Factory : AbstractFactory(f@ {
|
|
||||||
// KtProperty or its name identifier
|
|
||||||
psiElement as? KtProperty ?: (psiElement.parent as? KtProperty) ?: return@f null
|
|
||||||
findElement<KtProperty>()?.let(::ParcelRemoveCustomCreatorProperty)
|
|
||||||
})
|
|
||||||
|
|
||||||
override fun getText() = KotlinParcelizeBundle.message("parcelize.fix.remove.custom.creator.property")
|
|
||||||
|
|
||||||
override fun invoke(ktPsiFactory: KtPsiFactory, element: KtProperty) {
|
|
||||||
element.delete()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-31
@@ -1,31 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.parcelize.ide.quickfixes
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.parcelize.ide.KotlinParcelizeBundle
|
|
||||||
import org.jetbrains.kotlin.psi.KtFunction
|
|
||||||
import org.jetbrains.kotlin.psi.KtPsiFactory
|
|
||||||
|
|
||||||
class ParcelRemoveCustomWriteToParcel(function: KtFunction) : AbstractParcelizeQuickFix<KtFunction>(function) {
|
|
||||||
object Factory : AbstractFactory({ findElement<KtFunction>()?.let(::ParcelRemoveCustomWriteToParcel) })
|
|
||||||
|
|
||||||
override fun getText() = KotlinParcelizeBundle.message("parcelize.fix.remove.custom.write.to.parcel.function")
|
|
||||||
|
|
||||||
override fun invoke(ktPsiFactory: KtPsiFactory, element: KtFunction) {
|
|
||||||
element.delete()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-32
@@ -1,32 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.parcelize.ide.quickfixes
|
|
||||||
|
|
||||||
import kotlinx.parcelize.IgnoredOnParcel
|
|
||||||
import org.jetbrains.kotlin.parcelize.ide.KotlinParcelizeBundle
|
|
||||||
import org.jetbrains.kotlin.psi.KtProperty
|
|
||||||
import org.jetbrains.kotlin.psi.KtPsiFactory
|
|
||||||
|
|
||||||
class ParcelizeAddIgnoreOnParcelAnnotationQuickFix(property: KtProperty) : AbstractParcelizeQuickFix<KtProperty>(property) {
|
|
||||||
object Factory : AbstractFactory({ findElement<KtProperty>()?.let(::ParcelizeAddIgnoreOnParcelAnnotationQuickFix) })
|
|
||||||
|
|
||||||
override fun getText() = KotlinParcelizeBundle.message("parcelize.fix.add.ignored.on.parcel.annotation")
|
|
||||||
|
|
||||||
override fun invoke(ktPsiFactory: KtPsiFactory, element: KtProperty) {
|
|
||||||
element.addAnnotationEntry(ktPsiFactory.createAnnotationEntry("@" + IgnoredOnParcel::class.java.name)).shortenReferences()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-40
@@ -1,40 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.parcelize.ide.quickfixes
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.parcelize.ide.KotlinParcelizeBundle
|
|
||||||
import org.jetbrains.kotlin.psi.KtClass
|
|
||||||
import org.jetbrains.kotlin.psi.KtPsiFactory
|
|
||||||
import org.jetbrains.kotlin.psi.createPrimaryConstructorIfAbsent
|
|
||||||
|
|
||||||
class ParcelizeAddPrimaryConstructorQuickFix(clazz: KtClass) : AbstractParcelizeQuickFix<KtClass>(clazz) {
|
|
||||||
object Factory : AbstractFactory({ findElement<KtClass>()?.let(::ParcelizeAddPrimaryConstructorQuickFix) })
|
|
||||||
|
|
||||||
override fun getText() = KotlinParcelizeBundle.message("parcelize.fix.add.empty.primary.constructor")
|
|
||||||
|
|
||||||
override fun invoke(ktPsiFactory: KtPsiFactory, element: KtClass) {
|
|
||||||
element.createPrimaryConstructorIfAbsent()
|
|
||||||
|
|
||||||
for (secondaryConstructor in element.secondaryConstructors) {
|
|
||||||
if (secondaryConstructor.getDelegationCall().isImplicit) {
|
|
||||||
val parameterList = secondaryConstructor.valueParameterList ?: return
|
|
||||||
val colon = secondaryConstructor.addAfter(ktPsiFactory.createColon(), parameterList)
|
|
||||||
secondaryConstructor.addAfter(ktPsiFactory.createExpression("this()"), colon)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-32
@@ -1,32 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.parcelize.ide.quickfixes
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.parcelize.ANDROID_PARCELABLE_CLASS_FQNAME
|
|
||||||
import org.jetbrains.kotlin.parcelize.ide.KotlinParcelizeBundle
|
|
||||||
import org.jetbrains.kotlin.psi.*
|
|
||||||
|
|
||||||
class ParcelizeAddSupertypeQuickFix(clazz: KtClassOrObject) : AbstractParcelizeQuickFix<KtClassOrObject>(clazz) {
|
|
||||||
object Factory : AbstractFactory({ findElement<KtClassOrObject>()?.let(::ParcelizeAddSupertypeQuickFix) })
|
|
||||||
|
|
||||||
override fun getText() = KotlinParcelizeBundle.message("parcelize.fix.add.parcelable.supertype")
|
|
||||||
|
|
||||||
override fun invoke(ktPsiFactory: KtPsiFactory, element: KtClassOrObject) {
|
|
||||||
val supertypeName = ANDROID_PARCELABLE_CLASS_FQNAME.asString()
|
|
||||||
element.addSuperTypeListEntry(ktPsiFactory.createSuperTypeEntry(supertypeName)).shortenReferences()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-45
@@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.parcelize.ide.quickfixes
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.idea.quickfix.QuickFixContributor
|
|
||||||
import org.jetbrains.kotlin.idea.quickfix.QuickFixes
|
|
||||||
import org.jetbrains.kotlin.idea.quickfix.RemoveModifierFix
|
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens
|
|
||||||
import org.jetbrains.kotlin.parcelize.diagnostic.ErrorsParcelize
|
|
||||||
|
|
||||||
class ParcelizeQuickFixContributor : QuickFixContributor {
|
|
||||||
override fun registerQuickFixes(quickFixes: QuickFixes) {
|
|
||||||
quickFixes.register(
|
|
||||||
ErrorsParcelize.PARCELABLE_CANT_BE_INNER_CLASS,
|
|
||||||
RemoveModifierFix.createRemoveModifierFromListOwnerPsiBasedFactory(KtTokens.INNER_KEYWORD, false)
|
|
||||||
)
|
|
||||||
|
|
||||||
quickFixes.register(ErrorsParcelize.NO_PARCELABLE_SUPERTYPE, ParcelizeAddSupertypeQuickFix.Factory)
|
|
||||||
quickFixes.register(ErrorsParcelize.PARCELABLE_SHOULD_HAVE_PRIMARY_CONSTRUCTOR, ParcelizeAddPrimaryConstructorQuickFix.Factory)
|
|
||||||
quickFixes.register(ErrorsParcelize.PROPERTY_WONT_BE_SERIALIZED, ParcelizeAddIgnoreOnParcelAnnotationQuickFix.Factory)
|
|
||||||
|
|
||||||
quickFixes.register(ErrorsParcelize.OVERRIDING_WRITE_TO_PARCEL_IS_NOT_ALLOWED, ParcelMigrateToParcelizeQuickFix.FactoryForWrite)
|
|
||||||
quickFixes.register(ErrorsParcelize.OVERRIDING_WRITE_TO_PARCEL_IS_NOT_ALLOWED, ParcelRemoveCustomWriteToParcel.Factory)
|
|
||||||
|
|
||||||
quickFixes.register(ErrorsParcelize.CREATOR_DEFINITION_IS_NOT_ALLOWED, ParcelMigrateToParcelizeQuickFix.FactoryForCREATOR)
|
|
||||||
quickFixes.register(ErrorsParcelize.CREATOR_DEFINITION_IS_NOT_ALLOWED, ParcelRemoveCustomCreatorProperty.Factory)
|
|
||||||
|
|
||||||
quickFixes.register(ErrorsParcelize.REDUNDANT_TYPE_PARCELER, ParcelizeRemoveDuplicatingTypeParcelerAnnotationQuickFix.Factory)
|
|
||||||
quickFixes.register(ErrorsParcelize.CLASS_SHOULD_BE_PARCELIZE, AnnotateWithParcelizeQuickFix.Factory)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-31
@@ -1,31 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.parcelize.ide.quickfixes
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.parcelize.ide.KotlinParcelizeBundle
|
|
||||||
import org.jetbrains.kotlin.psi.KtAnnotationEntry
|
|
||||||
import org.jetbrains.kotlin.psi.KtPsiFactory
|
|
||||||
|
|
||||||
class ParcelizeRemoveDuplicatingTypeParcelerAnnotationQuickFix(anno: KtAnnotationEntry) : AbstractParcelizeQuickFix<KtAnnotationEntry>(anno) {
|
|
||||||
object Factory : AbstractFactory({ findElement<KtAnnotationEntry>()?.let(::ParcelizeRemoveDuplicatingTypeParcelerAnnotationQuickFix) })
|
|
||||||
|
|
||||||
override fun getText() = KotlinParcelizeBundle.message("parcelize.fix.remove.redundant.type.parceler.annotation")
|
|
||||||
|
|
||||||
override fun invoke(ktPsiFactory: KtPsiFactory, element: KtAnnotationEntry) {
|
|
||||||
element.delete()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vendored
-13
@@ -1,13 +0,0 @@
|
|||||||
// "Add empty primary constructor" "true"
|
|
||||||
// WITH_STDLIB
|
|
||||||
|
|
||||||
package com.myapp.activity
|
|
||||||
|
|
||||||
import android.os.Parcelable
|
|
||||||
import kotlinx.parcelize.Parcelize
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
class <caret>Test : Parcelable {
|
|
||||||
constructor(s: String)
|
|
||||||
constructor(s: String, i: Int) : this(s)
|
|
||||||
}
|
|
||||||
-13
@@ -1,13 +0,0 @@
|
|||||||
// "Add empty primary constructor" "true"
|
|
||||||
// WITH_STDLIB
|
|
||||||
|
|
||||||
package com.myapp.activity
|
|
||||||
|
|
||||||
import android.os.Parcelable
|
|
||||||
import kotlinx.parcelize.Parcelize
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
class <caret>Test() : Parcelable {
|
|
||||||
constructor(s: String) : this()
|
|
||||||
constructor(s: String, i: Int) : this(s)
|
|
||||||
}
|
|
||||||
-11
@@ -1,11 +0,0 @@
|
|||||||
// "Add empty primary constructor" "false"
|
|
||||||
// IGNORE_IRRELEVANT_ACTIONS
|
|
||||||
// WITH_STDLIB
|
|
||||||
|
|
||||||
package com.myapp.activity
|
|
||||||
|
|
||||||
import android.os.Parcelable
|
|
||||||
import kotlinx.parcelize.Parcelize
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
class <caret>Test() : Parcelable
|
|
||||||
-12
@@ -1,12 +0,0 @@
|
|||||||
// "Add empty primary constructor" "true"
|
|
||||||
// WITH_STDLIB
|
|
||||||
|
|
||||||
package com.myapp.activity
|
|
||||||
|
|
||||||
import android.os.Parcelable
|
|
||||||
import kotlinx.parcelize.Parcelize
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
class <caret>Test : Parcelable {
|
|
||||||
constructor(a: Int)
|
|
||||||
}
|
|
||||||
-12
@@ -1,12 +0,0 @@
|
|||||||
// "Add empty primary constructor" "true"
|
|
||||||
// WITH_STDLIB
|
|
||||||
|
|
||||||
package com.myapp.activity
|
|
||||||
|
|
||||||
import android.os.Parcelable
|
|
||||||
import kotlinx.parcelize.Parcelize
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
class <caret>Test() : Parcelable {
|
|
||||||
constructor(a: Int) : this()
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
// "Remove 'inner' modifier" "true"
|
|
||||||
// WITH_STDLIB
|
|
||||||
|
|
||||||
package com.myapp.activity
|
|
||||||
|
|
||||||
import android.os.Parcelable
|
|
||||||
import kotlinx.parcelize.Parcelize
|
|
||||||
|
|
||||||
class Foo {
|
|
||||||
@Parcelize
|
|
||||||
<caret>inner class Bar : Parcelable
|
|
||||||
}
|
|
||||||
-12
@@ -1,12 +0,0 @@
|
|||||||
// "Remove 'inner' modifier" "true"
|
|
||||||
// WITH_STDLIB
|
|
||||||
|
|
||||||
package com.myapp.activity
|
|
||||||
|
|
||||||
import android.os.Parcelable
|
|
||||||
import kotlinx.parcelize.Parcelize
|
|
||||||
|
|
||||||
class Foo {
|
|
||||||
@Parcelize<caret>
|
|
||||||
class Bar : Parcelable
|
|
||||||
}
|
|
||||||
-15
@@ -1,15 +0,0 @@
|
|||||||
// "Annotate containing class with ''@Parcelize''" "true"
|
|
||||||
// ERROR: No 'Parcelable' supertype
|
|
||||||
// WITH_STDLIB
|
|
||||||
|
|
||||||
package com.myapp.activity
|
|
||||||
|
|
||||||
import android.os.*
|
|
||||||
import kotlinx.parcelize.*
|
|
||||||
|
|
||||||
object StringParceler : Parceler<String> {
|
|
||||||
override fun create(parcel: Parcel) = TODO()
|
|
||||||
override fun String.write(parcel: Parcel, flags: Int) = TODO()
|
|
||||||
}
|
|
||||||
|
|
||||||
class Foo(@<caret>TypeParceler<String, StringParceler> val a: String)
|
|
||||||
-16
@@ -1,16 +0,0 @@
|
|||||||
// "Annotate containing class with ''@Parcelize''" "true"
|
|
||||||
// ERROR: No 'Parcelable' supertype
|
|
||||||
// WITH_STDLIB
|
|
||||||
|
|
||||||
package com.myapp.activity
|
|
||||||
|
|
||||||
import android.os.*
|
|
||||||
import kotlinx.parcelize.*
|
|
||||||
|
|
||||||
object StringParceler : Parceler<String> {
|
|
||||||
override fun create(parcel: Parcel) = TODO()
|
|
||||||
override fun String.write(parcel: Parcel, flags: Int) = TODO()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
class Foo(@<caret>TypeParceler<String, StringParceler> val a: String)
|
|
||||||
-36
@@ -1,36 +0,0 @@
|
|||||||
// "Remove custom ''CREATOR'' property" "true"
|
|
||||||
// ERROR: Overriding 'writeToParcel' is not allowed. Use 'Parceler' companion object instead
|
|
||||||
// WITH_STDLIB
|
|
||||||
|
|
||||||
package com.myapp.activity
|
|
||||||
|
|
||||||
import android.os.*
|
|
||||||
import kotlinx.parcelize.Parcelize
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
class Foo(val a: String) : Parcelable {
|
|
||||||
constructor(parcel: Parcel) : this(parcel.readString()) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun writeToParcel(parcel: Parcel, flags: Int) {
|
|
||||||
parcel.writeString(a)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun describeContents(): Int {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
@JvmField
|
|
||||||
val <caret>CREATOR = object : Parcelable.Creator<Foo> {
|
|
||||||
override fun createFromParcel(parcel: Parcel): Foo {
|
|
||||||
return Foo(parcel)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun newArray(size: Int): Array<Foo?> {
|
|
||||||
return arrayOfNulls(size)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-26
@@ -1,26 +0,0 @@
|
|||||||
// "Remove custom ''CREATOR'' property" "true"
|
|
||||||
// ERROR: Overriding 'writeToParcel' is not allowed. Use 'Parceler' companion object instead
|
|
||||||
// WITH_STDLIB
|
|
||||||
|
|
||||||
package com.myapp.activity
|
|
||||||
|
|
||||||
import android.os.*
|
|
||||||
import kotlinx.parcelize.Parcelize
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
class Foo(val a: String) : Parcelable {
|
|
||||||
constructor(parcel: Parcel) : this(parcel.readString()) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun writeToParcel(parcel: Parcel, flags: Int) {
|
|
||||||
parcel.writeString(a)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun describeContents(): Int {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
<caret>}
|
|
||||||
|
|
||||||
}
|
|
||||||
-33
@@ -1,33 +0,0 @@
|
|||||||
// "Remove custom ''writeToParcel()'' function" "true"
|
|
||||||
// ERROR: 'CREATOR' definition is not allowed. Use 'Parceler' companion object instead
|
|
||||||
// WITH_STDLIB
|
|
||||||
|
|
||||||
package com.myapp.activity
|
|
||||||
|
|
||||||
import android.os.*
|
|
||||||
import kotlinx.parcelize.Parcelize
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
class Foo(val a: String) : Parcelable {
|
|
||||||
constructor(parcel: Parcel) : this(parcel.readString()) {
|
|
||||||
}
|
|
||||||
|
|
||||||
<caret>override fun writeToParcel(parcel: Parcel, flags: Int) {
|
|
||||||
parcel.writeString(a)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun describeContents(): Int {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object CREATOR : Parcelable.Creator<Foo> {
|
|
||||||
override fun createFromParcel(parcel: Parcel): Foo {
|
|
||||||
return Foo(parcel)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun newArray(size: Int): Array<Foo?> {
|
|
||||||
return arrayOfNulls(size)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Vendored
-29
@@ -1,29 +0,0 @@
|
|||||||
// "Remove custom ''writeToParcel()'' function" "true"
|
|
||||||
// ERROR: 'CREATOR' definition is not allowed. Use 'Parceler' companion object instead
|
|
||||||
// WITH_STDLIB
|
|
||||||
|
|
||||||
package com.myapp.activity
|
|
||||||
|
|
||||||
import android.os.*
|
|
||||||
import kotlinx.parcelize.Parcelize
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
class Foo(val a: String) : Parcelable {
|
|
||||||
constructor(parcel: Parcel) : this(parcel.readString()) {
|
|
||||||
}
|
|
||||||
|
|
||||||
<caret>override fun describeContents(): Int {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object CREATOR : Parcelable.Creator<Foo> {
|
|
||||||
override fun createFromParcel(parcel: Parcel): Foo {
|
|
||||||
return Foo(parcel)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun newArray(size: Int): Array<Foo?> {
|
|
||||||
return arrayOfNulls(size)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
// "Migrate to ''Parceler'' companion object" "true"
|
|
||||||
// WITH_STDLIB
|
|
||||||
|
|
||||||
package com.myapp.activity
|
|
||||||
|
|
||||||
import android.os.*
|
|
||||||
import kotlinx.parcelize.Parcelize
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
class Foo(val firstName: String, val age: Int) : Parcelable {
|
|
||||||
constructor(parcel: Parcel) : this(
|
|
||||||
parcel.readString(),
|
|
||||||
parcel.readInt()) {
|
|
||||||
}
|
|
||||||
|
|
||||||
<caret>override fun writeToParcel(parcel: Parcel, flags: Int) {
|
|
||||||
parcel.writeString(firstName)
|
|
||||||
parcel.writeInt(age)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun describeContents(): Int {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object CREATOR : Parcelable.Creator<Foo> {
|
|
||||||
override fun createFromParcel(parcel: Parcel): Foo {
|
|
||||||
return Foo(parcel)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun newArray(size: Int): Array<Foo?> {
|
|
||||||
return arrayOfNulls(size)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
// "Migrate to ''Parceler'' companion object" "true"
|
|
||||||
// WITH_STDLIB
|
|
||||||
|
|
||||||
package com.myapp.activity
|
|
||||||
|
|
||||||
import android.os.*
|
|
||||||
import kotlinx.parcelize.Parceler
|
|
||||||
import kotlinx.parcelize.Parcelize
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
class Foo(val firstName: String, val age: Int) : Parcelable {
|
|
||||||
constructor(parcel: Parcel) : this(
|
|
||||||
parcel.readString(),
|
|
||||||
parcel.readInt()) {
|
|
||||||
}
|
|
||||||
|
|
||||||
<caret>companion object : Parceler<Foo> {
|
|
||||||
|
|
||||||
override fun Foo.write(parcel: Parcel, flags: Int) {
|
|
||||||
parcel.writeString(firstName)
|
|
||||||
parcel.writeInt(age)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun create(parcel: Parcel): Foo {
|
|
||||||
return Foo(parcel)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
// "Migrate to ''Parceler'' companion object" "true"
|
|
||||||
// WITH_STDLIB
|
|
||||||
|
|
||||||
package com.myapp.activity
|
|
||||||
|
|
||||||
import android.os.*
|
|
||||||
import kotlinx.parcelize.Parcelize
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
class Foo(val firstName: String, val age: Int) : Parcelable {
|
|
||||||
constructor(parcel: Parcel) : this(parcel.readString(), parcel.readInt())
|
|
||||||
|
|
||||||
override fun writeToParcel(parcel: Parcel, flags: Int) {
|
|
||||||
parcel.writeString(firstName)
|
|
||||||
parcel.writeInt(age)
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
@JvmField
|
|
||||||
val <caret>CREATOR: Parcelable.Creator<Foo> = object : Creator() {}
|
|
||||||
}
|
|
||||||
|
|
||||||
private abstract class Creator : Parcelable.Creator<Foo> {
|
|
||||||
override fun createFromParcel(parcel: Parcel): Foo {
|
|
||||||
return Foo(parcel)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun newArray(size: Int): Array<Foo?> {
|
|
||||||
return arrayOfNulls(size)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-32
@@ -1,32 +0,0 @@
|
|||||||
// "Migrate to ''Parceler'' companion object" "true"
|
|
||||||
// WITH_STDLIB
|
|
||||||
|
|
||||||
package com.myapp.activity
|
|
||||||
|
|
||||||
import android.os.*
|
|
||||||
import kotlinx.parcelize.Parceler
|
|
||||||
import kotlinx.parcelize.Parcelize
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
class Foo(val firstName: String, val age: Int) : Parcelable {
|
|
||||||
constructor(parcel: Parcel) : this(parcel.readString(), parcel.readInt())
|
|
||||||
|
|
||||||
companion object : Parceler<Foo> {
|
|
||||||
<caret>override fun Foo.write(parcel: Parcel, flags: Int) {
|
|
||||||
parcel.writeString(firstName)
|
|
||||||
parcel.writeInt(age)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun create(parcel: Parcel): Foo = TODO()
|
|
||||||
}
|
|
||||||
|
|
||||||
private abstract class Creator : Parcelable.Creator<Foo> {
|
|
||||||
override fun createFromParcel(parcel: Parcel): Foo {
|
|
||||||
return Foo(parcel)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun newArray(size: Int): Array<Foo?> {
|
|
||||||
return arrayOfNulls(size)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-34
@@ -1,34 +0,0 @@
|
|||||||
// "Migrate to ''Parceler'' companion object" "true"
|
|
||||||
// WITH_STDLIB
|
|
||||||
|
|
||||||
package com.myapp.activity
|
|
||||||
|
|
||||||
import android.os.*
|
|
||||||
import kotlinx.parcelize.Parcelize
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
class Foo(val firstName: String, val age: Int) : Parcelable {
|
|
||||||
constructor(parcel: Parcel) : this(
|
|
||||||
parcel.readString(),
|
|
||||||
parcel.readInt()) {
|
|
||||||
}
|
|
||||||
|
|
||||||
<caret>override fun writeToParcel(parcel: Parcel, flags: Int) {
|
|
||||||
parcel.writeString(firstName)
|
|
||||||
parcel.writeInt(age)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun describeContents(): Int {
|
|
||||||
return 50
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object CREATOR : Parcelable.Creator<Foo> {
|
|
||||||
override fun createFromParcel(parcel: Parcel): Foo {
|
|
||||||
return Foo(parcel)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun newArray(size: Int): Array<Foo?> {
|
|
||||||
return arrayOfNulls(size)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vendored
-32
@@ -1,32 +0,0 @@
|
|||||||
// "Migrate to ''Parceler'' companion object" "true"
|
|
||||||
// WITH_STDLIB
|
|
||||||
|
|
||||||
package com.myapp.activity
|
|
||||||
|
|
||||||
import android.os.*
|
|
||||||
import kotlinx.parcelize.Parceler
|
|
||||||
import kotlinx.parcelize.Parcelize
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
class Foo(val firstName: String, val age: Int) : Parcelable {
|
|
||||||
constructor(parcel: Parcel) : this(
|
|
||||||
parcel.readString(),
|
|
||||||
parcel.readInt()) {
|
|
||||||
}
|
|
||||||
|
|
||||||
<caret>override fun describeContents(): Int {
|
|
||||||
return 50
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object : Parceler<Foo> {
|
|
||||||
|
|
||||||
override fun Foo.write(parcel: Parcel, flags: Int) {
|
|
||||||
parcel.writeString(firstName)
|
|
||||||
parcel.writeInt(age)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun create(parcel: Parcel): Foo {
|
|
||||||
return Foo(parcel)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-30
@@ -1,30 +0,0 @@
|
|||||||
// "Migrate to ''Parceler'' companion object" "true"
|
|
||||||
// WITH_STDLIB
|
|
||||||
|
|
||||||
package com.myapp.activity
|
|
||||||
|
|
||||||
import android.os.*
|
|
||||||
import kotlinx.parcelize.Parcelize
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
class Foo(val firstName: String, val age: Int) : Parcelable {
|
|
||||||
constructor(parcel: Parcel) : this(
|
|
||||||
parcel.readString(),
|
|
||||||
parcel.readInt()) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun writeToParcel(parcel: Parcel, flags: Int) {
|
|
||||||
parcel.writeString(firstName)
|
|
||||||
parcel.writeInt(age)
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object <caret>CREATOR : Parcelable.Creator<Foo> {
|
|
||||||
override fun createFromParcel(parcel: Parcel): Foo {
|
|
||||||
return Foo(parcel)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun newArray(size: Int): Array<Foo?> {
|
|
||||||
return arrayOfNulls(size)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-28
@@ -1,28 +0,0 @@
|
|||||||
// "Migrate to ''Parceler'' companion object" "true"
|
|
||||||
// WITH_STDLIB
|
|
||||||
|
|
||||||
package com.myapp.activity
|
|
||||||
|
|
||||||
import android.os.*
|
|
||||||
import kotlinx.parcelize.Parceler
|
|
||||||
import kotlinx.parcelize.Parcelize
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
class Foo(val firstName: String, val age: Int) : Parcelable {
|
|
||||||
constructor(parcel: Parcel) : this(
|
|
||||||
parcel.readString(),
|
|
||||||
parcel.readInt()) {
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object <caret>: Parceler<Foo> {
|
|
||||||
|
|
||||||
override fun Foo.write(parcel: Parcel, flags: Int) {
|
|
||||||
parcel.writeString(firstName)
|
|
||||||
parcel.writeInt(age)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun create(parcel: Parcel): Foo {
|
|
||||||
return Foo(parcel)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-32
@@ -1,32 +0,0 @@
|
|||||||
// "Migrate to ''Parceler'' companion object" "true"
|
|
||||||
// WITH_STDLIB
|
|
||||||
|
|
||||||
package com.myapp.activity
|
|
||||||
|
|
||||||
import android.os.*
|
|
||||||
import kotlinx.parcelize.Parcelize
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
class Foo(val firstName: String, val age: Int) : Parcelable {
|
|
||||||
constructor(parcel: Parcel) : this(parcel.readString(), parcel.readInt())
|
|
||||||
|
|
||||||
override fun writeToParcel(parcel: Parcel, flags: Int) {
|
|
||||||
parcel.writeString(firstName)
|
|
||||||
parcel.writeInt(age)
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
@JvmField
|
|
||||||
val <caret>CREATOR: Parcelable.Creator<Foo> = Creator()
|
|
||||||
}
|
|
||||||
|
|
||||||
private class Creator : Parcelable.Creator<Foo> {
|
|
||||||
override fun createFromParcel(parcel: Parcel): Foo {
|
|
||||||
return Foo(parcel)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun newArray(size: Int): Array<Foo?> {
|
|
||||||
return arrayOfNulls(size)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-34
@@ -1,34 +0,0 @@
|
|||||||
// "Migrate to ''Parceler'' companion object" "true"
|
|
||||||
// WITH_STDLIB
|
|
||||||
|
|
||||||
package com.myapp.activity
|
|
||||||
|
|
||||||
import android.os.*
|
|
||||||
import kotlinx.parcelize.Parceler
|
|
||||||
import kotlinx.parcelize.Parcelize
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
class Foo(val firstName: String, val age: Int) : Parcelable {
|
|
||||||
constructor(parcel: Parcel) : this(parcel.readString(), parcel.readInt())
|
|
||||||
|
|
||||||
companion object : Parceler<Foo> {
|
|
||||||
<caret>override fun Foo.write(parcel: Parcel, flags: Int) {
|
|
||||||
parcel.writeString(firstName)
|
|
||||||
parcel.writeInt(age)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun create(parcel: Parcel): Foo {
|
|
||||||
return Foo(parcel)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class Creator : Parcelable.Creator<Foo> {
|
|
||||||
override fun createFromParcel(parcel: Parcel): Foo {
|
|
||||||
return Foo(parcel)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun newArray(size: Int): Array<Foo?> {
|
|
||||||
return arrayOfNulls(size)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
// "Migrate to ''Parceler'' companion object" "true"
|
|
||||||
// WITH_STDLIB
|
|
||||||
|
|
||||||
package com.myapp.activity
|
|
||||||
|
|
||||||
import android.os.*
|
|
||||||
import kotlinx.parcelize.Parcelize
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
class Foo(val firstName: String, val age: Int) : Parcelable {
|
|
||||||
constructor(parcel: Parcel) : this(parcel.readString(), parcel.readInt())
|
|
||||||
|
|
||||||
override fun writeToParcel(parcel: Parcel, flags: Int) {
|
|
||||||
parcel.writeString(firstName)
|
|
||||||
parcel.writeInt(age)
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
@JvmField
|
|
||||||
val <caret>CREATOR = object : Parcelable.Creator<Foo> {
|
|
||||||
override fun createFromParcel(parcel: Parcel): Foo {
|
|
||||||
return Foo(parcel)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun newArray(size: Int): Array<Foo?> {
|
|
||||||
return arrayOfNulls(size)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-24
@@ -1,24 +0,0 @@
|
|||||||
// "Migrate to ''Parceler'' companion object" "true"
|
|
||||||
// WITH_STDLIB
|
|
||||||
|
|
||||||
package com.myapp.activity
|
|
||||||
|
|
||||||
import android.os.*
|
|
||||||
import kotlinx.parcelize.Parceler
|
|
||||||
import kotlinx.parcelize.Parcelize
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
class Foo(val firstName: String, val age: Int) : Parcelable {
|
|
||||||
constructor(parcel: Parcel) : this(parcel.readString(), parcel.readInt())
|
|
||||||
|
|
||||||
companion object : Parceler<Foo> {
|
|
||||||
<caret>override fun Foo.write(parcel: Parcel, flags: Int) {
|
|
||||||
parcel.writeString(firstName)
|
|
||||||
parcel.writeInt(age)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun create(parcel: Parcel): Foo {
|
|
||||||
return Foo(parcel)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-30
@@ -1,30 +0,0 @@
|
|||||||
// "Migrate to ''Parceler'' companion object" "true"
|
|
||||||
// WITH_STDLIB
|
|
||||||
|
|
||||||
package com.myapp.activity
|
|
||||||
|
|
||||||
import android.os.*
|
|
||||||
import kotlinx.parcelize.Parcelize
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
class Foo(val firstName: String, val age: Int) : Parcelable {
|
|
||||||
constructor(parcel: Parcel) : this(
|
|
||||||
parcel.readString(),
|
|
||||||
parcel.readInt()) {
|
|
||||||
}
|
|
||||||
|
|
||||||
<caret>override fun writeToParcel(parcel: Parcel, flags: Int) {
|
|
||||||
parcel.writeString(firstName)
|
|
||||||
parcel.writeInt(age)
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object CREATOR : Parcelable.Creator<Foo> {
|
|
||||||
override fun createFromParcel(parcel: Parcel): Foo {
|
|
||||||
return Foo(parcel)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun newArray(size: Int): Array<Foo?> {
|
|
||||||
return arrayOfNulls(size)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vendored
-28
@@ -1,28 +0,0 @@
|
|||||||
// "Migrate to ''Parceler'' companion object" "true"
|
|
||||||
// WITH_STDLIB
|
|
||||||
|
|
||||||
package com.myapp.activity
|
|
||||||
|
|
||||||
import android.os.*
|
|
||||||
import kotlinx.parcelize.Parceler
|
|
||||||
import kotlinx.parcelize.Parcelize
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
class Foo(val firstName: String, val age: Int) : Parcelable {
|
|
||||||
constructor(parcel: Parcel) : this(
|
|
||||||
parcel.readString(),
|
|
||||||
parcel.readInt()) {
|
|
||||||
}
|
|
||||||
|
|
||||||
<caret>companion object : Parceler<Foo> {
|
|
||||||
|
|
||||||
override fun Foo.write(parcel: Parcel, flags: Int) {
|
|
||||||
parcel.writeString(firstName)
|
|
||||||
parcel.writeInt(age)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun create(parcel: Parcel): Foo {
|
|
||||||
return Foo(parcel)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vendored
-13
@@ -1,13 +0,0 @@
|
|||||||
// "Add ''Parcelable'' supertype" "false"
|
|
||||||
// IGNORE_IRRELEVANT_ACTIONS
|
|
||||||
// WITH_STDLIB
|
|
||||||
|
|
||||||
package com.myapp.activity
|
|
||||||
|
|
||||||
import android.os.Parcelable
|
|
||||||
import kotlinx.parcelize.Parcelize
|
|
||||||
|
|
||||||
abstract class AbstractParcelable : Parcelable
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
class <caret>Test(val s: String) : AbstractParcelable()
|
|
||||||
-10
@@ -1,10 +0,0 @@
|
|||||||
// "Add ''Parcelable'' supertype" "true"
|
|
||||||
// WITH_STDLIB
|
|
||||||
|
|
||||||
package com.myapp.activity
|
|
||||||
|
|
||||||
import android.os.Parcelable
|
|
||||||
import kotlinx.parcelize.Parcelize
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
class <caret>Test(val s: String)
|
|
||||||
-10
@@ -1,10 +0,0 @@
|
|||||||
// "Add ''Parcelable'' supertype" "true"
|
|
||||||
// WITH_STDLIB
|
|
||||||
|
|
||||||
package com.myapp.activity
|
|
||||||
|
|
||||||
import android.os.Parcelable
|
|
||||||
import kotlinx.parcelize.Parcelize
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
class <caret>Test(val s: String) : Parcelable
|
|
||||||
-12
@@ -1,12 +0,0 @@
|
|||||||
// "Add ''@IgnoredOnParcel'' annotation" "true"
|
|
||||||
// WITH_STDLIB
|
|
||||||
|
|
||||||
package com.myapp.activity
|
|
||||||
|
|
||||||
import android.os.Parcelable
|
|
||||||
import kotlinx.parcelize.Parcelize
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
class Test : Parcelable {
|
|
||||||
val <caret>a = 5
|
|
||||||
}
|
|
||||||
-14
@@ -1,14 +0,0 @@
|
|||||||
// "Add ''@IgnoredOnParcel'' annotation" "true"
|
|
||||||
// WITH_STDLIB
|
|
||||||
|
|
||||||
package com.myapp.activity
|
|
||||||
|
|
||||||
import android.os.Parcelable
|
|
||||||
import kotlinx.parcelize.IgnoredOnParcel
|
|
||||||
import kotlinx.parcelize.Parcelize
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
class Test : Parcelable {
|
|
||||||
@IgnoredOnParcel
|
|
||||||
val <caret>a = 5
|
|
||||||
}
|
|
||||||
Vendored
-17
@@ -1,17 +0,0 @@
|
|||||||
// "Remove redundant ''@TypeParceler'' annotation" "true"
|
|
||||||
// WARNING: This annotation duplicates the one for Class 'Foo'
|
|
||||||
// WITH_STDLIB
|
|
||||||
|
|
||||||
package com.myapp.activity
|
|
||||||
|
|
||||||
import android.os.*
|
|
||||||
import kotlinx.parcelize.*
|
|
||||||
|
|
||||||
object StringParceler : Parceler<String> {
|
|
||||||
override fun create(parcel: Parcel) = TODO()
|
|
||||||
override fun String.write(parcel: Parcel, flags: Int) = TODO()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
@TypeParceler<String, StringParceler>
|
|
||||||
class Foo(@<caret>TypeParceler<String, StringParceler> val a: String) : Parcelable
|
|
||||||
-17
@@ -1,17 +0,0 @@
|
|||||||
// "Remove redundant ''@TypeParceler'' annotation" "true"
|
|
||||||
// WARNING: This annotation duplicates the one for Class 'Foo'
|
|
||||||
// WITH_STDLIB
|
|
||||||
|
|
||||||
package com.myapp.activity
|
|
||||||
|
|
||||||
import android.os.*
|
|
||||||
import kotlinx.parcelize.*
|
|
||||||
|
|
||||||
object StringParceler : Parceler<String> {
|
|
||||||
override fun create(parcel: Parcel) = TODO()
|
|
||||||
override fun String.write(parcel: Parcel, flags: Int) = TODO()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
@TypeParceler<String, StringParceler>
|
|
||||||
class Foo(<caret>val a: String) : Parcelable
|
|
||||||
-20
@@ -1,20 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2020 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.pacelize.ide.test
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.checkers.AbstractKotlinHighlightingPassTest
|
|
||||||
|
|
||||||
abstract class AbstractParcelizeCheckerTest : AbstractKotlinHighlightingPassTest() {
|
|
||||||
override fun setUp() {
|
|
||||||
super.setUp()
|
|
||||||
addParcelizeLibraries(module)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun tearDown() {
|
|
||||||
removeParcelizeLibraries(module)
|
|
||||||
super.tearDown()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-33
@@ -1,33 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.pacelize.ide.test
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.idea.quickfix.AbstractQuickFixTest
|
|
||||||
import org.jetbrains.kotlin.idea.test.ConfigLibraryUtil
|
|
||||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
|
||||||
|
|
||||||
abstract class AbstractParcelizeQuickFixTest : AbstractQuickFixTest() {
|
|
||||||
override fun setUp() {
|
|
||||||
super.setUp()
|
|
||||||
addParcelizeLibraries(module)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun tearDown() {
|
|
||||||
removeParcelizeLibraries(module)
|
|
||||||
super.tearDown()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-106
@@ -1,106 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2021 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.pacelize.ide.test;
|
|
||||||
|
|
||||||
import com.intellij.testFramework.TestDataPath;
|
|
||||||
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
|
||||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
|
||||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
|
||||||
import org.jetbrains.kotlin.test.TestMetadata;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
|
||||||
@SuppressWarnings("all")
|
|
||||||
@TestMetadata("plugins/parcelize/parcelize-ide/testData/checker")
|
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
|
||||||
public class ParcelizeCheckerTestGenerated extends AbstractParcelizeCheckerTest {
|
|
||||||
private void runTest(String testDataFilePath) throws Exception {
|
|
||||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testAllFilesPresentInChecker() throws Exception {
|
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/parcelize/parcelize-ide/testData/checker"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("constructors.kt")
|
|
||||||
public void testConstructors() throws Exception {
|
|
||||||
runTest("plugins/parcelize/parcelize-ide/testData/checker/constructors.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("customCreator.kt")
|
|
||||||
public void testCustomCreator() throws Exception {
|
|
||||||
runTest("plugins/parcelize/parcelize-ide/testData/checker/customCreator.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("customParcelers.kt")
|
|
||||||
public void testCustomParcelers() throws Exception {
|
|
||||||
runTest("plugins/parcelize/parcelize-ide/testData/checker/customParcelers.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("customWriteToParcel.kt")
|
|
||||||
public void testCustomWriteToParcel() throws Exception {
|
|
||||||
runTest("plugins/parcelize/parcelize-ide/testData/checker/customWriteToParcel.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("delegate.kt")
|
|
||||||
public void testDelegate() throws Exception {
|
|
||||||
runTest("plugins/parcelize/parcelize-ide/testData/checker/delegate.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("deprecatedAnnotations.kt")
|
|
||||||
public void testDeprecatedAnnotations() throws Exception {
|
|
||||||
runTest("plugins/parcelize/parcelize-ide/testData/checker/deprecatedAnnotations.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("emptyPrimaryConstructor.kt")
|
|
||||||
public void testEmptyPrimaryConstructor() throws Exception {
|
|
||||||
runTest("plugins/parcelize/parcelize-ide/testData/checker/emptyPrimaryConstructor.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("kt20062.kt")
|
|
||||||
public void testKt20062() throws Exception {
|
|
||||||
runTest("plugins/parcelize/parcelize-ide/testData/checker/kt20062.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("modality.kt")
|
|
||||||
public void testModality() throws Exception {
|
|
||||||
runTest("plugins/parcelize/parcelize-ide/testData/checker/modality.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("notMagicParcel.kt")
|
|
||||||
public void testNotMagicParcel() throws Exception {
|
|
||||||
runTest("plugins/parcelize/parcelize-ide/testData/checker/notMagicParcel.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("properties.kt")
|
|
||||||
public void testProperties() throws Exception {
|
|
||||||
runTest("plugins/parcelize/parcelize-ide/testData/checker/properties.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("simple.kt")
|
|
||||||
public void testSimple() throws Exception {
|
|
||||||
runTest("plugins/parcelize/parcelize-ide/testData/checker/simple.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("unsupportedType.kt")
|
|
||||||
public void testUnsupportedType() throws Exception {
|
|
||||||
runTest("plugins/parcelize/parcelize-ide/testData/checker/unsupportedType.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("withoutParcelableSupertype.kt")
|
|
||||||
public void testWithoutParcelableSupertype() throws Exception {
|
|
||||||
runTest("plugins/parcelize/parcelize-ide/testData/checker/withoutParcelableSupertype.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("wrongAnnotationTarget.kt")
|
|
||||||
public void testWrongAnnotationTarget() throws Exception {
|
|
||||||
runTest("plugins/parcelize/parcelize-ide/testData/checker/wrongAnnotationTarget.kt");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-225
@@ -1,225 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2021 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.pacelize.ide.test;
|
|
||||||
|
|
||||||
import com.intellij.testFramework.TestDataPath;
|
|
||||||
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
|
||||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
|
||||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
|
||||||
import org.jetbrains.kotlin.test.TestMetadata;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
|
||||||
@SuppressWarnings("all")
|
|
||||||
@TestMetadata("plugins/parcelize/parcelize-ide/testData/quickfix")
|
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
|
||||||
public class ParcelizeQuickFixTestGenerated extends AbstractParcelizeQuickFixTest {
|
|
||||||
private void runTest(String testDataFilePath) throws Exception {
|
|
||||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testAllFilesPresentInQuickfix() throws Exception {
|
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/parcelize/parcelize-ide/testData/quickfix"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), null, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("plugins/parcelize/parcelize-ide/testData/quickfix/addPrimaryConstructor")
|
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
|
||||||
public static class AddPrimaryConstructor extends AbstractParcelizeQuickFixTest {
|
|
||||||
private void runTest(String testDataFilePath) throws Exception {
|
|
||||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testAllFilesPresentInAddPrimaryConstructor() throws Exception {
|
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/parcelize/parcelize-ide/testData/quickfix/addPrimaryConstructor"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), null, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("constructorWithDelegate.kt")
|
|
||||||
public void testConstructorWithDelegate() throws Exception {
|
|
||||||
runTest("plugins/parcelize/parcelize-ide/testData/quickfix/addPrimaryConstructor/constructorWithDelegate.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("noQuickFix.kt")
|
|
||||||
public void testNoQuickFix() throws Exception {
|
|
||||||
runTest("plugins/parcelize/parcelize-ide/testData/quickfix/addPrimaryConstructor/noQuickFix.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("simple.kt")
|
|
||||||
public void testSimple() throws Exception {
|
|
||||||
runTest("plugins/parcelize/parcelize-ide/testData/quickfix/addPrimaryConstructor/simple.kt");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("plugins/parcelize/parcelize-ide/testData/quickfix/cantBeInnerClass")
|
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
|
||||||
public static class CantBeInnerClass extends AbstractParcelizeQuickFixTest {
|
|
||||||
private void runTest(String testDataFilePath) throws Exception {
|
|
||||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testAllFilesPresentInCantBeInnerClass() throws Exception {
|
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/parcelize/parcelize-ide/testData/quickfix/cantBeInnerClass"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), null, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("simple.kt")
|
|
||||||
public void testSimple() throws Exception {
|
|
||||||
runTest("plugins/parcelize/parcelize-ide/testData/quickfix/cantBeInnerClass/simple.kt");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("plugins/parcelize/parcelize-ide/testData/quickfix/classShouldBeAnnotated")
|
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
|
||||||
public static class ClassShouldBeAnnotated extends AbstractParcelizeQuickFixTest {
|
|
||||||
private void runTest(String testDataFilePath) throws Exception {
|
|
||||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testAllFilesPresentInClassShouldBeAnnotated() throws Exception {
|
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/parcelize/parcelize-ide/testData/quickfix/classShouldBeAnnotated"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), null, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("simple.kt")
|
|
||||||
public void testSimple() throws Exception {
|
|
||||||
runTest("plugins/parcelize/parcelize-ide/testData/quickfix/classShouldBeAnnotated/simple.kt");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("plugins/parcelize/parcelize-ide/testData/quickfix/deleteIncompatible")
|
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
|
||||||
public static class DeleteIncompatible extends AbstractParcelizeQuickFixTest {
|
|
||||||
private void runTest(String testDataFilePath) throws Exception {
|
|
||||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testAllFilesPresentInDeleteIncompatible() throws Exception {
|
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/parcelize/parcelize-ide/testData/quickfix/deleteIncompatible"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), null, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("creatorField.kt")
|
|
||||||
public void testCreatorField() throws Exception {
|
|
||||||
runTest("plugins/parcelize/parcelize-ide/testData/quickfix/deleteIncompatible/creatorField.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("writeToParcel.kt")
|
|
||||||
public void testWriteToParcel() throws Exception {
|
|
||||||
runTest("plugins/parcelize/parcelize-ide/testData/quickfix/deleteIncompatible/writeToParcel.kt");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("plugins/parcelize/parcelize-ide/testData/quickfix/migrations")
|
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
|
||||||
public static class Migrations extends AbstractParcelizeQuickFixTest {
|
|
||||||
private void runTest(String testDataFilePath) throws Exception {
|
|
||||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testAllFilesPresentInMigrations() throws Exception {
|
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/parcelize/parcelize-ide/testData/quickfix/migrations"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), null, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("basic.kt")
|
|
||||||
public void testBasic() throws Exception {
|
|
||||||
runTest("plugins/parcelize/parcelize-ide/testData/quickfix/migrations/basic.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("complexCase1.kt")
|
|
||||||
public void testComplexCase1() throws Exception {
|
|
||||||
runTest("plugins/parcelize/parcelize-ide/testData/quickfix/migrations/complexCase1.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("customDescribeContents.kt")
|
|
||||||
public void testCustomDescribeContents() throws Exception {
|
|
||||||
runTest("plugins/parcelize/parcelize-ide/testData/quickfix/migrations/customDescribeContents.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("fromCreatorObject.kt")
|
|
||||||
public void testFromCreatorObject() throws Exception {
|
|
||||||
runTest("plugins/parcelize/parcelize-ide/testData/quickfix/migrations/fromCreatorObject.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("innerClassFactory.kt")
|
|
||||||
public void testInnerClassFactory() throws Exception {
|
|
||||||
runTest("plugins/parcelize/parcelize-ide/testData/quickfix/migrations/innerClassFactory.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("jvmField.kt")
|
|
||||||
public void testJvmField() throws Exception {
|
|
||||||
runTest("plugins/parcelize/parcelize-ide/testData/quickfix/migrations/jvmField.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("withoutDescribeContents.kt")
|
|
||||||
public void testWithoutDescribeContents() throws Exception {
|
|
||||||
runTest("plugins/parcelize/parcelize-ide/testData/quickfix/migrations/withoutDescribeContents.kt");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("plugins/parcelize/parcelize-ide/testData/quickfix/noParcelableSupertype")
|
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
|
||||||
public static class NoParcelableSupertype extends AbstractParcelizeQuickFixTest {
|
|
||||||
private void runTest(String testDataFilePath) throws Exception {
|
|
||||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testAllFilesPresentInNoParcelableSupertype() throws Exception {
|
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/parcelize/parcelize-ide/testData/quickfix/noParcelableSupertype"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), null, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("alreadyHasSupertype.kt")
|
|
||||||
public void testAlreadyHasSupertype() throws Exception {
|
|
||||||
runTest("plugins/parcelize/parcelize-ide/testData/quickfix/noParcelableSupertype/alreadyHasSupertype.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("simple.kt")
|
|
||||||
public void testSimple() throws Exception {
|
|
||||||
runTest("plugins/parcelize/parcelize-ide/testData/quickfix/noParcelableSupertype/simple.kt");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("plugins/parcelize/parcelize-ide/testData/quickfix/propertyWontBeSerialized")
|
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
|
||||||
public static class PropertyWontBeSerialized extends AbstractParcelizeQuickFixTest {
|
|
||||||
private void runTest(String testDataFilePath) throws Exception {
|
|
||||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testAllFilesPresentInPropertyWontBeSerialized() throws Exception {
|
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/parcelize/parcelize-ide/testData/quickfix/propertyWontBeSerialized"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), null, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("simple.kt")
|
|
||||||
public void testSimple() throws Exception {
|
|
||||||
runTest("plugins/parcelize/parcelize-ide/testData/quickfix/propertyWontBeSerialized/simple.kt");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("plugins/parcelize/parcelize-ide/testData/quickfix/removeDuplicatingTypeParcelerAnnotation")
|
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
|
||||||
public static class RemoveDuplicatingTypeParcelerAnnotation extends AbstractParcelizeQuickFixTest {
|
|
||||||
private void runTest(String testDataFilePath) throws Exception {
|
|
||||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testAllFilesPresentInRemoveDuplicatingTypeParcelerAnnotation() throws Exception {
|
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/parcelize/parcelize-ide/testData/quickfix/removeDuplicatingTypeParcelerAnnotation"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), null, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("simple.kt")
|
|
||||||
public void testSimple() throws Exception {
|
|
||||||
runTest("plugins/parcelize/parcelize-ide/testData/quickfix/removeDuplicatingTypeParcelerAnnotation/simple.kt");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-23
@@ -1,23 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2020 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.pacelize.ide.test
|
|
||||||
|
|
||||||
import com.intellij.openapi.module.Module
|
|
||||||
import org.jetbrains.kotlin.idea.test.ConfigLibraryUtil
|
|
||||||
import org.jetbrains.kotlin.test.util.KtTestUtil
|
|
||||||
|
|
||||||
fun addParcelizeLibraries(module: Module) {
|
|
||||||
val androidJar = KtTestUtil.findAndroidApiJar()
|
|
||||||
ConfigLibraryUtil.addLibrary(module, "androidJar", androidJar.parentFile.absolutePath, arrayOf(androidJar.name))
|
|
||||||
ConfigLibraryUtil.addLibrary(module, "parcelizeRuntime", "dist/kotlinc/lib", arrayOf("parcelize-runtime.jar"))
|
|
||||||
ConfigLibraryUtil.addLibrary(module, "androidExtensionsRuntime", "dist/kotlinc/lib", arrayOf("android-extensions-runtime.jar"))
|
|
||||||
}
|
|
||||||
|
|
||||||
fun removeParcelizeLibraries(module: Module) {
|
|
||||||
ConfigLibraryUtil.removeLibrary(module, "androidJar")
|
|
||||||
ConfigLibraryUtil.removeLibrary(module, "parcelizeRuntime")
|
|
||||||
ConfigLibraryUtil.removeLibrary(module, "androidExtensionsRuntime")
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user