KotlinCreateTestIntention: disallow intention for expect classes

#KT-26242 Fixed
This commit is contained in:
Dmitry Gridin
2019-07-16 15:43:14 +03:00
parent 311cfc3806
commit c76ca988eb
5 changed files with 11 additions and 2 deletions
@@ -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,5 +1,4 @@
// "Implement members" "false"
// ACTION: Create test
// ACTION: Make internal
// ACTION: Extract 'A' from current file
@@ -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/");