Pull Members Up: fix invalid code format on function with comment and another indent
#KT-32426 Fixed
This commit is contained in:
committed by
Dmitry Gridin
parent
7c2f6ecba7
commit
729ed1a44e
@@ -45,6 +45,7 @@ import org.jetbrains.kotlin.idea.refactoring.memberInfo.KtPsiClassWrapper
|
||||
import org.jetbrains.kotlin.idea.refactoring.memberInfo.toKtDeclarationWrapperAware
|
||||
import org.jetbrains.kotlin.idea.refactoring.safeDelete.removeOverrideModifier
|
||||
import org.jetbrains.kotlin.idea.util.anonymousObjectSuperTypeOrNull
|
||||
import org.jetbrains.kotlin.idea.util.hasComments
|
||||
import org.jetbrains.kotlin.idea.util.psi.patternMatching.KotlinPsiUnifier
|
||||
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
@@ -503,6 +504,9 @@ class KotlinPullUpHelper(
|
||||
if (member.typeReference == null) {
|
||||
movedMember.typeReference?.addToShorteningWaitSet()
|
||||
}
|
||||
if (movedMember.nextSibling.hasComments()) {
|
||||
movedMember.parent.addAfter(psiFactory.createNewLine(), movedMember)
|
||||
}
|
||||
|
||||
removeOriginalMemberOrAddOverride(member)
|
||||
} else {
|
||||
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
open class A
|
||||
|
||||
class <caret>B : A() {
|
||||
// INFO: {"checked": "true"}
|
||||
fun barw() {
|
||||
}
|
||||
|
||||
// INFO: {"checked": "true", "toAbstract": "true"}
|
||||
val foo8: Int = 1
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
abstract class A {
|
||||
// INFO: {"checked": "true", "toAbstract": "true"}
|
||||
abstract val foo8: Int
|
||||
|
||||
// INFO: {"checked": "true"}
|
||||
fun barw() {
|
||||
}
|
||||
}
|
||||
|
||||
class B : A() {
|
||||
|
||||
// INFO: {"checked": "true", "toAbstract": "true"}
|
||||
override val foo8: Int = 1
|
||||
}
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
open class A
|
||||
|
||||
class Root {
|
||||
class <caret>B : A() {
|
||||
// INFO: {"checked": "true"}
|
||||
fun barw() {
|
||||
}
|
||||
|
||||
// INFO: {"checked": "true", "toAbstract": "true"}
|
||||
val foo8: Int = 1
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
abstract class A {
|
||||
// INFO: {"checked": "true", "toAbstract": "true"}
|
||||
abstract val foo8: Int
|
||||
|
||||
// INFO: {"checked": "true"}
|
||||
fun barw() {
|
||||
}
|
||||
}
|
||||
|
||||
class Root {
|
||||
class B : A() {
|
||||
|
||||
// INFO: {"checked": "true", "toAbstract": "true"}
|
||||
override val foo8: Int = 1
|
||||
}
|
||||
}
|
||||
+10
@@ -126,6 +126,16 @@ public class PullUpTestGenerated extends AbstractPullUpTest {
|
||||
runTest("idea/testData/refactoring/pullUp/k2k/fromClassToClassMakeAbstract.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("fromClassToClassMakeAbstractWithCommentAndAnotherIndent.kt")
|
||||
public void testFromClassToClassMakeAbstractWithCommentAndAnotherIndent() throws Exception {
|
||||
runTest("idea/testData/refactoring/pullUp/k2k/fromClassToClassMakeAbstractWithCommentAndAnotherIndent.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("fromClassToClassMakeAbstractWithCommentAndAnotherIndent2.kt")
|
||||
public void testFromClassToClassMakeAbstractWithCommentAndAnotherIndent2() throws Exception {
|
||||
runTest("idea/testData/refactoring/pullUp/k2k/fromClassToClassMakeAbstractWithCommentAndAnotherIndent2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("fromClassToClassWithGenerics.kt")
|
||||
public void testFromClassToClassWithGenerics() throws Exception {
|
||||
runTest("idea/testData/refactoring/pullUp/k2k/fromClassToClassWithGenerics.kt");
|
||||
|
||||
Reference in New Issue
Block a user