FIR IDE: do not report suppressed diagnostics
This commit is contained in:
+14
@@ -5,7 +5,9 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.analysis.checkers.context
|
||||
|
||||
import org.jetbrains.kotlin.diagnostics.Severity
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnostic
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
|
||||
import org.jetbrains.kotlin.fir.expressions.FirGetClassCall
|
||||
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccess
|
||||
@@ -39,6 +41,18 @@ abstract class CheckerContext {
|
||||
allWarningsSuppressed: Boolean,
|
||||
allErrorsSuppressed: Boolean
|
||||
): PersistentCheckerContext
|
||||
|
||||
fun isDiagnosticSuppressed(diagnostic: FirDiagnostic<*>): Boolean {
|
||||
val factory = diagnostic.factory
|
||||
val name = factory.name
|
||||
val suppressedByAll = when (factory.severity) {
|
||||
Severity.INFO -> allInfosSuppressed
|
||||
Severity.WARNING -> allWarningsSuppressed
|
||||
Severity.ERROR -> allErrorsSuppressed
|
||||
}
|
||||
|
||||
return suppressedByAll || name in suppressedDiagnostics
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
-10
@@ -5,7 +5,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.analysis.diagnostics.impl
|
||||
|
||||
import org.jetbrains.kotlin.diagnostics.Severity
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnostic
|
||||
|
||||
@@ -16,15 +15,8 @@ class DiagnosticReporterWithSuppress : BaseDiagnosticReporter() {
|
||||
|
||||
override fun report(diagnostic: FirDiagnostic<*>?, context: CheckerContext) {
|
||||
if (diagnostic == null) return
|
||||
val factory = diagnostic.factory
|
||||
val name = factory.name
|
||||
val suppressedByAll = when (factory.severity) {
|
||||
Severity.INFO -> context.allInfosSuppressed
|
||||
Severity.WARNING -> context.allWarningsSuppressed
|
||||
Severity.ERROR -> context.allErrorsSuppressed
|
||||
if (!context.isDiagnosticSuppressed(diagnostic)) {
|
||||
_diagnostics += diagnostic
|
||||
}
|
||||
|
||||
if (suppressedByAll || name in context.suppressedDiagnostics) return
|
||||
_diagnostics += diagnostic
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -54,6 +54,7 @@ internal abstract class AbstractFirIdeDiagnosticsCollector(
|
||||
private inner class Reporter : DiagnosticReporter() {
|
||||
override fun report(diagnostic: FirDiagnostic<*>?, context: CheckerContext) {
|
||||
if (diagnostic !is FirPsiDiagnostic<*>) return
|
||||
if (context.isDiagnosticSuppressed(diagnostic)) return
|
||||
onDiagnostic(diagnostic)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user