K2: introduce infrastructure for LanguageVersionSettings checkers

This commit is contained in:
Mikhail Glukhikh
2023-07-14 18:03:30 +02:00
committed by Space Team
parent ba75ee4c03
commit 8c305d6143
23 changed files with 183 additions and 12 deletions
@@ -11,14 +11,14 @@ import org.jetbrains.kotlin.diagnostics.impl.SimpleDiagnosticsCollector
import org.jetbrains.kotlin.diagnostics.impl.SimpleDiagnosticsCollectorWithSuppress
object DiagnosticReporterFactory {
fun createReporter(disableSuppress: Boolean = false): BaseDiagnosticsCollector {
fun createReporter(rawReport: (Boolean, String) -> Unit = { _, _ -> }, disableSuppress: Boolean = false): BaseDiagnosticsCollector {
return if (disableSuppress) {
SimpleDiagnosticsCollector()
SimpleDiagnosticsCollector(rawReport)
} else {
SimpleDiagnosticsCollectorWithSuppress()
SimpleDiagnosticsCollectorWithSuppress(rawReport)
}
}
fun createPendingReporter(): PendingDiagnosticsCollectorWithSuppress =
PendingDiagnosticsCollectorWithSuppress()
fun createPendingReporter(rawReport: (Boolean, String) -> Unit = { _, _ -> }): PendingDiagnosticsCollectorWithSuppress =
PendingDiagnosticsCollectorWithSuppress(rawReport)
}
@@ -12,4 +12,6 @@ abstract class BaseDiagnosticsCollector : DiagnosticReporter() {
abstract val diagnostics: List<KtDiagnostic>
abstract val diagnosticsByFilePath: Map<String?, List<KtDiagnostic>>
abstract val hasErrors: Boolean
abstract val rawReport: (Boolean, String) -> Unit
}
@@ -10,7 +10,7 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticContext
import org.jetbrains.kotlin.diagnostics.KtDiagnostic
import org.jetbrains.kotlin.diagnostics.Severity
class PendingDiagnosticsCollectorWithSuppress : BaseDiagnosticsCollector() {
class PendingDiagnosticsCollectorWithSuppress(override val rawReport: (Boolean, String) -> Unit) : BaseDiagnosticsCollector() {
private val pendingDiagnosticsByFilePath: MutableMap<String?, MutableList<KtDiagnostic>> = mutableMapOf()
private val _diagnosticsByFilePath: MutableMap<String?, MutableList<KtDiagnostic>> = mutableMapOf()
override val diagnostics: List<KtDiagnostic>
@@ -9,7 +9,7 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticContext
import org.jetbrains.kotlin.diagnostics.KtDiagnostic
import org.jetbrains.kotlin.diagnostics.Severity
class SimpleDiagnosticsCollector : BaseDiagnosticsCollector() {
class SimpleDiagnosticsCollector(override val rawReport: (Boolean, String) -> Unit = { _, _ -> }) : BaseDiagnosticsCollector() {
private val _diagnosticsByFilePath: MutableMap<String?, MutableList<KtDiagnostic>> = mutableMapOf()
override val diagnostics: List<KtDiagnostic>
get() = _diagnosticsByFilePath.flatMap { it.value }
@@ -9,7 +9,7 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticContext
import org.jetbrains.kotlin.diagnostics.KtDiagnostic
import org.jetbrains.kotlin.diagnostics.Severity
class SimpleDiagnosticsCollectorWithSuppress : BaseDiagnosticsCollector() {
class SimpleDiagnosticsCollectorWithSuppress(override val rawReport: (Boolean, String) -> Unit) : BaseDiagnosticsCollector() {
private val _diagnosticsByFilePath: MutableMap<String?, MutableList<KtDiagnostic>> = mutableMapOf()
override val diagnostics: List<KtDiagnostic>
get() = _diagnosticsByFilePath.flatMap { it.value }