[FIR] Generate FIR diagnostics with explicit types

#KT-64147 Fixed
This commit is contained in:
Kirill Rakhman
2023-12-07 13:37:45 +01:00
committed by Space Team
parent fc1ada4896
commit daa02813c2
8 changed files with 895 additions and 855 deletions
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.fir.checkers.generator.printCopyright
import org.jetbrains.kotlin.fir.tree.generator.util.writeToFileUsingSmartPrinterIfFileContentChanged
import org.jetbrains.kotlin.generators.tree.printer.printKDoc
import org.jetbrains.kotlin.utils.SmartPrinter
import org.jetbrains.kotlin.utils.addToStdlib.ifNotEmpty
import java.io.File
import kotlin.reflect.KClass
import kotlin.reflect.KType
@@ -67,7 +68,9 @@ object ErrorListDiagnosticListRenderer : DiagnosticListRenderer() {
}
private fun SmartPrinter.printDiagnostic(diagnostic: DiagnosticData) {
print("val ${diagnostic.name} by ${diagnostic.getFactoryFunction()}")
print("val ${diagnostic.name}: ${diagnostic.getPropertType()}")
diagnostic.parameters.map { it.type }.ifNotEmpty { printTypeArguments(this) }
print(" by ${diagnostic.getFactoryFunction()}")
printTypeArguments(diagnostic.getAllTypeArguments())
printPositioningStrategyAndLanguageFeature(diagnostic)
println()
@@ -150,6 +153,7 @@ object ErrorListDiagnosticListRenderer : DiagnosticListRenderer() {
if (!diagnostic.hasDefaultPositioningStrategy()) {
add(PositioningStrategy.importToAdd)
}
add("org.jetbrains.kotlin.diagnostics." + diagnostic.getPropertType())
}
for (deprecationDiagnostic in diagnosticList.allDiagnostics.filterIsInstance<DeprecationDiagnosticData>()) {
add("org.jetbrains.kotlin.config.LanguageFeature.${deprecationDiagnostic.featureForError.name}")
@@ -165,6 +169,11 @@ object ErrorListDiagnosticListRenderer : DiagnosticListRenderer() {
is RegularDiagnosticData -> severity.name.lowercase()
is DeprecationDiagnosticData -> "deprecationError"
} + parameters.size
private fun DiagnosticData.getPropertType(): String = when (this) {
is RegularDiagnosticData -> "KtDiagnosticFactory"
is DeprecationDiagnosticData -> "KtDiagnosticFactoryForDeprecation"
} + parameters.size
}
private inline fun <T> SmartPrinter.printSeparatedWithComma(list: List<T>, printItem: (T) -> Unit) {