Add multiple renderer sources support to new diagnostics infrastructure
This commit is contained in:
+3
-3
@@ -10,10 +10,10 @@ import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.analysis.api.ValidityTokenOwner
|
||||
import org.jetbrains.kotlin.analysis.api.diagnostics.KtDiagnosticWithPsi
|
||||
import org.jetbrains.kotlin.analysis.api.withValidityAssertion
|
||||
import org.jetbrains.kotlin.diagnostics.Severity
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDefaultErrorMessages
|
||||
import org.jetbrains.kotlin.diagnostics.KtDiagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.KtPsiDiagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.Severity
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.RootDiagnosticRendererFactory
|
||||
|
||||
internal interface KtAbstractFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI>, ValidityTokenOwner {
|
||||
val firDiagnostic: KtPsiDiagnostic
|
||||
@@ -25,7 +25,7 @@ internal interface KtAbstractFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithP
|
||||
get() = withValidityAssertion {
|
||||
val diagnostic = firDiagnostic as KtDiagnostic
|
||||
|
||||
val firDiagnosticRenderer = FirDefaultErrorMessages.getRendererForDiagnostic(diagnostic)
|
||||
val firDiagnosticRenderer = RootDiagnosticRendererFactory(diagnostic)
|
||||
return firDiagnosticRenderer.render(diagnostic)
|
||||
}
|
||||
|
||||
|
||||
+1
-11
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.analysis.low.level.api.fir.diagnostics
|
||||
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.sessions.module
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.analysis.CheckersComponentInternal
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.*
|
||||
@@ -16,10 +17,8 @@ import org.jetbrains.kotlin.fir.analysis.checkers.expression.ExpressionCheckers
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.type.TypeCheckers
|
||||
import org.jetbrains.kotlin.fir.analysis.collectors.AbstractDiagnosticCollector
|
||||
import org.jetbrains.kotlin.fir.analysis.collectors.components.*
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
|
||||
import org.jetbrains.kotlin.fir.analysis.jvm.checkers.JvmDeclarationCheckers
|
||||
import org.jetbrains.kotlin.fir.analysis.jvm.checkers.JvmExpressionCheckers
|
||||
import org.jetbrains.kotlin.fir.analysis.jvm.diagnostics.FirJvmDefaultErrorMessages
|
||||
import org.jetbrains.kotlin.fir.moduleData
|
||||
import org.jetbrains.kotlin.platform.SimplePlatform
|
||||
import org.jetbrains.kotlin.platform.jvm.JvmPlatform
|
||||
@@ -43,7 +42,6 @@ private object CheckersFactory {
|
||||
): List<AbstractDiagnosticCollectorComponent> {
|
||||
val module = session.moduleData.module
|
||||
val platform = module.platform.componentPlatforms.first()
|
||||
installPlatformSpecificErrorMessages(platform)
|
||||
val declarationCheckers = createDeclarationCheckers(useExtendedCheckers, platform)
|
||||
val expressionCheckers = createExpressionCheckers(useExtendedCheckers, platform)
|
||||
val typeCheckers = createTypeCheckers(useExtendedCheckers)
|
||||
@@ -91,14 +89,6 @@ private object CheckersFactory {
|
||||
}
|
||||
}
|
||||
|
||||
private fun installPlatformSpecificErrorMessages(platform: SimplePlatform) {
|
||||
when (platform) {
|
||||
is JvmPlatform -> FirJvmDefaultErrorMessages.installJvmErrorMessages()
|
||||
else -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun createTypeCheckers(useExtendedCheckers: Boolean): TypeCheckers? =
|
||||
if (useExtendedCheckers) null else CommonTypeCheckers
|
||||
|
||||
|
||||
+14
-13
@@ -5,7 +5,8 @@
|
||||
|
||||
package org.jetbrains.kotlin.analysis.low.level.api.fir.compiler.based
|
||||
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.*
|
||||
import org.jetbrains.kotlin.diagnostics.*
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.RootDiagnosticRendererFactory
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
import org.jetbrains.kotlin.fir.types.ConeTypeVariableType
|
||||
import org.jetbrains.kotlin.fir.types.contains
|
||||
@@ -20,39 +21,39 @@ internal class LLDiagnosticParameterChecker(testServices: TestServices) : FirAna
|
||||
val diagnostics = info.firAnalyzerFacade.runCheckers().values.flatten()
|
||||
|
||||
for (diagnostic in diagnostics) {
|
||||
checkDiagnosticIsSuitableForFirIde(diagnostic)
|
||||
checkDiagnosticIsSuitableForFirIde(diagnostic as KtPsiDiagnostic)
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkDiagnosticIsSuitableForFirIde(diagnostic: FirDiagnostic) {
|
||||
private fun checkDiagnosticIsSuitableForFirIde(diagnostic: KtPsiDiagnostic) {
|
||||
val parameters = diagnostic.allParameters()
|
||||
for (parameter in parameters) {
|
||||
checkDiagnosticParameter(diagnostic, parameter)
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkDiagnosticParameter(diagnostic: FirDiagnostic, parameter: Any?) {
|
||||
private fun checkDiagnosticParameter(diagnostic: KtPsiDiagnostic, parameter: Any?) {
|
||||
when (parameter) {
|
||||
is ConeKotlinType -> checkType(parameter, diagnostic)
|
||||
is ConeKotlinType -> checkType(parameter, diagnostic as KtDiagnostic)
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkType(parameter: ConeKotlinType, diagnostic: FirDiagnostic) {
|
||||
private fun checkType(parameter: ConeKotlinType, diagnostic: KtDiagnostic) {
|
||||
val containsTypeVariableType = parameter.contains { it is ConeTypeVariableType }
|
||||
if (containsTypeVariableType) {
|
||||
val rendered = FirDefaultErrorMessages.getRendererForDiagnostic(diagnostic).render(diagnostic)
|
||||
val rendered = RootDiagnosticRendererFactory(diagnostic).render(diagnostic)
|
||||
testServices.assertions.fail {
|
||||
"ConeTypeVariableType should not be exposed from diagnostic. But it was for ${diagnostic.factoryName} $rendered"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun FirDiagnostic.allParameters(): List<Any?> = when (this) {
|
||||
is FirPsiDiagnosticWithParameters1<*> -> listOf(a)
|
||||
is FirPsiDiagnosticWithParameters2<*, *> -> listOf(a, b)
|
||||
is FirPsiDiagnosticWithParameters3<*, *, *> -> listOf(a, b, c)
|
||||
is FirPsiDiagnosticWithParameters4<*, *, *, *> -> listOf(a, b, c, d)
|
||||
is FirPsiSimpleDiagnostic -> emptyList()
|
||||
private fun KtPsiDiagnostic.allParameters(): List<Any?> = when (this) {
|
||||
is KtPsiDiagnosticWithParameters1<*> -> listOf(a)
|
||||
is KtPsiDiagnosticWithParameters2<*, *> -> listOf(a, b)
|
||||
is KtPsiDiagnosticWithParameters3<*, *, *> -> listOf(a, b, c)
|
||||
is KtPsiDiagnosticWithParameters4<*, *, *, *> -> listOf(a, b, c, d)
|
||||
is KtPsiSimpleDiagnostic -> emptyList()
|
||||
else -> error("Unexpected diagnostic $this")
|
||||
}
|
||||
|
||||
|
||||
+2
-3
@@ -14,7 +14,7 @@ import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageUtil
|
||||
import org.jetbrains.kotlin.diagnostics.*
|
||||
import org.jetbrains.kotlin.diagnostics.impl.BaseDiagnosticReporter
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDefaultErrorMessages
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.RootDiagnosticRendererFactory
|
||||
import java.io.Closeable
|
||||
import java.io.File
|
||||
import java.io.InputStreamReader
|
||||
@@ -86,8 +86,7 @@ object FirDiagnosticsCompilerResultsReporter {
|
||||
reporter: MessageCollector
|
||||
) {
|
||||
val severity = AnalyzerWithCompilerReport.convertSeverity(diagnostic.severity)
|
||||
// TODO: support multiple maps with messages
|
||||
val renderer = FirDefaultErrorMessages.getRendererForDiagnostic(diagnostic)
|
||||
val renderer = RootDiagnosticRendererFactory(diagnostic)
|
||||
reporter.report(severity, renderer.render(diagnostic), location)
|
||||
}
|
||||
|
||||
|
||||
+7
-1
@@ -5,7 +5,9 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.checkers.generator.diagnostics.model
|
||||
|
||||
import org.jetbrains.kotlin.fir.checkers.generator.*
|
||||
import org.jetbrains.kotlin.fir.checkers.generator.collectClassNamesTo
|
||||
import org.jetbrains.kotlin.fir.checkers.generator.inBracketsWithIndent
|
||||
import org.jetbrains.kotlin.fir.checkers.generator.printImports
|
||||
import org.jetbrains.kotlin.fir.tree.generator.printer.printCopyright
|
||||
import org.jetbrains.kotlin.fir.tree.generator.printer.printGeneratedMessage
|
||||
import org.jetbrains.kotlin.fir.tree.generator.util.writeToFileUsingSmartPrinterIfFileContentChanged
|
||||
@@ -40,6 +42,9 @@ object ErrorListDiagnosticListRenderer : DiagnosticListRenderer() {
|
||||
printDiagnosticGroup(group.name, group.diagnostics)
|
||||
println()
|
||||
}
|
||||
inBracketsWithIndent("init") {
|
||||
println("RootDiagnosticRendererFactory.registerFactory(${diagnosticList.objectName}DefaultMessages)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,6 +141,7 @@ object ErrorListDiagnosticListRenderer : DiagnosticListRenderer() {
|
||||
for (deprecationDiagnostic in diagnosticList.allDiagnostics.filterIsInstance<DeprecationDiagnosticData>()) {
|
||||
add("org.jetbrains.kotlin.config.LanguageFeature.${deprecationDiagnostic.featureForError.name}")
|
||||
}
|
||||
add("org.jetbrains.kotlin.diagnostics.rendering.RootDiagnosticRendererFactory")
|
||||
}
|
||||
|
||||
|
||||
|
||||
+4
@@ -13,6 +13,7 @@ import org.jetbrains.kotlin.config.LanguageFeature.ProhibitSpreadOnSignaturePoly
|
||||
import org.jetbrains.kotlin.config.LanguageFeature.RepeatableAnnotationContainerConstraints
|
||||
import org.jetbrains.kotlin.diagnostics.*
|
||||
import org.jetbrains.kotlin.diagnostics.SourceElementPositioningStrategies
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.RootDiagnosticRendererFactory
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.*
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
@@ -125,4 +126,7 @@ object FirJvmErrors {
|
||||
val CONCURRENT_HASH_MAP_CONTAINS_OPERATOR by deprecationError0<PsiElement>(ProhibitConcurrentHashMapContains)
|
||||
val SPREAD_ON_SIGNATURE_POLYMORPHIC_CALL by deprecationError0<PsiElement>(ProhibitSpreadOnSignaturePolymorphicCall, SourceElementPositioningStrategies.SPREAD_OPERATOR)
|
||||
|
||||
init {
|
||||
RootDiagnosticRendererFactory.registerFactory(FirJvmErrorsDefaultMessages)
|
||||
}
|
||||
}
|
||||
|
||||
+195
-195
@@ -5,11 +5,12 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.analysis.diagnostics.jvm
|
||||
|
||||
import org.jetbrains.kotlin.diagnostics.KtDiagnosticFactoryToRendererMap
|
||||
import org.jetbrains.kotlin.diagnostics.KtDiagnosticRenderers.TO_STRING
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.BaseDiagnosticRendererFactory
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.CommonRenderers.STRING
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDefaultErrorMessages
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers.RENDER_TYPE
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers.SYMBOL
|
||||
import org.jetbrains.kotlin.diagnostics.KtDiagnosticRenderers.TO_STRING
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.CONCURRENT_HASH_MAP_CONTAINS_OPERATOR
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.CONFLICTING_JVM_DECLARATIONS
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET
|
||||
@@ -84,210 +85,209 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.VALUE_CLAS
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.VOLATILE_ON_DELEGATE
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.VOLATILE_ON_VALUE
|
||||
|
||||
object FirJvmDefaultErrorMessages {
|
||||
fun installJvmErrorMessages() {
|
||||
FirDefaultErrorMessages.Companion.MAP.also { map ->
|
||||
map.put(CONFLICTING_JVM_DECLARATIONS, "Platform declaration clash")
|
||||
map.put(JAVA_TYPE_MISMATCH, "Java type mismatch expected {0} but found {1}. Use explicit cast", RENDER_TYPE, RENDER_TYPE)
|
||||
map.put(UPPER_BOUND_CANNOT_BE_ARRAY, "Upper bound of a type parameter cannot be an array")
|
||||
map.put(STRICTFP_ON_CLASS, "'@Strictfp' annotation on classes is unsupported yet")
|
||||
map.put(VOLATILE_ON_VALUE, "'@Volatile' annotation cannot be used on immutable properties")
|
||||
map.put(VOLATILE_ON_DELEGATE, "'@Volatile' annotation cannot be used on delegated properties")
|
||||
map.put(SYNCHRONIZED_ON_ABSTRACT, "'@Synchronized' annotation cannot be used on abstract functions")
|
||||
map.put(SYNCHRONIZED_ON_INLINE, "'@Synchronized' annotation has no effect on inline functions")
|
||||
map.put(SYNCHRONIZED_IN_INTERFACE, "'@Synchronized' annotation cannot be used on interface members")
|
||||
map.put(OVERLOADS_WITHOUT_DEFAULT_ARGUMENTS, "'@JvmOverloads' annotation has no effect for methods without default arguments")
|
||||
map.put(OVERLOADS_ABSTRACT, "'@JvmOverloads' annotation cannot be used on abstract methods")
|
||||
map.put(OVERLOADS_INTERFACE, "'@JvmOverloads' annotation cannot be used on interface methods")
|
||||
map.put(OVERLOADS_PRIVATE, "'@JvmOverloads' annotation has no effect on private declarations")
|
||||
map.put(OVERLOADS_LOCAL, "'@JvmOverloads' annotation cannot be used on local declarations")
|
||||
map.put(
|
||||
OVERLOADS_ANNOTATION_CLASS_CONSTRUCTOR,
|
||||
"'@JvmOverloads' annotation cannot be used on constructors of annotation classes"
|
||||
)
|
||||
map.put(DEPRECATED_JAVA_ANNOTATION, "This annotation is deprecated in Kotlin. Use ''@{0}'' instead", TO_STRING)
|
||||
map.put(POSITIONED_VALUE_ARGUMENT_FOR_JAVA_ANNOTATION, "Only named arguments are available for Java annotations")
|
||||
map.put(JVM_PACKAGE_NAME_CANNOT_BE_EMPTY, "''@JvmPackageName'' annotation value cannot be empty")
|
||||
map.put(
|
||||
JVM_PACKAGE_NAME_MUST_BE_VALID_NAME,
|
||||
"''@JvmPackageName'' annotation value must be a valid dot-qualified name of a package"
|
||||
)
|
||||
map.put(
|
||||
JVM_PACKAGE_NAME_NOT_SUPPORTED_IN_FILES_WITH_CLASSES,
|
||||
"''@JvmPackageName'' annotation is not supported for files with class declarations"
|
||||
)
|
||||
map.put(
|
||||
SUPER_CALL_WITH_DEFAULT_PARAMETERS,
|
||||
"Super-calls with default arguments are not allowed. Please specify all arguments of ''super.{0}'' explicitly",
|
||||
TO_STRING
|
||||
)
|
||||
object FirJvmErrorsDefaultMessages : BaseDiagnosticRendererFactory() {
|
||||
|
||||
map.put(LOCAL_JVM_RECORD, "Local @JvmRecord classes are not allowed")
|
||||
map.put(NON_FINAL_JVM_RECORD, "@JvmRecord class should be final")
|
||||
map.put(ENUM_JVM_RECORD, "@JvmRecord class should not be an enum")
|
||||
map.put(
|
||||
JVM_RECORD_WITHOUT_PRIMARY_CONSTRUCTOR_PARAMETERS,
|
||||
"Primary constructor with parameters is required for @JvmRecord class"
|
||||
)
|
||||
map.put(JVM_RECORD_NOT_VAL_PARAMETER, "Constructor parameter of @JvmRecord class should be a val")
|
||||
map.put(JVM_RECORD_NOT_LAST_VARARG_PARAMETER, "Only the last constructor parameter of @JvmRecord may be a vararg")
|
||||
map.put(JVM_RECORD_EXTENDS_CLASS, "Record cannot inherit a class", RENDER_TYPE)
|
||||
map.put(INNER_JVM_RECORD, "@JvmRecord class should not be inner")
|
||||
map.put(FIELD_IN_JVM_RECORD, "It's not allowed to have non-constructor properties with backing filed in @JvmRecord class")
|
||||
map.put(DELEGATION_BY_IN_JVM_RECORD, "Delegation is not allowed for @JvmRecord classes")
|
||||
map.put(NON_DATA_CLASS_JVM_RECORD, "Only data classes are allowed to be marked as @JvmRecord")
|
||||
map.put(ILLEGAL_JAVA_LANG_RECORD_SUPERTYPE, "Classes cannot have explicit 'java.lang.Record' supertype")
|
||||
override val MAP = KtDiagnosticFactoryToRendererMap("FIR").also { map ->
|
||||
map.put(CONFLICTING_JVM_DECLARATIONS, "Platform declaration clash")
|
||||
map.put(JAVA_TYPE_MISMATCH, "Java type mismatch expected {0} but found {1}. Use explicit cast", RENDER_TYPE, RENDER_TYPE)
|
||||
map.put(UPPER_BOUND_CANNOT_BE_ARRAY, "Upper bound of a type parameter cannot be an array")
|
||||
map.put(STRICTFP_ON_CLASS, "'@Strictfp' annotation on classes is unsupported yet")
|
||||
map.put(VOLATILE_ON_VALUE, "'@Volatile' annotation cannot be used on immutable properties")
|
||||
map.put(VOLATILE_ON_DELEGATE, "'@Volatile' annotation cannot be used on delegated properties")
|
||||
map.put(SYNCHRONIZED_ON_ABSTRACT, "'@Synchronized' annotation cannot be used on abstract functions")
|
||||
map.put(SYNCHRONIZED_ON_INLINE, "'@Synchronized' annotation has no effect on inline functions")
|
||||
map.put(SYNCHRONIZED_IN_INTERFACE, "'@Synchronized' annotation cannot be used on interface members")
|
||||
map.put(OVERLOADS_WITHOUT_DEFAULT_ARGUMENTS, "'@JvmOverloads' annotation has no effect for methods without default arguments")
|
||||
map.put(OVERLOADS_ABSTRACT, "'@JvmOverloads' annotation cannot be used on abstract methods")
|
||||
map.put(OVERLOADS_INTERFACE, "'@JvmOverloads' annotation cannot be used on interface methods")
|
||||
map.put(OVERLOADS_PRIVATE, "'@JvmOverloads' annotation has no effect on private declarations")
|
||||
map.put(OVERLOADS_LOCAL, "'@JvmOverloads' annotation cannot be used on local declarations")
|
||||
map.put(
|
||||
OVERLOADS_ANNOTATION_CLASS_CONSTRUCTOR,
|
||||
"'@JvmOverloads' annotation cannot be used on constructors of annotation classes"
|
||||
)
|
||||
map.put(DEPRECATED_JAVA_ANNOTATION, "This annotation is deprecated in Kotlin. Use ''@{0}'' instead", TO_STRING)
|
||||
map.put(POSITIONED_VALUE_ARGUMENT_FOR_JAVA_ANNOTATION, "Only named arguments are available for Java annotations")
|
||||
map.put(JVM_PACKAGE_NAME_CANNOT_BE_EMPTY, "''@JvmPackageName'' annotation value cannot be empty")
|
||||
map.put(
|
||||
JVM_PACKAGE_NAME_MUST_BE_VALID_NAME,
|
||||
"''@JvmPackageName'' annotation value must be a valid dot-qualified name of a package"
|
||||
)
|
||||
map.put(
|
||||
JVM_PACKAGE_NAME_NOT_SUPPORTED_IN_FILES_WITH_CLASSES,
|
||||
"''@JvmPackageName'' annotation is not supported for files with class declarations"
|
||||
)
|
||||
map.put(
|
||||
SUPER_CALL_WITH_DEFAULT_PARAMETERS,
|
||||
"Super-calls with default arguments are not allowed. Please specify all arguments of ''super.{0}'' explicitly",
|
||||
TO_STRING
|
||||
)
|
||||
|
||||
map.put(OVERRIDE_CANNOT_BE_STATIC, "Override member cannot be '@JvmStatic' in object")
|
||||
map.put(
|
||||
JVM_STATIC_NOT_IN_OBJECT_OR_CLASS_COMPANION,
|
||||
"Only members in named objects and companion objects of classes can be annotated with '@JvmStatic'"
|
||||
)
|
||||
map.put(
|
||||
JVM_STATIC_NOT_IN_OBJECT_OR_COMPANION,
|
||||
"Only members in named objects and companion objects can be annotated with '@JvmStatic'"
|
||||
)
|
||||
map.put(
|
||||
JVM_STATIC_ON_NON_PUBLIC_MEMBER,
|
||||
"Only public members in interface companion objects can be annotated with '@JvmStatic'"
|
||||
)
|
||||
map.put(
|
||||
JVM_STATIC_ON_CONST_OR_JVM_FIELD,
|
||||
"'@JvmStatic' annotation is useless for const or '@JvmField' properties",
|
||||
)
|
||||
map.put(
|
||||
JVM_STATIC_ON_EXTERNAL_IN_INTERFACE,
|
||||
"'@JvmStatic' annotation cannot be used on 'external' members of interface companions"
|
||||
)
|
||||
map.put(LOCAL_JVM_RECORD, "Local @JvmRecord classes are not allowed")
|
||||
map.put(NON_FINAL_JVM_RECORD, "@JvmRecord class should be final")
|
||||
map.put(ENUM_JVM_RECORD, "@JvmRecord class should not be an enum")
|
||||
map.put(
|
||||
JVM_RECORD_WITHOUT_PRIMARY_CONSTRUCTOR_PARAMETERS,
|
||||
"Primary constructor with parameters is required for @JvmRecord class"
|
||||
)
|
||||
map.put(JVM_RECORD_NOT_VAL_PARAMETER, "Constructor parameter of @JvmRecord class should be a val")
|
||||
map.put(JVM_RECORD_NOT_LAST_VARARG_PARAMETER, "Only the last constructor parameter of @JvmRecord may be a vararg")
|
||||
map.put(JVM_RECORD_EXTENDS_CLASS, "Record cannot inherit a class", RENDER_TYPE)
|
||||
map.put(INNER_JVM_RECORD, "@JvmRecord class should not be inner")
|
||||
map.put(FIELD_IN_JVM_RECORD, "It's not allowed to have non-constructor properties with backing filed in @JvmRecord class")
|
||||
map.put(DELEGATION_BY_IN_JVM_RECORD, "Delegation is not allowed for @JvmRecord classes")
|
||||
map.put(NON_DATA_CLASS_JVM_RECORD, "Only data classes are allowed to be marked as @JvmRecord")
|
||||
map.put(ILLEGAL_JAVA_LANG_RECORD_SUPERTYPE, "Classes cannot have explicit 'java.lang.Record' supertype")
|
||||
|
||||
map.put(INAPPLICABLE_JVM_NAME, "'@JvmName' annotation is not applicable to this declaration")
|
||||
map.put(ILLEGAL_JVM_NAME, "Illegal JVM name")
|
||||
map.put(OVERRIDE_CANNOT_BE_STATIC, "Override member cannot be '@JvmStatic' in object")
|
||||
map.put(
|
||||
JVM_STATIC_NOT_IN_OBJECT_OR_CLASS_COMPANION,
|
||||
"Only members in named objects and companion objects of classes can be annotated with '@JvmStatic'"
|
||||
)
|
||||
map.put(
|
||||
JVM_STATIC_NOT_IN_OBJECT_OR_COMPANION,
|
||||
"Only members in named objects and companion objects can be annotated with '@JvmStatic'"
|
||||
)
|
||||
map.put(
|
||||
JVM_STATIC_ON_NON_PUBLIC_MEMBER,
|
||||
"Only public members in interface companion objects can be annotated with '@JvmStatic'"
|
||||
)
|
||||
map.put(
|
||||
JVM_STATIC_ON_CONST_OR_JVM_FIELD,
|
||||
"'@JvmStatic' annotation is useless for const or '@JvmField' properties",
|
||||
)
|
||||
map.put(
|
||||
JVM_STATIC_ON_EXTERNAL_IN_INTERFACE,
|
||||
"'@JvmStatic' annotation cannot be used on 'external' members of interface companions"
|
||||
)
|
||||
|
||||
map.put(FUNCTION_DELEGATE_MEMBER_NAME_CLASH, "Spread operator is prohibited for arguments to signature-polymorphic calls")
|
||||
map.put(INAPPLICABLE_JVM_NAME, "'@JvmName' annotation is not applicable to this declaration")
|
||||
map.put(ILLEGAL_JVM_NAME, "Illegal JVM name")
|
||||
|
||||
map.put(VALUE_CLASS_WITHOUT_JVM_INLINE_ANNOTATION, "Value classes without @JvmInline annotation are not supported yet")
|
||||
map.put(JVM_INLINE_WITHOUT_VALUE_CLASS, "@JvmInline annotation is only applicable to value classes")
|
||||
map.put(FUNCTION_DELEGATE_MEMBER_NAME_CLASH, "Spread operator is prohibited for arguments to signature-polymorphic calls")
|
||||
|
||||
map.put(JVM_DEFAULT_NOT_IN_INTERFACE, "'@JvmDefault' is only supported on interface members")
|
||||
map.put(
|
||||
JVM_DEFAULT_IN_JVM6_TARGET,
|
||||
"''@{0}'' is only supported since JVM target 1.8. Recompile with ''-jvm-target 1.8''",
|
||||
STRING
|
||||
)
|
||||
map.put(JVM_DEFAULT_REQUIRED_FOR_OVERRIDE, "'@JvmDefault' is required for an override of a '@JvmDefault' member")
|
||||
map.put(JVM_DEFAULT_IN_DECLARATION, "Usage of ''@{0}'' is only allowed with -Xjvm-default option", STRING)
|
||||
map.put(
|
||||
JVM_DEFAULT_THROUGH_INHERITANCE,
|
||||
"Inheritance from an interface with '@JvmDefault' members is only allowed with -Xjvm-default option"
|
||||
)
|
||||
map.put(
|
||||
USAGE_OF_JVM_DEFAULT_THROUGH_SUPER_CALL,
|
||||
"Super calls of '@JvmDefault' members are only allowed with -Xjvm-default option"
|
||||
)
|
||||
map.put(
|
||||
NON_JVM_DEFAULT_OVERRIDES_JAVA_DEFAULT,
|
||||
"Non-@JvmDefault interface method cannot override default Java method. Please annotate this method with @JvmDefault or enable `-Xjvm-default=all|all-compatibility`"
|
||||
)
|
||||
map.put(VALUE_CLASS_WITHOUT_JVM_INLINE_ANNOTATION, "Value classes without @JvmInline annotation are not supported yet")
|
||||
map.put(JVM_INLINE_WITHOUT_VALUE_CLASS, "@JvmInline annotation is only applicable to value classes")
|
||||
|
||||
map.put(EXTERNAL_DECLARATION_IN_INTERFACE, "Members of interfaces can not be external")
|
||||
map.put(EXTERNAL_DECLARATION_CANNOT_BE_ABSTRACT, "External declaration can not be abstract")
|
||||
map.put(EXTERNAL_DECLARATION_CANNOT_HAVE_BODY, "External declaration can not have a body")
|
||||
map.put(EXTERNAL_DECLARATION_CANNOT_BE_INLINED, "Inline functions can not be external")
|
||||
map.put(JVM_DEFAULT_NOT_IN_INTERFACE, "'@JvmDefault' is only supported on interface members")
|
||||
map.put(
|
||||
JVM_DEFAULT_IN_JVM6_TARGET,
|
||||
"''@{0}'' is only supported since JVM target 1.8. Recompile with ''-jvm-target 1.8''",
|
||||
STRING
|
||||
)
|
||||
map.put(JVM_DEFAULT_REQUIRED_FOR_OVERRIDE, "'@JvmDefault' is required for an override of a '@JvmDefault' member")
|
||||
map.put(JVM_DEFAULT_IN_DECLARATION, "Usage of ''@{0}'' is only allowed with -Xjvm-default option", STRING)
|
||||
map.put(
|
||||
JVM_DEFAULT_THROUGH_INHERITANCE,
|
||||
"Inheritance from an interface with '@JvmDefault' members is only allowed with -Xjvm-default option"
|
||||
)
|
||||
map.put(
|
||||
USAGE_OF_JVM_DEFAULT_THROUGH_SUPER_CALL,
|
||||
"Super calls of '@JvmDefault' members are only allowed with -Xjvm-default option"
|
||||
)
|
||||
map.put(
|
||||
NON_JVM_DEFAULT_OVERRIDES_JAVA_DEFAULT,
|
||||
"Non-@JvmDefault interface method cannot override default Java method. Please annotate this method with @JvmDefault or enable `-Xjvm-default=all|all-compatibility`"
|
||||
)
|
||||
|
||||
map.put(INAPPLICABLE_JVM_FIELD, "{0}", STRING)
|
||||
map.put(INAPPLICABLE_JVM_FIELD_WARNING, "{0}. This warning will become an error in further releases", STRING)
|
||||
map.put(EXTERNAL_DECLARATION_IN_INTERFACE, "Members of interfaces can not be external")
|
||||
map.put(EXTERNAL_DECLARATION_CANNOT_BE_ABSTRACT, "External declaration can not be abstract")
|
||||
map.put(EXTERNAL_DECLARATION_CANNOT_HAVE_BODY, "External declaration can not have a body")
|
||||
map.put(EXTERNAL_DECLARATION_CANNOT_BE_INLINED, "Inline functions can not be external")
|
||||
|
||||
map.put(JVM_SYNTHETIC_ON_DELEGATE, "'@JvmSynthetic' annotation cannot be used on delegated properties")
|
||||
map.put(INAPPLICABLE_JVM_FIELD, "{0}", STRING)
|
||||
map.put(INAPPLICABLE_JVM_FIELD_WARNING, "{0}. This warning will become an error in further releases", STRING)
|
||||
|
||||
map.put(
|
||||
NON_SOURCE_REPEATED_ANNOTATION,
|
||||
"Repeatable annotations with non-SOURCE retention are only supported starting from Kotlin 1.6"
|
||||
)
|
||||
map.put(
|
||||
REPEATED_ANNOTATION_TARGET6,
|
||||
"Repeatable annotations with non-SOURCE retention are not supported with JVM target 1.6. Use -jvm-target 1.8"
|
||||
)
|
||||
map.put(
|
||||
REPEATED_ANNOTATION_WITH_CONTAINER,
|
||||
"Repeated annotation ''@{0}'' cannot be used on a declaration which is annotated with its container annotation ''@{1}''",
|
||||
TO_STRING,
|
||||
TO_STRING
|
||||
)
|
||||
map.put(JVM_SYNTHETIC_ON_DELEGATE, "'@JvmSynthetic' annotation cannot be used on delegated properties")
|
||||
|
||||
map.put(
|
||||
DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET,
|
||||
"Super calls to Java default methods are prohibited in JVM target 1.6. Recompile with '-jvm-target 1.8'"
|
||||
)
|
||||
map.put(
|
||||
INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET,
|
||||
"Calls to static methods in Java interfaces are prohibited in JVM target 1.6. Recompile with '-jvm-target 1.8'"
|
||||
)
|
||||
map.put(
|
||||
INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER,
|
||||
"Interfaces can call default methods via super only within @JvmDefault members. Please annotate the containing interface member with @JvmDefault"
|
||||
)
|
||||
map.put(
|
||||
SUBCLASS_CANT_CALL_COMPANION_PROTECTED_NON_STATIC,
|
||||
"Using protected members which are not @JvmStatic in the superclass companion is unsupported yet"
|
||||
)
|
||||
map.put(
|
||||
DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET,
|
||||
"Super calls to Java default methods are prohibited in JVM target 1.6. Recompile with '-jvm-target 1.8'"
|
||||
)
|
||||
map.put(
|
||||
INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET,
|
||||
"Calls to static methods in Java interfaces are prohibited in JVM target 1.6. Recompile with '-jvm-target 1.8'"
|
||||
)
|
||||
map.put(
|
||||
INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER,
|
||||
"Interfaces can call default methods via super only within @JvmDefault members. Please annotate the containing interface member with @JvmDefault"
|
||||
)
|
||||
map.put(
|
||||
NON_SOURCE_REPEATED_ANNOTATION,
|
||||
"Repeatable annotations with non-SOURCE retention are only supported starting from Kotlin 1.6"
|
||||
)
|
||||
map.put(
|
||||
REPEATED_ANNOTATION_TARGET6,
|
||||
"Repeatable annotations with non-SOURCE retention are not supported with JVM target 1.6. Use -jvm-target 1.8"
|
||||
)
|
||||
map.put(
|
||||
REPEATED_ANNOTATION_WITH_CONTAINER,
|
||||
"Repeated annotation ''@{0}'' cannot be used on a declaration which is annotated with its container annotation ''@{1}''",
|
||||
TO_STRING,
|
||||
TO_STRING
|
||||
)
|
||||
|
||||
map.put(
|
||||
REPEATABLE_CONTAINER_MUST_HAVE_VALUE_ARRAY,
|
||||
"Container annotation ''{0}'' must have a property ''value'' of type ''Array<{1}>''.",
|
||||
TO_STRING,
|
||||
TO_STRING
|
||||
)
|
||||
map.put(
|
||||
REPEATABLE_CONTAINER_HAS_NON_DEFAULT_PARAMETER,
|
||||
"Container annotation ''{0}'' does not have a default value for ''{1}''.",
|
||||
TO_STRING,
|
||||
TO_STRING
|
||||
)
|
||||
map.put(
|
||||
REPEATABLE_CONTAINER_HAS_SHORTER_RETENTION,
|
||||
"Container annotation ''{0}'' has shorter retention (''{1}'') than the repeatable annotation ''{2}'' (''{3}'').",
|
||||
TO_STRING,
|
||||
TO_STRING,
|
||||
TO_STRING,
|
||||
TO_STRING
|
||||
)
|
||||
map.put(
|
||||
REPEATABLE_CONTAINER_TARGET_SET_NOT_A_SUBSET,
|
||||
"Target set of container annotation ''{0}'' must be a subset of the target set of contained annotation ''{1}''.",
|
||||
TO_STRING,
|
||||
TO_STRING
|
||||
)
|
||||
map.put(
|
||||
REPEATABLE_ANNOTATION_HAS_NESTED_CLASS_NAMED_CONTAINER,
|
||||
"Repeatable annotation cannot have a nested class named 'Container'. This name is reserved for auto-generated container class"
|
||||
)
|
||||
map.put(
|
||||
SUSPENSION_POINT_INSIDE_CRITICAL_SECTION,
|
||||
"The ''{0}'' suspension point is inside a critical section",
|
||||
SYMBOL
|
||||
)
|
||||
map.put(
|
||||
CONCURRENT_HASH_MAP_CONTAINS_OPERATOR,
|
||||
"Method 'contains' from ConcurrentHashMap may have unexpected semantics: it calls 'containsValue' instead of 'containsKey'. " +
|
||||
"Use explicit form of the call to 'containsKey'/'containsValue'/'contains' or cast the value to kotlin.collections.Map instead. " +
|
||||
"See https://youtrack.jetbrains.com/issue/KT-18053 for more details"
|
||||
)
|
||||
map.put(
|
||||
SPREAD_ON_SIGNATURE_POLYMORPHIC_CALL,
|
||||
"Spread operator is prohibited for arguments to signature-polymorphic calls"
|
||||
)
|
||||
}
|
||||
map.put(
|
||||
DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET,
|
||||
"Super calls to Java default methods are prohibited in JVM target 1.6. Recompile with '-jvm-target 1.8'"
|
||||
)
|
||||
map.put(
|
||||
INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET,
|
||||
"Calls to static methods in Java interfaces are prohibited in JVM target 1.6. Recompile with '-jvm-target 1.8'"
|
||||
)
|
||||
map.put(
|
||||
INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER,
|
||||
"Interfaces can call default methods via super only within @JvmDefault members. Please annotate the containing interface member with @JvmDefault"
|
||||
)
|
||||
map.put(
|
||||
SUBCLASS_CANT_CALL_COMPANION_PROTECTED_NON_STATIC,
|
||||
"Using protected members which are not @JvmStatic in the superclass companion is unsupported yet"
|
||||
)
|
||||
map.put(
|
||||
DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET,
|
||||
"Super calls to Java default methods are prohibited in JVM target 1.6. Recompile with '-jvm-target 1.8'"
|
||||
)
|
||||
map.put(
|
||||
INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET,
|
||||
"Calls to static methods in Java interfaces are prohibited in JVM target 1.6. Recompile with '-jvm-target 1.8'"
|
||||
)
|
||||
map.put(
|
||||
INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER,
|
||||
"Interfaces can call default methods via super only within @JvmDefault members. Please annotate the containing interface member with @JvmDefault"
|
||||
)
|
||||
|
||||
map.put(
|
||||
REPEATABLE_CONTAINER_MUST_HAVE_VALUE_ARRAY,
|
||||
"Container annotation ''{0}'' must have a property ''value'' of type ''Array<{1}>''.",
|
||||
TO_STRING,
|
||||
TO_STRING
|
||||
)
|
||||
map.put(
|
||||
REPEATABLE_CONTAINER_HAS_NON_DEFAULT_PARAMETER,
|
||||
"Container annotation ''{0}'' does not have a default value for ''{1}''.",
|
||||
TO_STRING,
|
||||
TO_STRING
|
||||
)
|
||||
map.put(
|
||||
REPEATABLE_CONTAINER_HAS_SHORTER_RETENTION,
|
||||
"Container annotation ''{0}'' has shorter retention (''{1}'') than the repeatable annotation ''{2}'' (''{3}'').",
|
||||
TO_STRING,
|
||||
TO_STRING,
|
||||
TO_STRING,
|
||||
TO_STRING
|
||||
)
|
||||
map.put(
|
||||
REPEATABLE_CONTAINER_TARGET_SET_NOT_A_SUBSET,
|
||||
"Target set of container annotation ''{0}'' must be a subset of the target set of contained annotation ''{1}''.",
|
||||
TO_STRING,
|
||||
TO_STRING
|
||||
)
|
||||
map.put(
|
||||
REPEATABLE_ANNOTATION_HAS_NESTED_CLASS_NAMED_CONTAINER,
|
||||
"Repeatable annotation cannot have a nested class named 'Container'. This name is reserved for auto-generated container class"
|
||||
)
|
||||
map.put(
|
||||
SUSPENSION_POINT_INSIDE_CRITICAL_SECTION,
|
||||
"The ''{0}'' suspension point is inside a critical section",
|
||||
SYMBOL
|
||||
)
|
||||
map.put(
|
||||
CONCURRENT_HASH_MAP_CONTAINS_OPERATOR,
|
||||
"Method 'contains' from ConcurrentHashMap may have unexpected semantics: it calls 'containsValue' instead of 'containsKey'. " +
|
||||
"Use explicit form of the call to 'containsKey'/'containsValue'/'contains' or cast the value to kotlin.collections.Map instead. " +
|
||||
"See https://youtrack.jetbrains.com/issue/KT-18053 for more details"
|
||||
)
|
||||
map.put(
|
||||
SPREAD_ON_SIGNATURE_POLYMORPHIC_CALL,
|
||||
"Spread operator is prohibited for arguments to signature-polymorphic calls"
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.diagnostics.*
|
||||
import org.jetbrains.kotlin.diagnostics.SourceElementPositioningStrategies
|
||||
import org.jetbrains.kotlin.diagnostics.WhenMissingCase
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.RootDiagnosticRendererFactory
|
||||
import org.jetbrains.kotlin.fir.FirModuleData
|
||||
import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
@@ -711,4 +712,7 @@ object FirErrors {
|
||||
// label
|
||||
val REDUNDANT_LABEL_WARNING by warning0<KtLabelReferenceExpression>(SourceElementPositioningStrategies.LABEL)
|
||||
|
||||
init {
|
||||
RootDiagnosticRendererFactory.registerFactory(FirErrorsDefaultMessages)
|
||||
}
|
||||
}
|
||||
|
||||
+1293
-1234
File diff suppressed because it is too large
Load Diff
@@ -14,7 +14,6 @@ import org.jetbrains.kotlin.fir.analysis.checkers.expression.ExpressionCheckers
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.type.TypeCheckers
|
||||
import org.jetbrains.kotlin.fir.analysis.checkersComponent
|
||||
import org.jetbrains.kotlin.fir.analysis.extensions.additionalCheckers
|
||||
import org.jetbrains.kotlin.fir.analysis.jvm.diagnostics.FirJvmDefaultErrorMessages
|
||||
import org.jetbrains.kotlin.fir.checkers.registerCommonCheckers
|
||||
import org.jetbrains.kotlin.fir.checkers.registerJvmCheckers
|
||||
import org.jetbrains.kotlin.fir.deserialization.ModuleDataProvider
|
||||
@@ -185,7 +184,6 @@ object FirSessionFactory {
|
||||
dependenciesSymbolProvider
|
||||
)
|
||||
|
||||
FirJvmDefaultErrorMessages.installJvmErrorMessages()
|
||||
projectEnvironment.registerAsJavaElementFinder(this)
|
||||
}
|
||||
}
|
||||
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.diagnostics.rendering
|
||||
|
||||
import org.jetbrains.kotlin.diagnostics.KtDiagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.KtDiagnosticFactoryToRendererMap
|
||||
import org.jetbrains.kotlin.diagnostics.KtDiagnosticRenderer
|
||||
import java.util.concurrent.locks.ReentrantLock
|
||||
import kotlin.concurrent.withLock
|
||||
|
||||
fun interface DiagnosticRendererFactory {
|
||||
operator fun invoke(diagnostic: KtDiagnostic): KtDiagnosticRenderer?
|
||||
}
|
||||
|
||||
abstract class BaseDiagnosticRendererFactory : DiagnosticRendererFactory {
|
||||
override operator fun invoke(diagnostic: KtDiagnostic): KtDiagnosticRenderer? {
|
||||
val factory = diagnostic.factory
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return MAP[factory]
|
||||
}
|
||||
|
||||
abstract val MAP: KtDiagnosticFactoryToRendererMap
|
||||
}
|
||||
|
||||
object RootDiagnosticRendererFactory: DiagnosticRendererFactory {
|
||||
private val factories = linkedSetOf<DiagnosticRendererFactory>()
|
||||
private val lock = ReentrantLock()
|
||||
|
||||
override operator fun invoke(diagnostic: KtDiagnostic): KtDiagnosticRenderer = lock.withLock {
|
||||
for (factory in factories) {
|
||||
val renderer = factory(diagnostic)
|
||||
if (renderer != null) return renderer
|
||||
}
|
||||
diagnostic.factory.ktRenderer
|
||||
}
|
||||
|
||||
fun registerFactory(factory: DiagnosticRendererFactory) {
|
||||
lock.withLock {
|
||||
factories.add(factory)
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.test.backend.handlers
|
||||
|
||||
import org.jetbrains.kotlin.diagnostics.PsiDiagnosticUtils
|
||||
import org.jetbrains.kotlin.diagnostics.Severity
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDefaultErrorMessages
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.RootDiagnosticRendererFactory
|
||||
import org.jetbrains.kotlin.psi
|
||||
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives
|
||||
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.IGNORE_FIR_DIAGNOSTICS
|
||||
@@ -29,7 +29,7 @@ class NoFirCompilationErrorsHandler(testServices: TestServices) : FirAnalysisHan
|
||||
if (diagnostic.severity == Severity.ERROR) {
|
||||
hasError = true
|
||||
if (!ignoreErrors) {
|
||||
val diagnosticText = FirDefaultErrorMessages.getRendererForDiagnostic(diagnostic).render(diagnostic)
|
||||
val diagnosticText = RootDiagnosticRendererFactory(diagnostic).render(diagnostic)
|
||||
val range = diagnostic.textRanges.first()
|
||||
val locationText = firFile.source?.psi?.containingFile?.let { psiFile ->
|
||||
PsiDiagnosticUtils.atLocation(psiFile, range)
|
||||
|
||||
+2
-2
@@ -9,8 +9,8 @@ import com.intellij.openapi.util.TextRange
|
||||
import org.jetbrains.kotlin.codeMetaInfo.model.CodeMetaInfo
|
||||
import org.jetbrains.kotlin.codeMetaInfo.renderConfigurations.AbstractCodeMetaInfoRenderConfiguration
|
||||
import org.jetbrains.kotlin.diagnostics.AbstractKtDiagnosticWithParametersRenderer
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDefaultErrorMessages
|
||||
import org.jetbrains.kotlin.diagnostics.KtDiagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.RootDiagnosticRendererFactory
|
||||
|
||||
object FirMetaInfoUtils {
|
||||
val renderDiagnosticNoArgs = FirDiagnosticCodeMetaRenderConfiguration().apply { renderParams = false }
|
||||
@@ -63,7 +63,7 @@ class FirDiagnosticCodeMetaRenderConfiguration(
|
||||
val diagnostic = codeMetaInfo.diagnostic
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val renderer = FirDefaultErrorMessages.getRendererForDiagnostic(diagnostic)
|
||||
val renderer = RootDiagnosticRendererFactory(diagnostic)
|
||||
if (renderer is AbstractKtDiagnosticWithParametersRenderer) {
|
||||
renderer.renderParameters(diagnostic).mapTo(params, Any?::toString)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user