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.idea.util.runWithAlternativeResolveEnabled
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.hasExpectModifier
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class KotlinCreateTestIntention : SelfTargetingRangeIntention<KtNamedDeclaration>(KtNamedDeclaration::class.java, "Create test") {
|
class KotlinCreateTestIntention : SelfTargetingRangeIntention<KtNamedDeclaration>(KtNamedDeclaration::class.java, "Create test") {
|
||||||
override fun applicabilityRange(element: KtNamedDeclaration): TextRange? {
|
override fun applicabilityRange(element: KtNamedDeclaration): TextRange? {
|
||||||
|
if (element.hasExpectModifier() || element.nameIdentifier == null) return null
|
||||||
if (ModuleUtilCore.findModuleForPsiElement(element) == null) return null
|
if (ModuleUtilCore.findModuleForPsiElement(element) == null) return null
|
||||||
if (element.nameIdentifier == null) return null
|
|
||||||
|
|
||||||
if (element is KtClassOrObject) {
|
if (element is KtClassOrObject) {
|
||||||
if (element.isLocal) return null
|
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"
|
// "Implement members" "false"
|
||||||
// ACTION: Create test
|
|
||||||
// ACTION: Make internal
|
// ACTION: Make internal
|
||||||
// ACTION: Extract 'A' from current file
|
// ACTION: Extract 'A' from current file
|
||||||
|
|
||||||
|
|||||||
+5
@@ -219,6 +219,11 @@ public class QuickFixMultiModuleTestGenerated extends AbstractQuickFixMultiModul
|
|||||||
runTest("idea/testData/multiModuleQuickFix/createFunInExpectClass/");
|
runTest("idea/testData/multiModuleQuickFix/createFunInExpectClass/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("createTestOnExpect")
|
||||||
|
public void testCreateTestOnExpect() throws Exception {
|
||||||
|
runTest("idea/testData/multiModuleQuickFix/createTestOnExpect/");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("createValInExpectClass")
|
@TestMetadata("createValInExpectClass")
|
||||||
public void testCreateValInExpectClass() throws Exception {
|
public void testCreateValInExpectClass() throws Exception {
|
||||||
runTest("idea/testData/multiModuleQuickFix/createValInExpectClass/");
|
runTest("idea/testData/multiModuleQuickFix/createValInExpectClass/");
|
||||||
|
|||||||
Reference in New Issue
Block a user