FIR IDE: Allow FIR-specific "after" files for
AbstractHighLevelQuickFixTest.
This commit is contained in:
committed by
Ilya Kirillov
parent
14ca2d207d
commit
e9298d1d71
+12
-1
@@ -7,7 +7,9 @@ package org.jetbrains.kotlin.idea.quickfix
|
|||||||
|
|
||||||
import com.intellij.codeInsight.intention.IntentionAction
|
import com.intellij.codeInsight.intention.IntentionAction
|
||||||
import com.intellij.codeInspection.InspectionProfileEntry
|
import com.intellij.codeInspection.InspectionProfileEntry
|
||||||
|
import com.intellij.openapi.util.io.FileUtil
|
||||||
import org.jetbrains.kotlin.test.uitls.IgnoreTests
|
import org.jetbrains.kotlin.test.uitls.IgnoreTests
|
||||||
|
import java.io.File
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
|
|
||||||
|
|
||||||
@@ -15,7 +17,7 @@ abstract class AbstractHighLevelQuickFixTest : AbstractQuickFixTest() {
|
|||||||
override fun doTest(beforeFileName: String) {
|
override fun doTest(beforeFileName: String) {
|
||||||
IgnoreTests.runTestIfEnabledByFileDirective(
|
IgnoreTests.runTestIfEnabledByFileDirective(
|
||||||
Paths.get(beforeFileName),
|
Paths.get(beforeFileName),
|
||||||
enableTestDirective = IgnoreTests.DIRECTIVES.FIR_COMPARISON_MUTLTILINE_COMMENT,
|
enableTestDirective = IgnoreTests.DIRECTIVES.FIR_COMPARISON_MULTILINE_COMMENT,
|
||||||
directivePosition = IgnoreTests.DirectivePosition.LAST_LINE_IN_FILE,
|
directivePosition = IgnoreTests.DirectivePosition.LAST_LINE_IN_FILE,
|
||||||
additionalFilesExtensions = arrayOf("after")
|
additionalFilesExtensions = arrayOf("after")
|
||||||
) {
|
) {
|
||||||
@@ -23,6 +25,15 @@ abstract class AbstractHighLevelQuickFixTest : AbstractQuickFixTest() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getAfterFileName(beforeFileName: String): String {
|
||||||
|
val firAfterFile = File(testPath(beforeFileName + ".fir.after"))
|
||||||
|
return if (firAfterFile.exists()) {
|
||||||
|
firAfterFile.name
|
||||||
|
} else {
|
||||||
|
super.getAfterFileName(beforeFileName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Enable these as more actions/inspections are enabled, and/or add more FIR-specific directives
|
// TODO: Enable these as more actions/inspections are enabled, and/or add more FIR-specific directives
|
||||||
override fun checkForUnexpectedErrors() {}
|
override fun checkForUnexpectedErrors() {}
|
||||||
override fun checkAvailableActionsAreExpected(actions: List<IntentionAction>) {}
|
override fun checkAvailableActionsAreExpected(actions: List<IntentionAction>) {}
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ object IgnoreTests {
|
|||||||
|
|
||||||
object DIRECTIVES {
|
object DIRECTIVES {
|
||||||
const val FIR_COMPARISON = "// FIR_COMPARISON"
|
const val FIR_COMPARISON = "// FIR_COMPARISON"
|
||||||
const val FIR_COMPARISON_MUTLTILINE_COMMENT = "/* FIR_COMPARISON */"
|
const val FIR_COMPARISON_MULTILINE_COMMENT = "/* FIR_COMPARISON */"
|
||||||
const val IGNORE_FIR = "// IGNORE_FIR"
|
const val IGNORE_FIR = "// IGNORE_FIR"
|
||||||
const val FIX_ME = "// FIX_ME: "
|
const val FIX_ME = "// FIX_ME: "
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,4 +5,5 @@ fun foo(a: String?) {
|
|||||||
// comment2
|
// comment2
|
||||||
.<caret>length
|
.<caret>length
|
||||||
}
|
}
|
||||||
|
// FIR_IDENTICAL
|
||||||
/* FIR_COMPARISON */
|
/* FIR_COMPARISON */
|
||||||
@@ -5,4 +5,5 @@ fun foo(a: String?) {
|
|||||||
// comment2
|
// comment2
|
||||||
?.length
|
?.length
|
||||||
}
|
}
|
||||||
|
// FIR_IDENTICAL
|
||||||
/* FIR_COMPARISON */
|
/* FIR_COMPARISON */
|
||||||
@@ -4,4 +4,5 @@ fun foo(a: String?) {
|
|||||||
val b = a
|
val b = a
|
||||||
.<caret>length
|
.<caret>length
|
||||||
}
|
}
|
||||||
|
// FIR_IDENTICAL
|
||||||
/* FIR_COMPARISON */
|
/* FIR_COMPARISON */
|
||||||
@@ -4,4 +4,5 @@ fun foo(a: String?) {
|
|||||||
val b = a
|
val b = a
|
||||||
?.length
|
?.length
|
||||||
}
|
}
|
||||||
|
// FIR_IDENTICAL
|
||||||
/* FIR_COMPARISON */
|
/* FIR_COMPARISON */
|
||||||
@@ -191,7 +191,7 @@ abstract class AbstractQuickFixTest : KotlinLightCodeInsightFixtureTestCase(), Q
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
myFixture.checkResultByFile(File(fileName).name + ".after")
|
myFixture.checkResultByFile(getAfterFileName(fileName))
|
||||||
|
|
||||||
if (stubComparisonFailure != null) {
|
if (stubComparisonFailure != null) {
|
||||||
throw stubComparisonFailure
|
throw stubComparisonFailure
|
||||||
@@ -201,6 +201,10 @@ abstract class AbstractQuickFixTest : KotlinLightCodeInsightFixtureTestCase(), Q
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected open fun getAfterFileName(beforeFileName: String): String {
|
||||||
|
return File(beforeFileName).name + ".after"
|
||||||
|
}
|
||||||
|
|
||||||
@Throws(ClassNotFoundException::class)
|
@Throws(ClassNotFoundException::class)
|
||||||
private fun checkForUnexpectedActions() {
|
private fun checkForUnexpectedActions() {
|
||||||
val text = myFixture.editor.document.text
|
val text = myFixture.editor.document.text
|
||||||
|
|||||||
Reference in New Issue
Block a user