Report errors from compiler plugins as compiler PLUGIN_ERRORs (KT-19311)
This commit is contained in:
+25
-16
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.android.parcel
|
||||
|
||||
import org.jetbrains.kotlin.android.parcel.serializers.ParcelSerializer
|
||||
import org.jetbrains.kotlin.android.parcel.serializers.isParcelable
|
||||
import org.jetbrains.kotlin.android.synthetic.diagnostic.DefaultErrorMessagesAndroid
|
||||
import org.jetbrains.kotlin.android.synthetic.diagnostic.ErrorsAndroid
|
||||
import org.jetbrains.kotlin.codegen.ClassBuilderMode
|
||||
import org.jetbrains.kotlin.codegen.state.IncompatibleClassTracker
|
||||
@@ -27,6 +28,7 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
||||
import org.jetbrains.kotlin.diagnostics.reportFromPlugin
|
||||
import org.jetbrains.kotlin.fileClasses.NoResolveFileClassesProvider
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
@@ -82,7 +84,7 @@ class ParcelableDeclarationChecker : SimpleDeclarationChecker {
|
||||
|
||||
if (method.isWriteToParcel() && declaration.hasModifier(KtTokens.OVERRIDE_KEYWORD)) {
|
||||
val reportElement = declaration.modifierList?.getModifier(KtTokens.OVERRIDE_KEYWORD) ?: declaration.nameIdentifier ?: declaration
|
||||
diagnosticHolder.report(ErrorsAndroid.OVERRIDING_WRITE_TO_PARCEL_IS_NOT_ALLOWED.on(reportElement))
|
||||
diagnosticHolder.reportFromPlugin(ErrorsAndroid.OVERRIDING_WRITE_TO_PARCEL_IS_NOT_ALLOWED.on(reportElement), DefaultErrorMessagesAndroid)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,14 +99,16 @@ class ParcelableDeclarationChecker : SimpleDeclarationChecker {
|
||||
&& (declaration.hasDelegate() || bindingContext[BindingContext.BACKING_FIELD_REQUIRED, property] == true)
|
||||
&& !property.annotations.hasAnnotation(TRANSIENT_FQNAME)
|
||||
) {
|
||||
diagnosticHolder.report(ErrorsAndroid.PROPERTY_WONT_BE_SERIALIZED.on(declaration.nameIdentifier ?: declaration))
|
||||
val reportElement = declaration.nameIdentifier ?: declaration
|
||||
diagnosticHolder.reportFromPlugin(ErrorsAndroid.PROPERTY_WONT_BE_SERIALIZED.on(reportElement), DefaultErrorMessagesAndroid)
|
||||
}
|
||||
|
||||
// @JvmName is not applicable to property so we can check just the descriptor name
|
||||
if (property.name.asString() == "CREATOR" && property.findJvmFieldAnnotation() != null && containingClass.isCompanionObject) {
|
||||
val outerClass = containingClass.containingDeclaration as? ClassDescriptor
|
||||
if (outerClass != null && outerClass.isParcelize) {
|
||||
diagnosticHolder.report(ErrorsAndroid.CREATOR_DEFINITION_IS_NOT_ALLOWED.on(declaration.nameIdentifier ?: declaration))
|
||||
val reportElement = declaration.nameIdentifier ?: declaration
|
||||
diagnosticHolder.reportFromPlugin(ErrorsAndroid.CREATOR_DEFINITION_IS_NOT_ALLOWED.on(reportElement), DefaultErrorMessagesAndroid)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,33 +123,35 @@ class ParcelableDeclarationChecker : SimpleDeclarationChecker {
|
||||
|
||||
if (declaration !is KtClass || (declaration.isAnnotation() || declaration.isInterface())) {
|
||||
val reportElement = (declaration as? KtClassOrObject)?.nameIdentifier ?: declaration
|
||||
diagnosticHolder.report(ErrorsAndroid.PARCELABLE_SHOULD_BE_CLASS.on(reportElement))
|
||||
diagnosticHolder.reportFromPlugin(ErrorsAndroid.PARCELABLE_SHOULD_BE_CLASS.on(reportElement), DefaultErrorMessagesAndroid)
|
||||
return
|
||||
}
|
||||
|
||||
if (declaration.isEnum()) {
|
||||
val reportElement = (declaration as? KtClass)?.nameIdentifier ?: declaration
|
||||
diagnosticHolder.report(ErrorsAndroid.PARCELABLE_SHOULD_BE_CLASS.on(reportElement))
|
||||
diagnosticHolder.reportFromPlugin(ErrorsAndroid.PARCELABLE_SHOULD_BE_CLASS.on(reportElement), DefaultErrorMessagesAndroid)
|
||||
return
|
||||
}
|
||||
|
||||
val sealedOrAbstract = declaration.modifierList?.let { it.getModifier(KtTokens.ABSTRACT_KEYWORD) ?: it.getModifier(KtTokens.SEALED_KEYWORD) }
|
||||
if (sealedOrAbstract != null) {
|
||||
diagnosticHolder.report(ErrorsAndroid.PARCELABLE_SHOULD_BE_INSTANTIABLE.on(sealedOrAbstract))
|
||||
diagnosticHolder.reportFromPlugin(ErrorsAndroid.PARCELABLE_SHOULD_BE_INSTANTIABLE.on(sealedOrAbstract), DefaultErrorMessagesAndroid)
|
||||
}
|
||||
|
||||
if (declaration.isInner()) {
|
||||
val reportElement = declaration.modifierList?.getModifier(KtTokens.INNER_KEYWORD) ?: declaration.nameIdentifier ?: declaration
|
||||
diagnosticHolder.report(ErrorsAndroid.PARCELABLE_CANT_BE_INNER_CLASS.on(reportElement))
|
||||
diagnosticHolder.reportFromPlugin(ErrorsAndroid.PARCELABLE_CANT_BE_INNER_CLASS.on(reportElement), DefaultErrorMessagesAndroid)
|
||||
}
|
||||
|
||||
if (declaration.isLocal) {
|
||||
diagnosticHolder.report(ErrorsAndroid.PARCELABLE_CANT_BE_LOCAL_CLASS.on(declaration.nameIdentifier ?: declaration))
|
||||
val reportElement = declaration.nameIdentifier ?: declaration
|
||||
diagnosticHolder.reportFromPlugin(ErrorsAndroid.PARCELABLE_CANT_BE_LOCAL_CLASS.on(reportElement), DefaultErrorMessagesAndroid)
|
||||
}
|
||||
|
||||
val superTypes = TypeUtils.getAllSupertypes(descriptor.defaultType)
|
||||
if (superTypes.none { it.constructor.declarationDescriptor?.fqNameSafe == ANDROID_PARCELABLE_CLASS_FQNAME }) {
|
||||
diagnosticHolder.report(ErrorsAndroid.NO_PARCELABLE_SUPERTYPE.on(declaration.nameIdentifier ?: declaration))
|
||||
val reportElement = declaration.nameIdentifier ?: declaration
|
||||
diagnosticHolder.reportFromPlugin(ErrorsAndroid.NO_PARCELABLE_SUPERTYPE.on(reportElement), DefaultErrorMessagesAndroid)
|
||||
}
|
||||
|
||||
for (supertypeEntry in declaration.superTypeListEntries) {
|
||||
@@ -154,15 +160,17 @@ class ParcelableDeclarationChecker : SimpleDeclarationChecker {
|
||||
val type = bindingContext[BindingContext.TYPE, supertypeEntry.typeReference] ?: continue
|
||||
if (type.isParcelable()) {
|
||||
val reportElement = supertypeEntry.byKeywordNode?.psi ?: delegateExpression
|
||||
diagnosticHolder.report(ErrorsAndroid.PARCELABLE_DELEGATE_IS_NOT_ALLOWED.on(reportElement))
|
||||
diagnosticHolder.reportFromPlugin(ErrorsAndroid.PARCELABLE_DELEGATE_IS_NOT_ALLOWED.on(reportElement), DefaultErrorMessagesAndroid)
|
||||
}
|
||||
}
|
||||
|
||||
val primaryConstructor = declaration.primaryConstructor
|
||||
if (primaryConstructor == null && declaration.secondaryConstructors.isNotEmpty()) {
|
||||
diagnosticHolder.report(ErrorsAndroid.PARCELABLE_SHOULD_HAVE_PRIMARY_CONSTRUCTOR.on(declaration.nameIdentifier ?: declaration))
|
||||
val reportElement = declaration.nameIdentifier ?: declaration
|
||||
diagnosticHolder.reportFromPlugin(ErrorsAndroid.PARCELABLE_SHOULD_HAVE_PRIMARY_CONSTRUCTOR.on(reportElement), DefaultErrorMessagesAndroid)
|
||||
} else if (primaryConstructor != null && primaryConstructor.valueParameters.isEmpty()) {
|
||||
diagnosticHolder.report(ErrorsAndroid.PARCELABLE_PRIMARY_CONSTRUCTOR_IS_EMPTY.on(declaration.nameIdentifier ?: declaration))
|
||||
val reportElement = declaration.nameIdentifier ?: declaration
|
||||
diagnosticHolder.reportFromPlugin(ErrorsAndroid.PARCELABLE_PRIMARY_CONSTRUCTOR_IS_EMPTY.on(reportElement), DefaultErrorMessagesAndroid)
|
||||
}
|
||||
|
||||
val typeMapper = KotlinTypeMapper(
|
||||
@@ -181,8 +189,9 @@ class ParcelableDeclarationChecker : SimpleDeclarationChecker {
|
||||
|
||||
private fun checkParcelableClassProperty(parameter: KtParameter, diagnosticHolder: DiagnosticSink, typeMapper: KotlinTypeMapper) {
|
||||
if (!parameter.hasValOrVar()) {
|
||||
diagnosticHolder.report(ErrorsAndroid.PARCELABLE_CONSTRUCTOR_PARAMETER_SHOULD_BE_VAL_OR_VAR.on(
|
||||
parameter.nameIdentifier ?: parameter))
|
||||
val reportElement = parameter.nameIdentifier ?: parameter
|
||||
diagnosticHolder.reportFromPlugin(
|
||||
ErrorsAndroid.PARCELABLE_CONSTRUCTOR_PARAMETER_SHOULD_BE_VAL_OR_VAR.on(reportElement), DefaultErrorMessagesAndroid)
|
||||
}
|
||||
|
||||
val descriptor = typeMapper.bindingContext[BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, parameter] ?: return
|
||||
@@ -196,8 +205,8 @@ class ParcelableDeclarationChecker : SimpleDeclarationChecker {
|
||||
}
|
||||
catch (e: IllegalArgumentException) {
|
||||
// get() throws IllegalArgumentException on unknown types
|
||||
diagnosticHolder.report(ErrorsAndroid.PARCELABLE_TYPE_NOT_SUPPORTED.on(
|
||||
parameter.typeReference ?: parameter.nameIdentifier ?: parameter))
|
||||
val reportElement = parameter.typeReference ?: parameter.nameIdentifier ?: parameter
|
||||
diagnosticHolder.reportFromPlugin(ErrorsAndroid.PARCELABLE_TYPE_NOT_SUPPORTED.on(reportElement), DefaultErrorMessagesAndroid)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-1
@@ -117,7 +117,6 @@ class AndroidComponentRegistrar : ComponentRegistrar {
|
||||
|
||||
ExpressionCodegenExtension.registerExtension(project, CliAndroidExtensionsExpressionCodegenExtension(isExperimental, globalCacheImpl))
|
||||
StorageComponentContainerContributor.registerExtension(project, AndroidExtensionPropertiesComponentContainerContributor())
|
||||
Extensions.getRootArea().getExtensionPoint(DefaultErrorMessages.Extension.EP_NAME).registerExtension(DefaultErrorMessagesAndroid())
|
||||
ClassBuilderInterceptorExtension.registerExtension(project, CliAndroidOnDestroyClassBuilderInterceptorExtension(globalCacheImpl))
|
||||
PackageFragmentProviderExtension.registerExtension(project, CliAndroidPackageFragmentProviderExtension(isExperimental))
|
||||
}
|
||||
|
||||
+5
-4
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.android.synthetic.res.AndroidSyntheticProperty
|
||||
import org.jetbrains.kotlin.android.synthetic.res.isErrorType
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
||||
import org.jetbrains.kotlin.diagnostics.reportFromPlugin
|
||||
import org.jetbrains.kotlin.psi.KtDotQualifiedExpression
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
@@ -50,7 +51,7 @@ class AndroidExtensionPropertiesCallChecker : CallChecker {
|
||||
|
||||
private fun DiagnosticSink.checkDeprecated(expression: KtExpression, packageDescriptor: AndroidSyntheticPackageFragmentDescriptor) {
|
||||
if (packageDescriptor.packageData.isDeprecated) {
|
||||
report(SYNTHETIC_DEPRECATED_PACKAGE.on(expression))
|
||||
reportFromPlugin(SYNTHETIC_DEPRECATED_PACKAGE.on(expression), DefaultErrorMessagesAndroid)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +60,7 @@ class AndroidExtensionPropertiesCallChecker : CallChecker {
|
||||
val type = property.errorType ?: return
|
||||
|
||||
val warning = if (type.contains('.')) SYNTHETIC_UNRESOLVED_WIDGET_TYPE else SYNTHETIC_INVALID_WIDGET_TYPE
|
||||
report(warning.on(expression, type))
|
||||
reportFromPlugin(warning.on(expression, type), DefaultErrorMessagesAndroid)
|
||||
}
|
||||
|
||||
private fun DiagnosticSink.checkPartiallyDefinedResource(
|
||||
@@ -72,7 +73,7 @@ class AndroidExtensionPropertiesCallChecker : CallChecker {
|
||||
|
||||
val expectedType = context.resolutionContext.expectedType
|
||||
if (!TypeUtils.noExpectedType(expectedType) && !expectedType.isMarkedNullable && !expectedType.isFlexible()) {
|
||||
report(UNSAFE_CALL_ON_PARTIALLY_DEFINED_RESOURCE.on(calleeExpression))
|
||||
reportFromPlugin(UNSAFE_CALL_ON_PARTIALLY_DEFINED_RESOURCE.on(calleeExpression), DefaultErrorMessagesAndroid)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -80,7 +81,7 @@ class AndroidExtensionPropertiesCallChecker : CallChecker {
|
||||
val usage = outermostQualifiedExpression.parent
|
||||
|
||||
if (usage is KtDotQualifiedExpression && usage.receiverExpression == outermostQualifiedExpression) {
|
||||
report(UNSAFE_CALL_ON_PARTIALLY_DEFINED_RESOURCE.on(calleeExpression))
|
||||
reportFromPlugin(UNSAFE_CALL_ON_PARTIALLY_DEFINED_RESOURCE.on(calleeExpression), DefaultErrorMessagesAndroid)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+61
-65
@@ -20,70 +20,66 @@ import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.DiagnosticFactoryToRendererMap
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.Renderers
|
||||
|
||||
class DefaultErrorMessagesAndroid : DefaultErrorMessages.Extension {
|
||||
|
||||
private companion object {
|
||||
val MAP = DiagnosticFactoryToRendererMap("Android")
|
||||
|
||||
init {
|
||||
MAP.put(ErrorsAndroid.SYNTHETIC_INVALID_WIDGET_TYPE,
|
||||
"Widget has an invalid type ''{0}''. Please specify the fully qualified widget class name in XML",
|
||||
Renderers.TO_STRING)
|
||||
|
||||
MAP.put(ErrorsAndroid.SYNTHETIC_UNRESOLVED_WIDGET_TYPE,
|
||||
"Widget has an unresolved type ''{0}'', and thus it was upcasted to ''android.view.View''",
|
||||
Renderers.TO_STRING)
|
||||
|
||||
MAP.put(ErrorsAndroid.SYNTHETIC_DEPRECATED_PACKAGE,
|
||||
"Use properties from the build variant packages")
|
||||
|
||||
MAP.put(ErrorsAndroid.UNSAFE_CALL_ON_PARTIALLY_DEFINED_RESOURCE,
|
||||
"Potential NullPointerException. The resource is missing in some of layout versions")
|
||||
|
||||
MAP.put(ErrorsAndroid.PARCELABLE_SHOULD_BE_CLASS,
|
||||
"'Parcelable' should be a class")
|
||||
|
||||
MAP.put(ErrorsAndroid.PARCELABLE_DELEGATE_IS_NOT_ALLOWED,
|
||||
"Delegating 'Parcelable' is now allowed")
|
||||
|
||||
MAP.put(ErrorsAndroid.PARCELABLE_SHOULD_NOT_BE_ENUM_CLASS,
|
||||
"'Parcelable' should not be a 'enum class'")
|
||||
|
||||
MAP.put(ErrorsAndroid.PARCELABLE_SHOULD_BE_INSTANTIABLE,
|
||||
"'Parcelable' should not be a 'sealed' or 'abstract' class")
|
||||
|
||||
MAP.put(ErrorsAndroid.PARCELABLE_CANT_BE_INNER_CLASS,
|
||||
"'Parcelable' can't be an inner class")
|
||||
|
||||
MAP.put(ErrorsAndroid.PARCELABLE_CANT_BE_LOCAL_CLASS,
|
||||
"'Parcelable' can't be a local class")
|
||||
|
||||
MAP.put(ErrorsAndroid.NO_PARCELABLE_SUPERTYPE,
|
||||
"No 'Parcelable' supertype")
|
||||
|
||||
MAP.put(ErrorsAndroid.PARCELABLE_SHOULD_HAVE_PRIMARY_CONSTRUCTOR,
|
||||
"'Parcelable' should have a primary constructor")
|
||||
|
||||
MAP.put(ErrorsAndroid.PARCELABLE_PRIMARY_CONSTRUCTOR_IS_EMPTY,
|
||||
"The primary constructor is empty, no data will be serialized to 'Parcel'")
|
||||
|
||||
MAP.put(ErrorsAndroid.PARCELABLE_CONSTRUCTOR_PARAMETER_SHOULD_BE_VAL_OR_VAR,
|
||||
"'Parcelable' constructor parameter should be 'val' or 'var'")
|
||||
|
||||
MAP.put(ErrorsAndroid.PROPERTY_WONT_BE_SERIALIZED,
|
||||
"Property would not be serialized into a 'Parcel'. Add '@Transient' annotation to it")
|
||||
|
||||
MAP.put(ErrorsAndroid.OVERRIDING_WRITE_TO_PARCEL_IS_NOT_ALLOWED,
|
||||
"Overriding 'writeToParcel' is not allowed. Use 'Parceler' companion object instead.")
|
||||
|
||||
MAP.put(ErrorsAndroid.CREATOR_DEFINITION_IS_NOT_ALLOWED,
|
||||
"'CREATOR' definition is not allowed. Use 'Parceler' companion object instead.")
|
||||
|
||||
MAP.put(ErrorsAndroid.PARCELABLE_TYPE_NOT_SUPPORTED,
|
||||
"Type is not directly supported by 'Parcelize'. " +
|
||||
"Annotate the parameter type with '@RawValue' if you want it to be serialized using 'writeValue()'")
|
||||
}
|
||||
}
|
||||
|
||||
object DefaultErrorMessagesAndroid : DefaultErrorMessages.Extension {
|
||||
private val MAP = DiagnosticFactoryToRendererMap("Android")
|
||||
override fun getMap() = MAP
|
||||
|
||||
init {
|
||||
MAP.put(ErrorsAndroid.SYNTHETIC_INVALID_WIDGET_TYPE,
|
||||
"Widget has an invalid type ''{0}''. Please specify the fully qualified widget class name in XML",
|
||||
Renderers.TO_STRING)
|
||||
|
||||
MAP.put(ErrorsAndroid.SYNTHETIC_UNRESOLVED_WIDGET_TYPE,
|
||||
"Widget has an unresolved type ''{0}'', and thus it was upcasted to ''android.view.View''",
|
||||
Renderers.TO_STRING)
|
||||
|
||||
MAP.put(ErrorsAndroid.SYNTHETIC_DEPRECATED_PACKAGE,
|
||||
"Use properties from the build variant packages")
|
||||
|
||||
MAP.put(ErrorsAndroid.UNSAFE_CALL_ON_PARTIALLY_DEFINED_RESOURCE,
|
||||
"Potential NullPointerException. The resource is missing in some of layout versions")
|
||||
|
||||
MAP.put(ErrorsAndroid.PARCELABLE_SHOULD_BE_CLASS,
|
||||
"'Parcelable' should be a class")
|
||||
|
||||
MAP.put(ErrorsAndroid.PARCELABLE_DELEGATE_IS_NOT_ALLOWED,
|
||||
"Delegating 'Parcelable' is now allowed")
|
||||
|
||||
MAP.put(ErrorsAndroid.PARCELABLE_SHOULD_NOT_BE_ENUM_CLASS,
|
||||
"'Parcelable' should not be a 'enum class'")
|
||||
|
||||
MAP.put(ErrorsAndroid.PARCELABLE_SHOULD_BE_INSTANTIABLE,
|
||||
"'Parcelable' should not be a 'sealed' or 'abstract' class")
|
||||
|
||||
MAP.put(ErrorsAndroid.PARCELABLE_CANT_BE_INNER_CLASS,
|
||||
"'Parcelable' can't be an inner class")
|
||||
|
||||
MAP.put(ErrorsAndroid.PARCELABLE_CANT_BE_LOCAL_CLASS,
|
||||
"'Parcelable' can't be a local class")
|
||||
|
||||
MAP.put(ErrorsAndroid.NO_PARCELABLE_SUPERTYPE,
|
||||
"No 'Parcelable' supertype")
|
||||
|
||||
MAP.put(ErrorsAndroid.PARCELABLE_SHOULD_HAVE_PRIMARY_CONSTRUCTOR,
|
||||
"'Parcelable' should have a primary constructor")
|
||||
|
||||
MAP.put(ErrorsAndroid.PARCELABLE_PRIMARY_CONSTRUCTOR_IS_EMPTY,
|
||||
"The primary constructor is empty, no data will be serialized to 'Parcel'")
|
||||
|
||||
MAP.put(ErrorsAndroid.PARCELABLE_CONSTRUCTOR_PARAMETER_SHOULD_BE_VAL_OR_VAR,
|
||||
"'Parcelable' constructor parameter should be 'val' or 'var'")
|
||||
|
||||
MAP.put(ErrorsAndroid.PROPERTY_WONT_BE_SERIALIZED,
|
||||
"Property would not be serialized into a 'Parcel'. Add '@Transient' annotation to it")
|
||||
|
||||
MAP.put(ErrorsAndroid.OVERRIDING_WRITE_TO_PARCEL_IS_NOT_ALLOWED,
|
||||
"Overriding 'writeToParcel' is not allowed. Use 'Parceler' companion object instead.")
|
||||
|
||||
MAP.put(ErrorsAndroid.CREATOR_DEFINITION_IS_NOT_ALLOWED,
|
||||
"'CREATOR' definition is not allowed. Use 'Parceler' companion object instead.")
|
||||
|
||||
MAP.put(ErrorsAndroid.PARCELABLE_TYPE_NOT_SUPPORTED,
|
||||
"Type is not directly supported by 'Parcelize'. " +
|
||||
"Annotate the parameter type with '@RawValue' if you want it to be serialized using 'writeValue()'")
|
||||
}
|
||||
}
|
||||
Vendored
+2
-2
@@ -10,7 +10,7 @@ class A : Parcelable
|
||||
class B(val firstName: String, val secondName: String) : Parcelable
|
||||
|
||||
@Parcelize
|
||||
class C(val firstName: String, <error descr="[PARCELABLE_CONSTRUCTOR_PARAMETER_SHOULD_BE_VAL_OR_VAR] 'Parcelable' constructor parameter should be 'val' or 'var'">secondName</error>: String) : Parcelable
|
||||
class C(val firstName: String, <error descr="[PLUGIN_ERROR] PARCELABLE_CONSTRUCTOR_PARAMETER_SHOULD_BE_VAL_OR_VAR: 'Parcelable' constructor parameter should be 'val' or 'var'">secondName</error>: String) : Parcelable
|
||||
|
||||
@Parcelize
|
||||
class D(val firstName: String, vararg val secondName: String) : Parcelable
|
||||
@@ -21,7 +21,7 @@ class E(val firstName: String, val secondName: String) : Parcelable {
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
class <error descr="[PARCELABLE_SHOULD_HAVE_PRIMARY_CONSTRUCTOR] 'Parcelable' should have a primary constructor">F</error> : Parcelable {
|
||||
class <error descr="[PLUGIN_ERROR] PARCELABLE_SHOULD_HAVE_PRIMARY_CONSTRUCTOR: 'Parcelable' should have a primary constructor">F</error> : Parcelable {
|
||||
constructor(a: String) {
|
||||
println(a)
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -8,7 +8,7 @@ import android.os.Parcel
|
||||
class A(val a: String) : Parcelable {
|
||||
companion object {
|
||||
@JvmField
|
||||
val <error descr="[CREATOR_DEFINITION_IS_NOT_ALLOWED] 'CREATOR' definition is not allowed. Use 'Parceler' companion object instead.">CREATOR</error> = object : Parcelable.Creator<A> {
|
||||
val <error descr="[PLUGIN_ERROR] CREATOR_DEFINITION_IS_NOT_ALLOWED: 'CREATOR' definition is not allowed. Use 'Parceler' companion object instead.">CREATOR</error> = object : Parcelable.Creator<A> {
|
||||
override fun createFromParcel(source: Parcel): A = A("")
|
||||
override fun newArray(size: Int) = arrayOfNulls<A>(size)
|
||||
}
|
||||
|
||||
+3
-3
@@ -6,16 +6,16 @@ import android.os.Parcel
|
||||
|
||||
@Parcelize
|
||||
class A(val a: String) : Parcelable {
|
||||
<error descr="[OVERRIDING_WRITE_TO_PARCEL_IS_NOT_ALLOWED] Overriding 'writeToParcel' is not allowed. Use 'Parceler' companion object instead.">override</error> fun writeToParcel(p: Parcel?, flags: Int) {}
|
||||
<error descr="[PLUGIN_ERROR] OVERRIDING_WRITE_TO_PARCEL_IS_NOT_ALLOWED: Overriding 'writeToParcel' is not allowed. Use 'Parceler' companion object instead.">override</error> fun writeToParcel(p: Parcel?, flags: Int) {}
|
||||
override fun describeContents() = 0
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
class B(val a: String) : Parcelable {
|
||||
<error descr="[OVERRIDING_WRITE_TO_PARCEL_IS_NOT_ALLOWED] Overriding 'writeToParcel' is not allowed. Use 'Parceler' companion object instead.">override</error> fun writeToParcel(p: Parcel?, flags: Int) {}
|
||||
<error descr="[PLUGIN_ERROR] OVERRIDING_WRITE_TO_PARCEL_IS_NOT_ALLOWED: Overriding 'writeToParcel' is not allowed. Use 'Parceler' companion object instead.">override</error> fun writeToParcel(p: Parcel?, flags: Int) {}
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
class C(val a: String) : Parcelable {
|
||||
<error descr="[OVERRIDING_WRITE_TO_PARCEL_IS_NOT_ALLOWED] Overriding 'writeToParcel' is not allowed. Use 'Parceler' companion object instead.">override</error> fun writeToParcel(p: Parcel, flags: Int) {}
|
||||
<error descr="[PLUGIN_ERROR] OVERRIDING_WRITE_TO_PARCEL_IS_NOT_ALLOWED: Overriding 'writeToParcel' is not allowed. Use 'Parceler' companion object instead.">override</error> fun writeToParcel(p: Parcel, flags: Int) {}
|
||||
}
|
||||
Vendored
+1
-1
@@ -10,4 +10,4 @@ open class Delegate : Parcelable {
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
class Test : Parcelable <error descr="[PARCELABLE_DELEGATE_IS_NOT_ALLOWED] Delegating 'Parcelable' is now allowed">by</error> Delegate()
|
||||
class Test : Parcelable <error descr="[PLUGIN_ERROR] PARCELABLE_DELEGATE_IS_NOT_ALLOWED: Delegating 'Parcelable' is now allowed">by</error> Delegate()
|
||||
+1
-1
@@ -7,4 +7,4 @@ import android.os.Parcelable
|
||||
class User : Parcelable
|
||||
|
||||
@Parcelize
|
||||
class <warning descr="[PARCELABLE_PRIMARY_CONSTRUCTOR_IS_EMPTY] The primary constructor is empty, no data will be serialized to 'Parcel'">User2</warning>() : Parcelable
|
||||
class <warning descr="[PLUGIN_WARNING] PARCELABLE_PRIMARY_CONSTRUCTOR_IS_EMPTY: The primary constructor is empty, no data will be serialized to 'Parcel'">User2</warning>() : Parcelable
|
||||
Vendored
+5
-5
@@ -10,22 +10,22 @@ open class Open(val foo: String) : Parcelable
|
||||
class Final(val foo: String) : Parcelable
|
||||
|
||||
@Parcelize
|
||||
<error descr="[PARCELABLE_SHOULD_BE_INSTANTIABLE] 'Parcelable' should not be a 'sealed' or 'abstract' class">abstract</error> class Abstract(val foo: String) : Parcelable
|
||||
<error descr="[PLUGIN_ERROR] PARCELABLE_SHOULD_BE_INSTANTIABLE: 'Parcelable' should not be a 'sealed' or 'abstract' class">abstract</error> class Abstract(val foo: String) : Parcelable
|
||||
|
||||
@Parcelize
|
||||
<error descr="[PARCELABLE_SHOULD_BE_INSTANTIABLE] 'Parcelable' should not be a 'sealed' or 'abstract' class">sealed</error> class Sealed(val foo: String) : Parcelable {
|
||||
<error descr="[PLUGIN_ERROR] PARCELABLE_SHOULD_BE_INSTANTIABLE: 'Parcelable' should not be a 'sealed' or 'abstract' class">sealed</error> class Sealed(val foo: String) : Parcelable {
|
||||
class X : Sealed("")
|
||||
}
|
||||
|
||||
class Outer {
|
||||
@Parcelize
|
||||
<error descr="[PARCELABLE_CANT_BE_INNER_CLASS] 'Parcelable' can't be an inner class">inner</error> class Inner(val foo: String) : Parcelable
|
||||
<error descr="[PLUGIN_ERROR] PARCELABLE_CANT_BE_INNER_CLASS: 'Parcelable' can't be an inner class">inner</error> class Inner(val foo: String) : Parcelable
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
@Parcelize
|
||||
<error descr="[PARCELABLE_SHOULD_BE_CLASS] 'Parcelable' should be a class">object</error> : Parcelable {}
|
||||
<error descr="[PLUGIN_ERROR] PARCELABLE_SHOULD_BE_CLASS: 'Parcelable' should be a class">object</error> : Parcelable {}
|
||||
|
||||
@Parcelize
|
||||
class <error descr="[NO_PARCELABLE_SUPERTYPE] No 'Parcelable' supertype"><error descr="[PARCELABLE_CANT_BE_LOCAL_CLASS] 'Parcelable' can't be a local class">Local</error></error> {}
|
||||
class <error descr="[PLUGIN_ERROR] NO_PARCELABLE_SUPERTYPE: No 'Parcelable' supertype"><error descr="[PLUGIN_ERROR] PARCELABLE_CANT_BE_LOCAL_CLASS: 'Parcelable' can't be a local class">Local</error></error> {}
|
||||
}
|
||||
Vendored
+3
-3
@@ -5,11 +5,11 @@ import android.os.Parcelable
|
||||
|
||||
@Parcelize
|
||||
class A(val firstName: String) : Parcelable {
|
||||
val <warning descr="[PROPERTY_WONT_BE_SERIALIZED] Property would not be serialized into a 'Parcel'. Add '@Transient' annotation to it">secondName</warning>: String = ""
|
||||
val <warning descr="[PLUGIN_WARNING] PROPERTY_WONT_BE_SERIALIZED: Property would not be serialized into a 'Parcel'. Add '@Transient' annotation to remove the warning">secondName</warning>: String = ""
|
||||
|
||||
val <warning descr="[PROPERTY_WONT_BE_SERIALIZED] Property would not be serialized into a 'Parcel'. Add '@Transient' annotation to it">delegated</warning> by lazy { "" }
|
||||
val <warning descr="[PLUGIN_WARNING] PROPERTY_WONT_BE_SERIALIZED: Property would not be serialized into a 'Parcel'. Add '@Transient' annotation to remove the warning">delegated</warning> by lazy { "" }
|
||||
|
||||
lateinit var <warning descr="[PROPERTY_WONT_BE_SERIALIZED] Property would not be serialized into a 'Parcel'. Add '@Transient' annotation to it">lateinit</warning>: String
|
||||
lateinit var <warning descr="[PLUGIN_WARNING] PROPERTY_WONT_BE_SERIALIZED: Property would not be serialized into a 'Parcel'. Add '@Transient' annotation to remove the warning">lateinit</warning>: String
|
||||
|
||||
val customGetter: String
|
||||
get() = ""
|
||||
|
||||
+3
-3
@@ -7,9 +7,9 @@ import android.os.Parcelable
|
||||
@Parcelize
|
||||
class User(
|
||||
val a: String,
|
||||
val b: <error descr="[PARCELABLE_TYPE_NOT_SUPPORTED] Type is not directly supported by 'Parcelize'. Annotate the parameter type with '@RawValue' if you want it to be serialized using 'writeValue()'">Any</error>,
|
||||
val c: <error descr="[PARCELABLE_TYPE_NOT_SUPPORTED] Type is not directly supported by 'Parcelize'. Annotate the parameter type with '@RawValue' if you want it to be serialized using 'writeValue()'">Any?</error>,
|
||||
val d: <error descr="[PARCELABLE_TYPE_NOT_SUPPORTED] Type is not directly supported by 'Parcelize'. Annotate the parameter type with '@RawValue' if you want it to be serialized using 'writeValue()'">Map<Any, String></error>,
|
||||
val b: <error descr="[PLUGIN_ERROR] PARCELABLE_TYPE_NOT_SUPPORTED: Type is not directly supported by 'Parcelize'. Annotate the parameter type with '@RawValue' if you want it to be serialized using 'writeValue()'">Any</error>,
|
||||
val c: <error descr="[PLUGIN_ERROR] PARCELABLE_TYPE_NOT_SUPPORTED: Type is not directly supported by 'Parcelize'. Annotate the parameter type with '@RawValue' if you want it to be serialized using 'writeValue()'">Any?</error>,
|
||||
val d: <error descr="[PLUGIN_ERROR] PARCELABLE_TYPE_NOT_SUPPORTED: Type is not directly supported by 'Parcelize'. Annotate the parameter type with '@RawValue' if you want it to be serialized using 'writeValue()'">Map<Any, String></error>,
|
||||
val e: @RawValue Any?,
|
||||
val f: @RawValue Map<String, Any>,
|
||||
val g: Map<String, @RawValue Any>,
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import kotlinx.android.parcel.Parcelize
|
||||
import android.os.Parcelable
|
||||
|
||||
@Parcelize
|
||||
class <error descr="[NO_PARCELABLE_SUPERTYPE] No 'Parcelable' supertype">Without</error>(val firstName: String, val secondName: String, val age: Int)
|
||||
class <error descr="[PLUGIN_ERROR] NO_PARCELABLE_SUPERTYPE: No 'Parcelable' supertype">Without</error>(val firstName: String, val secondName: String, val age: Int)
|
||||
|
||||
@Parcelize
|
||||
class With(val firstName: String, val secondName: String, val age: Int) : Parcelable
|
||||
|
||||
+5
-5
@@ -4,22 +4,22 @@ import kotlinx.android.parcel.Parcelize
|
||||
import android.os.Parcelable
|
||||
|
||||
@Parcelize
|
||||
interface <error descr="[PARCELABLE_SHOULD_BE_CLASS] 'Parcelable' should be a class">Intf</error> : Parcelable
|
||||
interface <error descr="[PLUGIN_ERROR] PARCELABLE_SHOULD_BE_CLASS: 'Parcelable' should be a class">Intf</error> : Parcelable
|
||||
|
||||
@Parcelize
|
||||
object <error descr="[PARCELABLE_SHOULD_BE_CLASS] 'Parcelable' should be a class">Obj</error>
|
||||
object <error descr="[PLUGIN_ERROR] PARCELABLE_SHOULD_BE_CLASS: 'Parcelable' should be a class">Obj</error>
|
||||
|
||||
class A {
|
||||
@Parcelize
|
||||
companion <error descr="[PARCELABLE_SHOULD_BE_CLASS] 'Parcelable' should be a class">object</error> {
|
||||
companion <error descr="[PLUGIN_ERROR] PARCELABLE_SHOULD_BE_CLASS: 'Parcelable' should be a class">object</error> {
|
||||
fun foo() {}
|
||||
}
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
enum class <error descr="[PARCELABLE_SHOULD_BE_CLASS] 'Parcelable' should be a class">Enum</error> {
|
||||
enum class <error descr="[PLUGIN_ERROR] PARCELABLE_SHOULD_BE_CLASS: 'Parcelable' should be a class">Enum</error> {
|
||||
WHITE, BLACK
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
annotation class <error descr="[PARCELABLE_SHOULD_BE_CLASS] 'Parcelable' should be a class">Anno</error>
|
||||
annotation class <error descr="[PLUGIN_ERROR] PARCELABLE_SHOULD_BE_CLASS: 'Parcelable' should be a class">Anno</error>
|
||||
Reference in New Issue
Block a user