Specify relevant declaration type in "create actual" fix #KT-20325 Fixed
This commit is contained in:
@@ -156,7 +156,19 @@ class CreateActualClassFix(
|
|||||||
generateClassOrObject(project, element, actualNeeded = true)
|
generateClassOrObject(project, element, actualNeeded = true)
|
||||||
}) {
|
}) {
|
||||||
|
|
||||||
override val elementType = if ((element as? KtClass)?.isInterface() == true) "interface" else "class"
|
override val elementType = run {
|
||||||
|
val element = element
|
||||||
|
when (element) {
|
||||||
|
is KtObjectDeclaration -> "object"
|
||||||
|
is KtClass -> when {
|
||||||
|
element.isInterface() -> "interface"
|
||||||
|
element.isEnum() -> "enum class"
|
||||||
|
element.isAnnotation() -> "annotation class"
|
||||||
|
else -> "class"
|
||||||
|
}
|
||||||
|
else -> "class"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CreateActualPropertyFix(
|
class CreateActualPropertyFix(
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
// "Create actual annotation class for platform JVM" "true"
|
||||||
|
|
||||||
|
expect annotation class <caret>Ann(val x: Int, val y: String)
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
// "Create actual annotation class for platform JVM" "true"
|
||||||
|
|
||||||
|
expect annotation class Ann(val x: Int, val y: String)
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
// Ann: to be implemented
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
// Ann: to be implemented
|
||||||
|
actual annotation class Ann(val x: Int, val y: String)
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// "Create actual class for platform JS" "true"
|
// "Create actual enum class for platform JS" "true"
|
||||||
|
|
||||||
expect enum class <caret>MyEnum {
|
expect enum class <caret>MyEnum {
|
||||||
FIRST,
|
FIRST,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// "Create actual class for platform JS" "true"
|
// "Create actual enum class for platform JS" "true"
|
||||||
|
|
||||||
expect enum class MyEnum {
|
expect enum class MyEnum {
|
||||||
FIRST,
|
FIRST,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// "Create actual class for platform JVM" "true"
|
// "Create actual object for platform JVM" "true"
|
||||||
|
|
||||||
expect object <caret>Object {
|
expect object <caret>Object {
|
||||||
fun foo(): String
|
fun foo(): String
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// "Create actual class for platform JVM" "true"
|
// "Create actual object for platform JVM" "true"
|
||||||
|
|
||||||
expect object Object {
|
expect object Object {
|
||||||
fun foo(): String
|
fun foo(): String
|
||||||
|
|||||||
@@ -49,6 +49,11 @@ class QuickFixMultiModuleTest : AbstractQuickFixMultiModuleTest() {
|
|||||||
doMultiPlatformTest(impls = "js" to TargetPlatformKind.JavaScript)
|
doMultiPlatformTest(impls = "js" to TargetPlatformKind.JavaScript)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testAnnotation() {
|
||||||
|
doMultiPlatformTest()
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testClass() {
|
fun testClass() {
|
||||||
doMultiPlatformTest()
|
doMultiPlatformTest()
|
||||||
|
|||||||
Reference in New Issue
Block a user