FIR IDE: do not remove duplicated diagnostics
This hides the real problem why diagnostics are duplicated
This commit is contained in:
+14
-6
@@ -6,10 +6,12 @@
|
||||
package org.jetbrains.kotlin.checkers
|
||||
|
||||
import com.intellij.rt.execution.junit.FileComparisonFailure
|
||||
import org.jetbrains.kotlin.idea.highlighter.AbstractHighlightingTest
|
||||
import org.jetbrains.kotlin.idea.invalidateCaches
|
||||
import org.jetbrains.kotlin.idea.test.withCustomCompilerOptions
|
||||
import org.jetbrains.kotlin.idea.withPossiblyDisabledDuplicatedFirSourceElementsException
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||
import org.jetbrains.kotlin.test.uitls.IgnoreTests
|
||||
import org.jetbrains.kotlin.test.uitls.IgnoreTests.DIRECTIVES
|
||||
import org.jetbrains.kotlin.test.uitls.IgnoreTests.cleanUpIdenticalFirTestFile
|
||||
@@ -45,14 +47,20 @@ abstract class AbstractFirKotlinHighlightingPassTest : AbstractKotlinHighlightin
|
||||
checkWeakWarnings: Boolean
|
||||
): Long {
|
||||
val fileText = file.text
|
||||
return withCustomCompilerOptions(fileText, project, module) {
|
||||
try {
|
||||
withPossiblyDisabledDuplicatedFirSourceElementsException(fileText) {
|
||||
myFixture.checkHighlighting(checkWarnings, checkInfos, checkWeakWarnings)
|
||||
val isDuplicatedHighlightingExpected =
|
||||
InTextDirectivesUtils.isDirectiveDefined(fileText, AbstractHighlightingTest.EXPECTED_DUPLICATED_HIGHLIGHTING_PREFIX)
|
||||
var result: Long? = null
|
||||
AbstractHighlightingTest.withExpectedDuplicatedHighlighting(isDuplicatedHighlightingExpected, /*isFirPlugin*/true) {
|
||||
withCustomCompilerOptions(fileText, project, module) {
|
||||
try {
|
||||
withPossiblyDisabledDuplicatedFirSourceElementsException(fileText) {
|
||||
result = myFixture.checkHighlighting(checkWarnings, checkInfos, checkWeakWarnings)
|
||||
}
|
||||
} catch (e: FileComparisonFailure) {
|
||||
throw FileComparisonFailure(e.message, e.expected, e.actual, File(e.filePath).absolutePath)
|
||||
}
|
||||
} catch (e: FileComparisonFailure) {
|
||||
throw FileComparisonFailure(e.message, e.expected, e.actual, File(e.filePath).absolutePath)
|
||||
}
|
||||
}
|
||||
return result!!
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -64,12 +64,12 @@ internal class FileStructure(
|
||||
fun getAllDiagnosticsForFile(diagnosticCheckerFilter: DiagnosticCheckerFilter): Collection<FirPsiDiagnostic<*>> {
|
||||
val structureElements = getAllStructureElements()
|
||||
|
||||
return buildSet {
|
||||
return buildList {
|
||||
collectDiagnosticsFromStructureElements(structureElements, diagnosticCheckerFilter)
|
||||
}
|
||||
}
|
||||
|
||||
private fun MutableSet<FirPsiDiagnostic<*>>.collectDiagnosticsFromStructureElements(
|
||||
private fun MutableCollection<FirPsiDiagnostic<*>>.collectDiagnosticsFromStructureElements(
|
||||
structureElements: Collection<FileStructureElement>,
|
||||
diagnosticCheckerFilter: DiagnosticCheckerFilter
|
||||
) {
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
|
||||
// EXPECTED_DUPLICATED_HIGHLIGHTING
|
||||
open class NoC
|
||||
class NoC1 : NoC()
|
||||
|
||||
@@ -18,7 +18,7 @@ class WithPC1(a : Int) {
|
||||
}
|
||||
|
||||
|
||||
class Foo() : WithPC0(), <error descr="Type expected"><error descr="[SYNTAX] Syntax error">this</error></error>() {
|
||||
class Foo() : WithPC0(), <error descr="Type expected"><error descr="[SYNTAX] Syntax error"><error descr="[SYNTAX] Syntax error">this</error></error></error>() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
|
||||
// EXPECTED_DUPLICATED_HIGHLIGHTING
|
||||
open class NoC
|
||||
class NoC1 : NoC()
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public abstract class AbstractHighlightingTest extends KotlinLightCodeInsightFix
|
||||
|
||||
myFixture.configureByFile(fileName());
|
||||
|
||||
withExpectedDuplicatedHighlighting(expectedDuplicatedHighlighting, () -> {
|
||||
withExpectedDuplicatedHighlighting(expectedDuplicatedHighlighting, isFirPlugin(), () -> {
|
||||
try {
|
||||
checkHighlighting(fileText);
|
||||
}
|
||||
@@ -54,7 +54,7 @@ public abstract class AbstractHighlightingTest extends KotlinLightCodeInsightFix
|
||||
});
|
||||
}
|
||||
|
||||
private void withExpectedDuplicatedHighlighting(boolean expectedDuplicatedHighlighting, Runnable runnable) {
|
||||
public static void withExpectedDuplicatedHighlighting(boolean expectedDuplicatedHighlighting, boolean isFirPlugin, Runnable runnable) {
|
||||
if (!expectedDuplicatedHighlighting) {
|
||||
runnable.run();
|
||||
return;
|
||||
@@ -63,7 +63,7 @@ public abstract class AbstractHighlightingTest extends KotlinLightCodeInsightFix
|
||||
try {
|
||||
ExpectedHighlightingData.expectedDuplicatedHighlighting(runnable);
|
||||
} catch (IllegalStateException e) {
|
||||
if (isFirPlugin()) {
|
||||
if (isFirPlugin) {
|
||||
runnable.run();
|
||||
} else {
|
||||
throw e;
|
||||
|
||||
Reference in New Issue
Block a user