FIR IDE: Assert that the action to invoke in
AbstractHighLevelQuickFixTest is of type QuickFixActionBase.
This commit is contained in:
committed by
TeamCityServer
parent
783e5972d0
commit
cd6dbd2515
+4
@@ -45,6 +45,10 @@ abstract class AbstractHighLevelQuickFixTest : AbstractQuickFixTest() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override val shouldCheckIntentionActionType: Boolean
|
||||||
|
// All quickfixes from the FIR plugin are guaranteed to be of type QuickFixActionBase (see HLDiagnosticFixFactory)
|
||||||
|
get() = true
|
||||||
|
|
||||||
// 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>) {}
|
||||||
|
|||||||
@@ -5,3 +5,4 @@ class Test {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* IGNORE_FIR */
|
||||||
@@ -6,3 +6,4 @@ class Test {
|
|||||||
}
|
}
|
||||||
set(value) {<caret>}
|
set(value) {<caret>}
|
||||||
}
|
}
|
||||||
|
/* IGNORE_FIR */
|
||||||
@@ -4,3 +4,4 @@ class Test {
|
|||||||
var x: Int<caret>
|
var x: Int<caret>
|
||||||
set(value) {}
|
set(value) {}
|
||||||
}
|
}
|
||||||
|
/* IGNORE_FIR */
|
||||||
@@ -7,3 +7,4 @@ class Test {
|
|||||||
}
|
}
|
||||||
set(value) {}
|
set(value) {}
|
||||||
}
|
}
|
||||||
|
/* IGNORE_FIR */
|
||||||
@@ -20,7 +20,6 @@ import com.intellij.testFramework.LightProjectDescriptor
|
|||||||
import com.intellij.testFramework.UsefulTestCase
|
import com.intellij.testFramework.UsefulTestCase
|
||||||
import com.intellij.util.ui.UIUtil
|
import com.intellij.util.ui.UIUtil
|
||||||
import junit.framework.TestCase
|
import junit.framework.TestCase
|
||||||
import org.jetbrains.annotations.NotNull
|
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.ResolveInDispatchThreadException
|
import org.jetbrains.kotlin.idea.caches.resolve.ResolveInDispatchThreadException
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.forceCheckForResolveInDispatchThreadInTests
|
import org.jetbrains.kotlin.idea.caches.resolve.forceCheckForResolveInDispatchThreadInTests
|
||||||
import org.jetbrains.kotlin.idea.facet.KotlinFacet
|
import org.jetbrains.kotlin.idea.facet.KotlinFacet
|
||||||
@@ -163,9 +162,12 @@ abstract class AbstractQuickFixTest : KotlinLightCodeInsightFixtureTestCase(), Q
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val writeActionResolveHandler: () -> Unit = {
|
val unwrappedIntention = unwrapIntention(intention)
|
||||||
val unwrappedIntention = unwrapIntention(intention)
|
if (shouldCheckIntentionActionType) {
|
||||||
|
assertInstanceOf(unwrappedIntention, QuickFixActionBase::class.java)
|
||||||
|
}
|
||||||
|
|
||||||
|
val writeActionResolveHandler: () -> Unit = {
|
||||||
val intentionClassName = unwrappedIntention.javaClass.name
|
val intentionClassName = unwrappedIntention.javaClass.name
|
||||||
if (!quickFixesAllowedToResolveInWriteAction.isWriteActionAllowed(intentionClassName)) {
|
if (!quickFixesAllowedToResolveInWriteAction.isWriteActionAllowed(intentionClassName)) {
|
||||||
throw ResolveInDispatchThreadException("Resolve is not allowed under the write action for `$intentionClassName`!")
|
throw ResolveInDispatchThreadException("Resolve is not allowed under the write action for `$intentionClassName`!")
|
||||||
@@ -205,6 +207,14 @@ abstract class AbstractQuickFixTest : KotlinLightCodeInsightFixtureTestCase(), Q
|
|||||||
return File(beforeFileName).name + ".after"
|
return File(beforeFileName).name + ".after"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If true, the type of the [IntentionAction] to invoke is [QuickFixActionBase]. This ensures that the action is coming from a
|
||||||
|
* quickfix (i.e., diagnostic-based), and not a regular IDE intention.
|
||||||
|
*/
|
||||||
|
protected open val shouldCheckIntentionActionType: Boolean
|
||||||
|
// For FE 1.0, many quickfixes are implemented as IntentionActions, which may or may not be used as regular IDE intentions as well
|
||||||
|
get() = false
|
||||||
|
|
||||||
@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