KotlinCreateTestIntention: disallow intention for expect classes
#KT-26242 Fixed
This commit is contained in:
@@ -47,13 +47,14 @@ import org.jetbrains.kotlin.idea.util.runWhenSmart
|
||||
import org.jetbrains.kotlin.idea.util.runWithAlternativeResolveEnabled
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||
import org.jetbrains.kotlin.psi.psiUtil.hasExpectModifier
|
||||
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
||||
import java.util.*
|
||||
|
||||
class KotlinCreateTestIntention : SelfTargetingRangeIntention<KtNamedDeclaration>(KtNamedDeclaration::class.java, "Create test") {
|
||||
override fun applicabilityRange(element: KtNamedDeclaration): TextRange? {
|
||||
if (element.hasExpectModifier() || element.nameIdentifier == null) return null
|
||||
if (ModuleUtilCore.findModuleForPsiElement(element) == null) return null
|
||||
if (element.nameIdentifier == null) return null
|
||||
|
||||
if (element is KtClassOrObject) {
|
||||
if (element.isLocal) return null
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
// "Create test" "false"
|
||||
// ACTION: Rename file to Foo.kt
|
||||
expect class <caret>Foo
|
||||
@@ -0,0 +1 @@
|
||||
actual class Foo
|
||||
-1
@@ -1,5 +1,4 @@
|
||||
// "Implement members" "false"
|
||||
// ACTION: Create test
|
||||
// ACTION: Make internal
|
||||
// ACTION: Extract 'A' from current file
|
||||
|
||||
|
||||
+5
@@ -219,6 +219,11 @@ public class QuickFixMultiModuleTestGenerated extends AbstractQuickFixMultiModul
|
||||
runTest("idea/testData/multiModuleQuickFix/createFunInExpectClass/");
|
||||
}
|
||||
|
||||
@TestMetadata("createTestOnExpect")
|
||||
public void testCreateTestOnExpect() throws Exception {
|
||||
runTest("idea/testData/multiModuleQuickFix/createTestOnExpect/");
|
||||
}
|
||||
|
||||
@TestMetadata("createValInExpectClass")
|
||||
public void testCreateValInExpectClass() throws Exception {
|
||||
runTest("idea/testData/multiModuleQuickFix/createValInExpectClass/");
|
||||
|
||||
Reference in New Issue
Block a user