Deprecated reportFromPlugin way to report diagnostics from plugin

Originally reportFromPlugin method was introduced to address the problem
with loading of DefaultErrorMessages.Extension vis ServiceLoader.
For some cases this extension was not loaded by ServiceLoader because
classes was loaded via different class loader, common scenario here is
compiler plugins. Ideally we should load such extension point via
getService approach, but unfortunately to do that we need project and
DefaultErrorMessages.render is static method for now.
Also with reportFromPlugin approach is a problem -- all diagnostics
reported via this method has the same id: PLUGIN_[WARNING|ERROR|INFO]
and it isn't possible to suppress only one particular diagnostic.
To bypass this problem the new method
initializeFactoryNamesAndDefaultErrorMessages was introduced.
It basically store DiagnosticRenderer inside DiagnosticFactory.
It is not ideal, because one DiagnosticFactory could have different
renderers for different scenarios -- for compiler and for IDE, but
I think that it is better than reportByPlugin approach.
This commit is contained in:
Stanislav Erokhin
2020-02-07 22:18:25 +03:00
parent 84baa0b4c2
commit 453008e488
20 changed files with 104 additions and 106 deletions
@@ -6,12 +6,12 @@ import kotlinx.serialization.*
class NonSerializable
@Serializable
class Basic(val foo: <!PLUGIN_ERROR("Serializer has not been found for type 'NonSerializable'. To use context serializer as fallback, explicitly annotate type or property with @ContextualSerialization")!>NonSerializable<!>)
class Basic(val foo: <!SERIALIZER_NOT_FOUND("NonSerializable")!>NonSerializable<!>)
@Serializable
class Inside(val foo: List<<!PLUGIN_ERROR("Serializer has not been found for type 'NonSerializable'. To use context serializer as fallback, explicitly annotate type or property with @ContextualSerialization")!>NonSerializable<!>>)
class Inside(val foo: List<<!SERIALIZER_NOT_FOUND("NonSerializable")!>NonSerializable<!>>)
@Serializable
class WithImplicitType {
<!PLUGIN_ERROR("Serializer has not been found for type 'NonSerializable'. To use context serializer as fallback, explicitly annotate type or property with @ContextualSerialization")!>val foo = NonSerializable()<!>
<!SERIALIZER_NOT_FOUND("NonSerializable")!>val foo = NonSerializable()<!>
}