From 68d7e51d3270433b69bd4ef05ddf3e13f03780d9 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Mon, 24 Sep 2018 13:51:36 +0300 Subject: [PATCH] Support test directive for rendering full diagnostic messages New `RENDER_DIAGNOSTICS_MESSAGES` directive forces test system render full messages for all diagnostics that found in test file --- .../kotlin/checkers/CheckerTestUtil.java | 27 ++++++++++++++++--- compiler/testData/diagnostics/ReadMe.md | 8 ++++++ .../kotlin/checkers/BaseDiagnosticsTest.kt | 7 ++++- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/checkers/CheckerTestUtil.java b/compiler/frontend/src/org/jetbrains/kotlin/checkers/CheckerTestUtil.java index b36c737fb1d..eb6916add7f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/checkers/CheckerTestUtil.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/checkers/CheckerTestUtil.java @@ -411,6 +411,18 @@ public class CheckerTestUtil { @NotNull Function getFileText, @NotNull Collection uncheckedDiagnostics, boolean withNewInferenceDirective + ) { + return addDiagnosticMarkersToText(psiFile, diagnostics, diagnosticToExpectedDiagnostic, getFileText, uncheckedDiagnostics, withNewInferenceDirective, false); + } + + public static StringBuffer addDiagnosticMarkersToText( + @NotNull PsiFile psiFile, + @NotNull Collection diagnostics, + @NotNull Map diagnosticToExpectedDiagnostic, + @NotNull Function getFileText, + @NotNull Collection uncheckedDiagnostics, + boolean withNewInferenceDirective, + boolean renderDiagnosticMessages ) { String text = getFileText.fun(psiFile); StringBuffer result = new StringBuffer(); @@ -433,7 +445,7 @@ public class CheckerTestUtil { opened.pop(); } while (currentDescriptor != null && i == currentDescriptor.start) { - openDiagnosticsString(result, currentDescriptor, diagnosticToExpectedDiagnostic, withNewInferenceDirective); + openDiagnosticsString(result, currentDescriptor, diagnosticToExpectedDiagnostic, withNewInferenceDirective, renderDiagnosticMessages); if (currentDescriptor.getEnd() == i) { closeDiagnosticString(result); } @@ -453,7 +465,7 @@ public class CheckerTestUtil { if (currentDescriptor != null) { assert currentDescriptor.start == text.length(); assert currentDescriptor.end == text.length(); - openDiagnosticsString(result, currentDescriptor, diagnosticToExpectedDiagnostic, withNewInferenceDirective); + openDiagnosticsString(result, currentDescriptor, diagnosticToExpectedDiagnostic, withNewInferenceDirective, renderDiagnosticMessages); opened.push(currentDescriptor); } @@ -471,7 +483,8 @@ public class CheckerTestUtil { StringBuffer result, AbstractDiagnosticDescriptor currentDescriptor, Map diagnosticToExpectedDiagnostic, - boolean withNewInferenceDirective + boolean withNewInferenceDirective, + boolean renderDiagnosticMessages ) { result.append(" = ArrayList() val withNewInferenceDirective: Boolean val newInferenceEnabled: Boolean + val renderDiagnosticMessages: Boolean init { this.declareCheckType = CHECK_TYPE_DIRECTIVE in directives @@ -162,6 +163,7 @@ abstract class BaseDiagnosticsTest : KotlinMultiFileTestWithJava file.text }, uncheckedDiagnostics, - withNewInferenceDirective + withNewInferenceDirective, + renderDiagnosticMessages ) ) @@ -375,6 +378,8 @@ abstract class BaseDiagnosticsTest : KotlinMultiFileTestWithJava, allowUnderscoreUsage: Boolean