[Test] Add ability to disable DEBUG_INFO diagnostics except explicitly defined

This commit is contained in:
Dmitriy Novozhilov
2021-05-14 13:12:53 +03:00
committed by TeamCityServer
parent d44782f49f
commit 6aca0bb374
2 changed files with 13 additions and 2 deletions
@@ -70,4 +70,11 @@ object DiagnosticsDirectives : SimpleDirectivesContainer() {
(additional to root package)
""".trimIndent()
)
val REPORT_ONLY_EXPLICITLY_DEFINED_DEBUG_INFO by directive(
description = """
If this directive enabled then `DEBUG_INFO_...` diagnostics will be reported
only if they are defined in testdata.
""".trimIndent()
)
}
@@ -119,9 +119,13 @@ class ClassicDiagnosticsHandler(testServices: TestServices) : ClassicFrontendAna
info.analysisResult.moduleDescriptor as ModuleDescriptorImpl,
diagnosedRanges = diagnosedRanges
)
debugAnnotations.mapNotNull { debugAnnotation ->
val onlyExplicitlyDefined = DiagnosticsDirectives.REPORT_ONLY_EXPLICITLY_DEFINED_DEBUG_INFO in module.directives
for (debugAnnotation in debugAnnotations) {
val factory = debugAnnotation.diagnostic.factory
if (!diagnosticsService.shouldRenderDiagnostic(module, factory.name, factory.severity)) return@mapNotNull null
if (!diagnosticsService.shouldRenderDiagnostic(module, factory.name, factory.severity)) continue
if (onlyExplicitlyDefined && !debugAnnotation.diagnostic.textRanges.any { it.startOffset..it.endOffset in diagnosedRanges }) {
continue
}
reporter.reportDiagnostic(debugAnnotation.diagnostic, module, file, configuration, withNewInferenceModeEnabled)
}
}