K2 LL API: implement automatic diagnostic suppression
This commit is contained in:
+2
-5
@@ -10,7 +10,6 @@ import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
|
||||
import org.jetbrains.kotlin.diagnostics.impl.PendingDiagnosticsCollectorWithSuppress
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFile
|
||||
import org.jetbrains.kotlin.fir.visitors.FirVisitor
|
||||
|
||||
@@ -21,10 +20,8 @@ abstract class AbstractDiagnosticCollectorComponent(
|
||||
override fun visitElement(element: FirElement, data: CheckerContext) {}
|
||||
|
||||
protected fun checkAndCommitReportsOn(element: FirElement, context: DiagnosticContext?) {
|
||||
if (reporter is PendingDiagnosticsCollectorWithSuppress) {
|
||||
val source = element.source ?: return
|
||||
reporter.checkAndCommitReportsOn(source, context, context == null)
|
||||
}
|
||||
val source = element.source ?: return
|
||||
reporter.checkAndCommitReportsOn(source, context)
|
||||
}
|
||||
|
||||
open fun endOfFile(file: FirFile) {}
|
||||
|
||||
@@ -27,6 +27,9 @@ abstract class MutableDiagnosticContext : DiagnosticContext {
|
||||
|
||||
abstract class DiagnosticReporter {
|
||||
abstract fun report(diagnostic: KtDiagnostic?, context: DiagnosticContext)
|
||||
|
||||
open fun checkAndCommitReportsOn(element: AbstractKtSourceElement, context: DiagnosticContext?) {
|
||||
}
|
||||
}
|
||||
|
||||
open class KtDiagnosticReporterWithContext(
|
||||
|
||||
+3
-3
@@ -29,11 +29,11 @@ class PendingDiagnosticsCollectorWithSuppress : BaseDiagnosticsCollector() {
|
||||
}
|
||||
}
|
||||
|
||||
fun checkAndCommitReportsOn(
|
||||
override fun checkAndCommitReportsOn(
|
||||
element: AbstractKtSourceElement,
|
||||
context: DiagnosticContext?,
|
||||
commitEverything: Boolean
|
||||
context: DiagnosticContext?
|
||||
) {
|
||||
val commitEverything = context == null
|
||||
for ((path, pendingList) in pendingDiagnosticsByFilePath) {
|
||||
val committedList = _diagnosticsByFilePath.getOrPut(path) { mutableListOf() }
|
||||
val iterator = pendingList.iterator()
|
||||
|
||||
Reference in New Issue
Block a user