Safe delete: when invoking on expect, delete also relevant actual
Partial fix of KT-15666
This commit is contained in:
+12
-9
@@ -57,10 +57,7 @@ import org.jetbrains.kotlin.idea.util.actualsForExpected
|
||||
import org.jetbrains.kotlin.idea.util.liftToExpected
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getParentOfTypeAndBranch
|
||||
import org.jetbrains.kotlin.psi.psiUtil.hasActualModifier
|
||||
import org.jetbrains.kotlin.psi.psiUtil.parameterIndex
|
||||
import org.jetbrains.kotlin.psi.psiUtil.*
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
import org.jetbrains.kotlin.utils.SmartSet
|
||||
@@ -388,11 +385,17 @@ class KotlinSafeDeleteProcessor : JavaSafeDeleteProcessor() {
|
||||
override fun prepareForDeletion(element: PsiElement) {
|
||||
if (element is KtDeclaration) {
|
||||
element.actualsForExpected().forEach {
|
||||
if (it is KtParameter) {
|
||||
(it.parent as? KtParameterList)?.removeParameter(it)
|
||||
} else {
|
||||
it.removeModifier(KtTokens.IMPL_KEYWORD)
|
||||
it.removeModifier(KtTokens.ACTUAL_KEYWORD)
|
||||
when (it) {
|
||||
is KtParameter -> {
|
||||
(it.parent as? KtParameterList)?.removeParameter(it)
|
||||
}
|
||||
is KtCallableDeclaration, is KtClassOrObject, is KtTypeAlias -> {
|
||||
it.delete()
|
||||
}
|
||||
else -> {
|
||||
it.removeModifier(KtTokens.IMPL_KEYWORD)
|
||||
it.removeModifier(KtTokens.ACTUAL_KEYWORD)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+11
-6
@@ -377,12 +377,17 @@ class KotlinSafeDeleteProcessor : JavaSafeDeleteProcessor() {
|
||||
override fun prepareForDeletion(element: PsiElement) {
|
||||
if (element is KtDeclaration) {
|
||||
element.actualsForExpected().forEach {
|
||||
if (it is KtParameter) {
|
||||
(it.parent as? KtParameterList)?.removeParameter(it)
|
||||
}
|
||||
else {
|
||||
it.removeModifier(KtTokens.IMPL_KEYWORD)
|
||||
it.removeModifier(KtTokens.ACTUAL_KEYWORD)
|
||||
when (it) {
|
||||
is KtParameter -> {
|
||||
(it.parent as? KtParameterList)?.removeParameter(it)
|
||||
}
|
||||
is KtCallableDeclaration, is KtClassOrObject, is KtTypeAlias -> {
|
||||
it.delete()
|
||||
}
|
||||
else -> {
|
||||
it.removeModifier(KtTokens.IMPL_KEYWORD)
|
||||
it.removeModifier(KtTokens.ACTUAL_KEYWORD)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+11
-6
@@ -387,12 +387,17 @@ class KotlinSafeDeleteProcessor : JavaSafeDeleteProcessor() {
|
||||
override fun prepareForDeletion(element: PsiElement) {
|
||||
if (element is KtDeclaration) {
|
||||
element.actualsForExpected().forEach {
|
||||
if (it is KtParameter) {
|
||||
(it.parent as? KtParameterList)?.removeParameter(it)
|
||||
}
|
||||
else {
|
||||
it.removeModifier(KtTokens.IMPL_KEYWORD)
|
||||
it.removeModifier(KtTokens.ACTUAL_KEYWORD)
|
||||
when (it) {
|
||||
is KtParameter -> {
|
||||
(it.parent as? KtParameterList)?.removeParameter(it)
|
||||
}
|
||||
is KtCallableDeclaration, is KtClassOrObject, is KtTypeAlias -> {
|
||||
it.delete()
|
||||
}
|
||||
else -> {
|
||||
it.removeModifier(KtTokens.IMPL_KEYWORD)
|
||||
it.removeModifier(KtTokens.ACTUAL_KEYWORD)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
package test
|
||||
|
||||
open class Foo
|
||||
actual class ChildOfFoo : Foo()
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
package test
|
||||
|
||||
open class Foo
|
||||
actual class ChildOfFoo : Foo()
|
||||
Vendored
-3
@@ -1,9 +1,6 @@
|
||||
package test
|
||||
|
||||
actual class Foo {
|
||||
fun foo(n: Int) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fun test(f: Foo) {
|
||||
|
||||
Vendored
-3
@@ -1,9 +1,6 @@
|
||||
package test
|
||||
|
||||
actual class Foo {
|
||||
fun foo(n: Int) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fun test(f: Foo) {
|
||||
|
||||
Vendored
-1
@@ -1,7 +1,6 @@
|
||||
package test
|
||||
|
||||
actual class Foo {
|
||||
val foo get() = 1
|
||||
}
|
||||
|
||||
fun test(f: Foo) = f.foo
|
||||
Vendored
-1
@@ -1,7 +1,6 @@
|
||||
package test
|
||||
|
||||
actual class Foo {
|
||||
val foo get() = 2
|
||||
}
|
||||
|
||||
fun test(f: Foo) = f.foo
|
||||
-1
@@ -1,7 +1,6 @@
|
||||
package test
|
||||
|
||||
actual open class Foo {
|
||||
constructor(n: Int)
|
||||
}
|
||||
|
||||
fun test() = Foo(1)
|
||||
-1
@@ -1,7 +1,6 @@
|
||||
package test
|
||||
|
||||
actual open class Foo {
|
||||
constructor(n: Int)
|
||||
}
|
||||
|
||||
fun test() = Foo(2)
|
||||
-4
@@ -1,9 +1,5 @@
|
||||
package test
|
||||
|
||||
fun foo(n: Int) {
|
||||
|
||||
}
|
||||
|
||||
fun test() {
|
||||
foo(1)
|
||||
}
|
||||
-4
@@ -1,9 +1,5 @@
|
||||
package test
|
||||
|
||||
fun foo(n: Int) {
|
||||
|
||||
}
|
||||
|
||||
fun test() {
|
||||
foo(1)
|
||||
}
|
||||
-2
@@ -1,5 +1,3 @@
|
||||
package test
|
||||
|
||||
val foo get() = 1
|
||||
|
||||
fun test() = foo
|
||||
-2
@@ -1,5 +1,3 @@
|
||||
package test
|
||||
|
||||
val foo get() = 2
|
||||
|
||||
fun test() = foo
|
||||
Reference in New Issue
Block a user