Use ServiceLoader instead of IntelliJ extensions for DefaultErrorMessages

#KT-10473 Fixed
This commit is contained in:
Alexander Udalov
2017-10-20 20:01:19 +02:00
parent 1c6dce3674
commit 1a8be635b9
24 changed files with 128 additions and 109 deletions
@@ -0,0 +1,3 @@
# Note that this file is also present in idea/src/META-INF/services
org.jetbrains.kotlin.resolve.jvm.diagnostics.DefaultErrorMessagesJvm
org.jetbrains.kotlin.js.resolve.diagnostics.DefaultErrorMessagesJs
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.config.LanguageFeature;
import org.jetbrains.kotlin.config.LanguageVersion;
import org.jetbrains.kotlin.config.LanguageVersionSettings;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.diagnostics.rendering.DiagnosticRenderer;
import org.jetbrains.kotlin.lexer.KtKeywordToken;
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken;
import org.jetbrains.kotlin.lexer.KtTokens;
@@ -982,9 +983,9 @@ public interface Errors {
DiagnosticFactory1<PsiElement, CallableDescriptor> ILLEGAL_SUSPEND_FUNCTION_CALL = DiagnosticFactory1.create(ERROR);
DiagnosticFactory0<PsiElement> ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL = DiagnosticFactory0.create(ERROR);
DiagnosticFactory2<PsiElement, String, String> PLUGIN_ERROR = DiagnosticFactory2.create(ERROR);
DiagnosticFactory2<PsiElement, String, String> PLUGIN_WARNING = DiagnosticFactory2.create(WARNING);
DiagnosticFactory2<PsiElement, String, String> PLUGIN_INFO = DiagnosticFactory2.create(INFO);
DiagnosticFactory1<PsiElement, RenderedDiagnostic<?>> PLUGIN_ERROR = DiagnosticFactory1.create(ERROR);
DiagnosticFactory1<PsiElement, RenderedDiagnostic<?>> PLUGIN_WARNING = DiagnosticFactory1.create(WARNING);
DiagnosticFactory1<PsiElement, RenderedDiagnostic<?>> PLUGIN_INFO = DiagnosticFactory1.create(INFO);
// Function contracts
DiagnosticFactory1<KtElement, String> ERROR_IN_CONTRACT_DESCRIPTION = DiagnosticFactory1.create(ERROR);
@@ -0,0 +1,30 @@
/*
* 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.diagnostics
import org.jetbrains.kotlin.diagnostics.rendering.DiagnosticRenderer
class RenderedDiagnostic<D : Diagnostic>(
val diagnostic: D,
val renderer: DiagnosticRenderer<D>
) {
val text = renderer.render(diagnostic)
val factory: DiagnosticFactory<*> get() = diagnostic.factory
override fun toString() = text
}
@@ -168,11 +168,11 @@ fun <D : Diagnostic> DiagnosticSink.reportFromPlugin(diagnostic: D, ext: Default
val renderer = ext.map[diagnostic.factory] as? DiagnosticRenderer<D>
?: error("Renderer not found for diagnostic ${diagnostic.factory.name}")
val text = renderer.render(diagnostic)
val renderedDiagnostic = RenderedDiagnostic(diagnostic, renderer)
when (diagnostic.severity) {
Severity.ERROR -> report(Errors.PLUGIN_ERROR.on(diagnostic.psiElement, diagnostic.factory.name, text))
Severity.WARNING -> report(Errors.PLUGIN_WARNING.on(diagnostic.psiElement, diagnostic.factory.name, text))
Severity.INFO -> report(Errors.PLUGIN_INFO.on(diagnostic.psiElement, diagnostic.factory.name, text))
Severity.ERROR -> report(Errors.PLUGIN_ERROR.on(diagnostic.psiElement, renderedDiagnostic))
Severity.WARNING -> report(Errors.PLUGIN_WARNING.on(diagnostic.psiElement, renderedDiagnostic))
Severity.INFO -> report(Errors.PLUGIN_INFO.on(diagnostic.psiElement, renderedDiagnostic))
}
}
@@ -16,26 +16,27 @@
package org.jetbrains.kotlin.diagnostics.rendering;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.util.io.FileUtil;
import kotlin.Pair;
import kotlin.collections.CollectionsKt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
import org.jetbrains.kotlin.config.LanguageVersion;
import org.jetbrains.kotlin.diagnostics.Diagnostic;
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory;
import org.jetbrains.kotlin.diagnostics.Errors;
import org.jetbrains.kotlin.diagnostics.RenderedDiagnostic;
import org.jetbrains.kotlin.resolve.VarianceConflictDiagnosticData;
import org.jetbrains.kotlin.serialization.deserialization.descriptors.VersionRequirement;
import org.jetbrains.kotlin.types.KotlinTypeKt;
import org.jetbrains.kotlin.util.MappedExtensionProvider;
import org.jetbrains.kotlin.util.OperatorNameConventions;
import org.jetbrains.kotlin.utils.addToStdlib.AddToStdlibKt;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.ServiceLoader;
import static org.jetbrains.kotlin.diagnostics.Errors.*;
import static org.jetbrains.kotlin.diagnostics.rendering.Renderers.*;
@@ -44,47 +45,30 @@ import static org.jetbrains.kotlin.diagnostics.rendering.RenderingContext.of;
public class DefaultErrorMessages {
public interface Extension {
ExtensionPointName<Extension> EP_NAME = ExtensionPointName.create("org.jetbrains.kotlin.defaultErrorMessages");
@NotNull
DiagnosticFactoryToRendererMap getMap();
}
private static final DiagnosticFactoryToRendererMap MAP = new DiagnosticFactoryToRendererMap("Default");
private static final MappedExtensionProvider<Extension, List<DiagnosticFactoryToRendererMap>> RENDERER_MAPS = MappedExtensionProvider.create(
Extension.EP_NAME,
extensions -> {
List<DiagnosticFactoryToRendererMap> result = new ArrayList<>(extensions.size() + 1);
for (Extension extension : extensions) {
result.add(extension.getMap());
}
result.add(MAP);
return result;
});
private static final List<DiagnosticFactoryToRendererMap> RENDERER_MAPS =
CollectionsKt.plus(
Collections.singletonList(MAP),
CollectionsKt.map(ServiceLoader.load(Extension.class, DefaultErrorMessages.class.getClassLoader()), Extension::getMap)
);
@NotNull
@SuppressWarnings("unchecked")
public static String render(@NotNull Diagnostic diagnostic) {
for (DiagnosticFactoryToRendererMap map : RENDERER_MAPS.get()) {
DiagnosticRenderer renderer = map.get(diagnostic.getFactory());
if (renderer != null) {
//noinspection unchecked
return renderer.render(diagnostic);
}
DiagnosticRenderer renderer = getRendererForDiagnostic(diagnostic);
if (renderer != null) {
return renderer.render(diagnostic);
}
throw new IllegalArgumentException("Don't know how to render diagnostic of type " + diagnostic.getFactory().getName() +
" with the following renderer maps: " + RENDERER_MAPS.get());
return diagnostic.toString() + " (error: could not render message)";
}
@TestOnly
@Nullable
public static DiagnosticRenderer getRendererForDiagnostic(@NotNull Diagnostic diagnostic) {
for (DiagnosticFactoryToRendererMap map : RENDERER_MAPS.get()) {
DiagnosticRenderer renderer = map.get(diagnostic.getFactory());
if (renderer != null) return renderer;
}
return null;
return AddToStdlibKt.firstNotNullResult(RENDERER_MAPS, map -> map.get(diagnostic.getFactory()));
}
static {
@@ -888,9 +872,9 @@ public class DefaultErrorMessages {
MAP.put(ILLEGAL_SUSPEND_FUNCTION_CALL, "Suspend function ''{0}'' should be called only from a coroutine or another suspend function", NAME);
MAP.put(ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL, "Restricted suspending functions can only invoke member or extension suspending functions on their restricted coroutine scope");
MAP.put(PLUGIN_ERROR, "{0}: {1}", TO_STRING, TO_STRING);
MAP.put(PLUGIN_WARNING, "{0}: {1}", TO_STRING, TO_STRING);
MAP.put(PLUGIN_INFO, "{0}: {1}", TO_STRING, TO_STRING);
MAP.put(PLUGIN_ERROR, "{0}", (d, c) -> d.getText());
MAP.put(PLUGIN_WARNING, "{0}", (d, c) -> d.getText());
MAP.put(PLUGIN_INFO, "{0}", (d, c) -> d.getText());
MAP.put(ERROR_IN_CONTRACT_DESCRIPTION, "Error in contract description: {0}", TO_STRING);
MAP.put(CONTRACT_NOT_ALLOWED, "Contract is not allowed here");
@@ -46,15 +46,10 @@ protected constructor(
cached = WeakReference(newVal)
return newVal.second
}
companion object {
@JvmStatic fun <T, R> create(epName: ExtensionPointName<T>, map: (List<T>) -> R): MappedExtensionProvider<T, R>
= MappedExtensionProvider(epName, map)
}
}
class ExtensionProvider<T>(epName: ExtensionPointName<T>) : MappedExtensionProvider<T, List<T>>(epName, { it }) {
companion object {
@JvmStatic fun <T> create(epName: ExtensionPointName<T>): ExtensionProvider<T> = ExtensionProvider(epName)
}
}
}
@@ -38,6 +38,7 @@ import com.intellij.util.containers.MultiMap
import com.intellij.xml.util.XmlStringUtil
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.diagnostics.Severity
import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages
@@ -45,7 +46,10 @@ import org.jetbrains.kotlin.idea.actions.internal.KotlinInternalMode
import org.jetbrains.kotlin.idea.caches.resolve.analyzeFullyAndGetResult
import org.jetbrains.kotlin.idea.quickfix.QuickFixes
import org.jetbrains.kotlin.idea.references.mainReference
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtNameReferenceExpression
import org.jetbrains.kotlin.psi.KtParameter
import org.jetbrains.kotlin.psi.KtReferenceExpression
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics
import org.jetbrains.kotlin.types.KotlinType
@@ -111,7 +115,7 @@ open class KotlinPsiChecker : Annotator, HighlightRangeExtension {
private fun createQuickFixes(similarDiagnostics: Collection<Diagnostic>): MultiMap<Diagnostic, IntentionAction> {
val first = similarDiagnostics.minBy { it.toString() }
val factory = similarDiagnostics.first().factory
val factory = similarDiagnostics.first().getRealDiagnosticFactory()
val actions = MultiMap<Diagnostic, IntentionAction>()
@@ -137,6 +141,14 @@ private fun createQuickFixes(similarDiagnostics: Collection<Diagnostic>): MultiM
return actions
}
private fun Diagnostic.getRealDiagnosticFactory(): DiagnosticFactory<*> =
when (factory) {
Errors.PLUGIN_ERROR -> Errors.PLUGIN_ERROR.cast(this).a.factory
Errors.PLUGIN_WARNING -> Errors.PLUGIN_WARNING.cast(this).a.factory
Errors.PLUGIN_INFO -> Errors.PLUGIN_INFO.cast(this).a.factory
else -> factory
}
private object NoDeclarationDescriptorsChecker {
private val LOG = Logger.getInstance(NoDeclarationDescriptorsChecker::class.java)
-2
View File
@@ -2,8 +2,6 @@
<id>org.jetbrains.kotlin</id>
<extensionPoints>
<extensionPoint name="defaultErrorMessages"
interface="org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages$Extension"/>
<extensionPoint name="suppressStringProvider"
interface="org.jetbrains.kotlin.resolve.diagnostics.SuppressStringProvider"/>
<extensionPoint name="diagnosticSuppressor"
@@ -2,9 +2,6 @@
<id>org.jetbrains.kotlin</id>
<extensions defaultExtensionNs="org.jetbrains.kotlin">
<defaultErrorMessages implementation="org.jetbrains.kotlin.js.resolve.diagnostics.DefaultErrorMessagesJs"/>
<!--temporary: JVM diagnostics included to fix KT-10473 / EA-75782-->
<defaultErrorMessages implementation="org.jetbrains.kotlin.resolve.jvm.diagnostics.DefaultErrorMessagesJvm"/>
<suppressStringProvider implementation="org.jetbrains.kotlin.js.analyze.SuppressUnusedParameterForJsNative"/>
<suppressStringProvider implementation="org.jetbrains.kotlin.js.analyze.SuppressNoBodyErrorsForNativeDeclarations"/>
<diagnosticSuppressor implementation="org.jetbrains.kotlin.js.analyze.SuppressUninitializedErrorsForNativeDeclarations"/>
@@ -2,14 +2,8 @@
<id>org.jetbrains.kotlin</id>
<extensions defaultExtensionNs="org.jetbrains.kotlin">
<defaultErrorMessages implementation="org.jetbrains.kotlin.resolve.jvm.diagnostics.DefaultErrorMessagesJvm"/>
<!--temporary: JS diagnostics included to fix KT-10473 / EA-75782-->
<defaultErrorMessages implementation="org.jetbrains.kotlin.js.resolve.diagnostics.DefaultErrorMessagesJs"/>
<classBuilderInterceptorExtension implementation="org.jetbrains.kotlin.annotation.AnnotationCollectorExtension"/>
<analyzeCompleteHandlerExtension implementation="org.jetbrains.kotlin.resolve.jvm.AnalyzeCompleteHandlerExtension"/>
<scriptHelper implementation="org.jetbrains.kotlin.script.ScriptHelperImpl"/>
</extensions>
</idea-plugin>
@@ -0,0 +1,3 @@
# Note that this file is also present in compiler/cli/src/META-INF/services
org.jetbrains.kotlin.resolve.jvm.diagnostics.DefaultErrorMessagesJvm
org.jetbrains.kotlin.js.resolve.diagnostics.DefaultErrorMessagesJs
@@ -17,15 +17,17 @@
package org.jetbrains.kotlin.android.parcel.quickfixes
import kotlinx.android.parcel.Parcelize
import org.jetbrains.kotlin.diagnostics.DiagnosticWithParameters1
import org.jetbrains.kotlin.android.synthetic.diagnostic.ErrorsAndroid
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.idea.util.addAnnotation
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.KtClassOrObject
import org.jetbrains.kotlin.psi.KtPsiFactory
class AnnotateWithParcelizeQuickFix(clazz: KtClassOrObject) : AbstractParcelableQuickFix<KtClassOrObject>(clazz) {
object Factory : AbstractFactory({
@Suppress("UNCHECKED_CAST")
val targetClass = (this as DiagnosticWithParameters1<*, KtClassOrObject>).a
val diagnostic = Errors.PLUGIN_ERROR.cast(this).a
val targetClass = ErrorsAndroid.CLASS_SHOULD_BE_PARCELIZE.cast(diagnostic.diagnostic).a
AnnotateWithParcelizeQuickFix(targetClass)
})
@@ -34,4 +36,4 @@ class AnnotateWithParcelizeQuickFix(clazz: KtClassOrObject) : AbstractParcelable
override fun invoke(ktPsiFactory: KtPsiFactory, element: KtClassOrObject) {
element.addAnnotation(FqName(Parcelize::class.java.name))
}
}
}
@@ -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'">secondName</error>: String) : Parcelable
@Parcelize
class D(val firstName: String, vararg val secondName: String) : Parcelable
@@ -21,8 +21,8 @@ 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 a primary constructor">F</error> : Parcelable {
constructor(a: String) {
println(a)
}
}
}
@@ -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. 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)
}
@@ -17,8 +17,8 @@ class A(val a: String) : Parcelable {
@Parcelize
class B(val b: String) : Parcelable {
companion object <error descr="[CREATOR_DEFINITION_IS_NOT_ALLOWED] 'CREATOR' definition is not allowed. Use 'Parceler' companion object instead.">CREATOR</error> : Parcelable.Creator<B> {
companion object <error descr="[PLUGIN_ERROR] 'CREATOR' definition is not allowed. Use 'Parceler' companion object instead">CREATOR</error> : Parcelable.Creator<B> {
override fun createFromParcel(source: Parcel): B = B("")
override fun newArray(size: Int) = arrayOfNulls<B>(size)
}
}
}
@@ -18,27 +18,27 @@ class StringClassParceler : Parceler<String> {
override fun String.write(parcel: Parcel, flags: Int) = TODO()
}
@<error descr="[CLASS_SHOULD_BE_PARCELIZE] Class 'MissingParcelizeAnnotation' should be annotated with '@Parcelize'">TypeParceler</error><String, StringParceler>
class MissingParcelizeAnnotation(val a: @<error descr="[CLASS_SHOULD_BE_PARCELIZE] Class 'MissingParcelizeAnnotation' should be annotated with '@Parcelize'">WriteWith</error><StringParceler> String)
@<error descr="[PLUGIN_ERROR] Class 'MissingParcelizeAnnotation' should be annotated with '@Parcelize'">TypeParceler</error><String, StringParceler>
class MissingParcelizeAnnotation(val a: @<error descr="[PLUGIN_ERROR] Class 'MissingParcelizeAnnotation' should be annotated with '@Parcelize'">WriteWith</error><StringParceler> String)
@Parcelize
@TypeParceler<String, StringClassParceler>
class ShouldBeClass(val a: @WriteWith<<error descr="[PARCELER_SHOULD_BE_OBJECT] Parceler should be an object">StringClassParceler</error>> String) : Parcelable
class ShouldBeClass(val a: @WriteWith<<error descr="[PLUGIN_ERROR] Parceler should be an object">StringClassParceler</error>> String) : Parcelable
@Parcelize
class Test(
val a: @WriteWith<<error descr="[PARCELER_TYPE_INCOMPATIBLE] Parceler type String is incompatible with Int">StringParceler</error>> Int,
val a: @WriteWith<<error descr="[PLUGIN_ERROR] Parceler type String is incompatible with Int">StringParceler</error>> Int,
val b: @WriteWith<StringParceler> String,
val c: @WriteWith<<error descr="[PARCELER_TYPE_INCOMPATIBLE] Parceler type String is incompatible with CharSequence">StringParceler</error>> CharSequence,
val c: @WriteWith<<error descr="[PLUGIN_ERROR] Parceler type String is incompatible with CharSequence">StringParceler</error>> CharSequence,
val d: @WriteWith<CharSequenceParceler> String,
val e: @WriteWith<CharSequenceParceler> CharSequence
) : Parcelable
@Parcelize
@TypeParceler<String, StringParceler>
class Test2(@<warning descr="[REDUNDANT_TYPE_PARCELER] This annotation duplicates the one for Class 'Test2'">TypeParceler</warning><String, StringParceler> val a: String) : Parcelable
class Test2(@<warning descr="[PLUGIN_WARNING] This 'TypeParceler' is already provided for Class 'Test2'">TypeParceler</warning><String, StringParceler> val a: String) : Parcelable
@Parcelize
@TypeParceler<<error descr="[DUPLICATING_TYPE_PARCELERS] Duplicating ''Parceler'' annotations">String</error>, StringParceler>
@TypeParceler<<error descr="[DUPLICATING_TYPE_PARCELERS] Duplicating ''Parceler'' annotations">String</error>, CharSequenceParceler>
class Test3(val a: String) : Parcelable
@TypeParceler<<error descr="[PLUGIN_ERROR] Duplicating ''TypeParceler'' annotations">String</error>, StringParceler>
@TypeParceler<<error descr="[PLUGIN_ERROR] Duplicating ''TypeParceler'' annotations">String</error>, CharSequenceParceler>
class Test3(val a: String) : Parcelable
@@ -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 '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 '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 'writeToParcel' is not allowed. Use 'Parceler' companion object instead">override</error> fun writeToParcel(p: Parcel, flags: Int) {}
}
@@ -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] Delegating 'Parcelable' is now allowed">by</error> Delegate()
@@ -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] The primary constructor is empty, no data will be serialized to 'Parcel'">User2</warning>() : Parcelable
@@ -17,4 +17,4 @@ class Foo(val box: Box): Parcelable {
}
@Parcelize
class Foo2(val box: <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()'">Box</error>): Parcelable
class Foo2(val box: <error descr="[PLUGIN_ERROR] Type is not directly supported by 'Parcelize'. Annotate the parameter type with '@RawValue' if you want it to be serialized using 'writeValue()'">Box</error>): Parcelable
@@ -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 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 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' 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 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] 'Parcelable' can't be a local class"><error descr="[PLUGIN_ERROR] No 'Parcelable' supertype">Local</error></error> {}
}
@@ -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 '@IgnoredOnParcel' annotation to remove the warning">secondName</warning>: String = ""
val <warning descr="[PLUGIN_WARNING] Property would not be serialized into a 'Parcel'. Add '@IgnoredOnParcel' annotation to remove the warning">secondName</warning>: String = ""
val <warning descr="[PROPERTY_WONT_BE_SERIALIZED] Property would not be serialized into a 'Parcel'. Add '@IgnoredOnParcel' annotation to remove the warning">delegated</warning> by lazy { "" }
val <warning descr="[PLUGIN_WARNING] Property would not be serialized into a 'Parcel'. Add '@IgnoredOnParcel' 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 '@IgnoredOnParcel' annotation to remove the warning">lateinit</warning>: String
lateinit var <warning descr="[PLUGIN_WARNING] Property would not be serialized into a 'Parcel'. Add '@IgnoredOnParcel' annotation to remove the warning">lateinit</warning>: String
val customGetter: String
get() = ""
@@ -17,4 +17,4 @@ class A(val firstName: String) : Parcelable {
var customSetter: String
get() = ""
set(v) {}
}
}
@@ -7,11 +7,11 @@ 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] 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] 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] 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>,
val h: Map<@RawValue Any, List<@RawValue Any>>
) : Parcelable
) : Parcelable
@@ -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">Without</error>(val firstName: String, val secondName: String, val age: Int)
@Parcelize
class With(val firstName: String, val secondName: String, val age: Int) : Parcelable
@@ -17,4 +17,4 @@ abstract class MyParcelableCl : Parcelable
class WithIntfSubtype(val firstName: String, val secondName: String, val age: Int) : MyParcelableIntf
@Parcelize
class WithClSubtype(val firstName: String, val secondName: String, val age: Int) : MyParcelableCl()
class WithClSubtype(val firstName: String, val secondName: String, val age: Int) : MyParcelableCl()
@@ -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 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 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 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 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 a class">Anno</error>