KaDiagnostic
A diagnostic message reported by a compiler checker.
Diagnostics come either from diagnostic collection, which yields the more specific KaDiagnosticWithPsi, or from other parts of the Analysis API which expose the reason of a failure, such as KaSimpleCallResolutionError.diagnostic in KaCallResolutionAttempt.
Members
val factoryName: StringA technical name identifying the diagnostic, such as
UNRESOLVED_REFERENCE. This is the same name as reported by the compiler when the-Xrender-internal-diagnostic-namescompiler flag is enabled. Prefer it over the rendered message when a diagnostic has to be recognized programmatically.val severity: KaSeverityThe severity of the diagnostic (e.g.,
ERRORorWARNING), determined from the compiler's classification of the diagnostic.val defaultMessage: StringThe human-readable message rendered by the compiler to describe the error, warning, or info.
val isSuppressed: BooleanWhether the diagnostic is suppressed at its use site, for example by a
@Suppressannotation. Suppressed diagnostics are not reported by the compiler, so they should not be presented to the user as is. Diagnostic collection filters them out by default, andignoreSuppressed(false)yields them as well. The property is only meaningful for diagnostics obtained from diagnostic collection; for a diagnostic obtained in another way, such as the diagnostic of an unresolved call, it is alwaysfalse.Experimental API.
val diagnosticClass: KClass<*>The class of the diagnostic. For a diagnostic of the
KaFirDiagnostichierarchy, this is the interface which corresponds to the diagnostic kind, such asKaFirDiagnostic.WrongAnnotationTarget.
Utilities
fun KaDiagnostic.getDefaultMessageWithFactoryName(): StringThe
defaultMessageprefixed with thefactoryName, formatted as[FACTORY_NAME] message. Handy for logs and test data, where the rendered message alone is ambiguous.
KaSeverity
The severity property indicates how the compiler classifies the diagnostic.
Member | Description |
|---|---|
| The code is invalid and will not compile. |
| The code compiles, but the checker reports a problem with it. |
| An informational message which reports neither an error nor a problem. |