Update pattern for finding diagnostics in diagnostic tests
Also use updated diagnostic pattern in TreesCompareTest.
In rare cases diagnostic was cut too early on !> characters,
that were a part of diagnostic parameter:
<!DIAGNOSTIC("Type<DefinitelyNotNullTypeArgument!!>")!>
This commit is contained in:
+2
-1
@@ -10,6 +10,7 @@ import com.intellij.openapi.vfs.CharsetToolkit
|
||||
import com.intellij.testFramework.TestDataPath
|
||||
import com.intellij.util.PathUtil
|
||||
import junit.framework.TestCase
|
||||
import org.jetbrains.kotlin.checkers.BaseDiagnosticsTest.Companion.DIAGNOSTIC_IN_TESTDATA_PATTERN
|
||||
import org.jetbrains.kotlin.fir.FirRenderer
|
||||
import org.jetbrains.kotlin.fir.builder.AbstractRawFirBuilderTestCase
|
||||
import org.jetbrains.kotlin.fir.builder.StubFirScopeProvider
|
||||
@@ -77,7 +78,7 @@ class TreesCompareTest : AbstractRawFirBuilderTestCase() {
|
||||
return@compareBase true
|
||||
}
|
||||
val notEditedText = FileUtil.loadFile(file, CharsetToolkit.UTF8, true).trim()
|
||||
val text = notEditedText.replace("(<!>)|(<!.*?!>)".toRegex(), "").replaceAfter(".java", "")
|
||||
val text = notEditedText.replace(DIAGNOSTIC_IN_TESTDATA_PATTERN, "").replaceAfter(".java", "")
|
||||
|
||||
//psi
|
||||
val ktFile = createPsiFile(FileUtil.getNameWithoutExtension(PathUtil.getFileName(file.path)), text) as KtFile
|
||||
|
||||
+4
-4
@@ -3,9 +3,9 @@
|
||||
|
||||
fun <T : Derived?> test(derived: T) {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Out<Base>")!>id<Out<Base>>(
|
||||
makeOut(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Out<T!!>")!>makeOut(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("T!!")!>makeDnn(derived)<!>
|
||||
)
|
||||
)<!>
|
||||
)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("In<Base>")!>id<In<Base>>(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("In<Base>")!>makeIn(
|
||||
@@ -18,9 +18,9 @@ fun <T : Derived?> test(derived: T) {
|
||||
)<!>
|
||||
)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("In<In<Base>>")!>id<In<In<Base>>>(
|
||||
makeInIn(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("In<In<T!!>>")!>makeInIn(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("T!!")!>makeDnn(derived)<!>
|
||||
)
|
||||
)<!>
|
||||
)<!>
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -30,5 +30,5 @@ val strList: List<String> = null!!
|
||||
fun main() {
|
||||
val rawB = Test.rawAField.b;
|
||||
// Raw(A).b is not erased because it have no type parameters
|
||||
var rawInner = rawB.<!INAPPLICABLE_CANDIDATE!>bar<!>(<!UNRESOLVED_REFERENCE!>!<!>", "<!UNRESOLVED_REFERENCE!>List<!><!SYNTAX!><<!><!UNRESOLVED_REFERENCE!>String<!><!SYNTAX!>><!><!SYNTAX!><!>")!>strList)<!SYNTAX, SYNTAX!><!>
|
||||
var rawInner = rawB.<!INAPPLICABLE_CANDIDATE!>bar<!>(strList)
|
||||
}
|
||||
|
||||
@@ -406,6 +406,8 @@ abstract class BaseDiagnosticsTest : KotlinMultiFileTestWithJava<TestModule, Tes
|
||||
|
||||
val RENDER_DIAGNOSTICS_MESSAGES = "RENDER_DIAGNOSTICS_MESSAGES"
|
||||
|
||||
val DIAGNOSTIC_IN_TESTDATA_PATTERN = Regex("<!>|<!(.*?(\\(\".*?\"\\)|\\(\\))??)+(?<!<)!>")
|
||||
|
||||
fun parseDiagnosticFilterDirective(
|
||||
directiveMap: Map<String, String>,
|
||||
allowUnderscoreUsage: Boolean
|
||||
@@ -477,8 +479,6 @@ abstract class BaseDiagnosticsTest : KotlinMultiFileTestWithJava<TestModule, Tes
|
||||
)
|
||||
}
|
||||
|
||||
private val DIAGNOSTIC_IN_TESTDATA_PATTERN = Regex("(<!>|(<!(.(\".*\")*?)+?!>))")
|
||||
|
||||
fun loadTestDataWithoutDiagnostics(file: File): String {
|
||||
val textWithoutDiagnostics = KotlinTestUtils.doLoadFile(file).replace(DIAGNOSTIC_IN_TESTDATA_PATTERN, "")
|
||||
return StringUtil.convertLineSeparators(textWithoutDiagnostics.trim()).trimTrailingWhitespacesAndAddNewlineAtEOF()
|
||||
|
||||
Reference in New Issue
Block a user