Fix add modifier for replacement case, add expect/actual order tests

This commit is contained in:
Mikhail Glukhikh
2017-09-15 18:10:33 +03:00
committed by Stanislav Erokhin
parent 2c521727c3
commit e12de11ce9
14 changed files with 32 additions and 5 deletions
@@ -83,10 +83,11 @@ internal fun addModifier(modifierList: KtModifierList, modifier: KtModifierKeywo
} }
return return
} }
if (modifierToReplace != null) { if (modifierToReplace != null && modifierList.firstChild == modifierList.lastChild) {
modifierToReplace.replace(newModifier) modifierToReplace.replace(newModifier)
} }
else { else {
modifierToReplace?.delete()
val newModifierOrder = MODIFIERS_ORDER.indexOf(modifier) val newModifierOrder = MODIFIERS_ORDER.indexOf(modifier)
fun placeAfter(child: PsiElement): Boolean { fun placeAfter(child: PsiElement): Boolean {
@@ -1 +1 @@
anno<caret>tation private class Ann private annotation class Ann
@@ -1 +1 @@
annotation private cla<caret>ss Ann private annotation class Ann
@@ -0,0 +1,3 @@
// "Replace with 'expect'" "true"
public open <caret>header class My
@@ -0,0 +1,3 @@
// "Replace with 'expect'" "true"
public expect open class My
@@ -0,0 +1 @@
actual class My
@@ -0,0 +1 @@
actual class My
@@ -0,0 +1 @@
header fun foo(n: Int): Int
@@ -0,0 +1 @@
header fun foo(n: Int): Int
@@ -0,0 +1,3 @@
// "Replace with 'actual'" "true"
<caret>impl public tailrec fun foo(n: Int): Int = if (n < 2) n else foo(n - 1)
@@ -0,0 +1,3 @@
// "Replace with 'actual'" "true"
public actual tailrec fun foo(n: Int): Int = if (n < 2) n else foo(n - 1)
@@ -4,7 +4,7 @@ interface X {
} }
interface XX : X { interface XX : X {
override open fun foo() { open override fun foo() {
} }
} }
@@ -4,7 +4,7 @@ interface X {
} }
interface XX : X { interface XX : X {
override open fun foo() { open override fun foo() {
} }
} }
@@ -94,6 +94,16 @@ class QuickFixMultiModuleTest : AbstractQuickFixMultiModuleTest() {
doMultiPlatformTest() doMultiPlatformTest()
} }
@Test
fun testOrderHeader() {
doMultiPlatformTest()
}
@Test
fun testOrderImpl() {
doMultiPlatformTest()
}
@Test @Test
fun testPackage() { fun testPackage() {
doMultiPlatformTest() doMultiPlatformTest()