Bad indentation after annotation in incomplete declaration (KT-22322)
Same behavior is for any modifier in incomplete declaration. #KT-22322 Fixed
This commit is contained in:
@@ -94,6 +94,16 @@ abstract class KotlinCommonBlock(
|
||||
|
||||
fun isLeaf(): Boolean = node.firstChildNode == null
|
||||
|
||||
fun isIncomplete(): Boolean {
|
||||
if (isIncompleteInSuper()) {
|
||||
return true
|
||||
}
|
||||
|
||||
// An incomplete declaration is the reason when modifier list can become a class body child, otherwise
|
||||
// it's going to be a declaration child.
|
||||
return node.elementType == MODIFIER_LIST && node.treeParent?.elementType == CLASS_BODY
|
||||
}
|
||||
|
||||
fun buildChildren(): List<Block> {
|
||||
if (mySubBlocks != null) {
|
||||
return mySubBlocks!!
|
||||
@@ -451,6 +461,11 @@ abstract class KotlinCommonBlock(
|
||||
return blockList.asSequence()
|
||||
}
|
||||
|
||||
if (this.node.elementType == CLASS_BODY && node.elementType == MODIFIER_LIST) {
|
||||
// Some unfinished declaration
|
||||
println()
|
||||
}
|
||||
|
||||
return sequenceOf(buildSubBlock(node, childrenAlignmentStrategy, wrappingStrategy))
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ class KotlinBlock(
|
||||
|
||||
override fun getAlignment(): Alignment? = alignment
|
||||
|
||||
override fun isIncompleteInSuper(): Boolean = this@KotlinBlock.isIncomplete
|
||||
override fun isIncompleteInSuper(): Boolean = super@KotlinBlock.isIncomplete()
|
||||
|
||||
override fun getSuperChildAttributes(newChildIndex: Int): ChildAttributes = super@KotlinBlock.getChildAttributes(newChildIndex)
|
||||
|
||||
@@ -96,6 +96,8 @@ class KotlinBlock(
|
||||
override fun isLeaf(): Boolean = kotlinDelegationBlock.isLeaf()
|
||||
|
||||
override fun getTextRange() = kotlinDelegationBlock.getTextRange()
|
||||
|
||||
override fun isIncomplete(): Boolean = kotlinDelegationBlock.isIncomplete()
|
||||
}
|
||||
|
||||
object KotlinSpacingBuilderUtilImpl : KotlinSpacingBuilderUtil {
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
class Foo {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
<caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class Foo {
|
||||
companion object {
|
||||
@JvmStatic<caret>
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
object A {
|
||||
private
|
||||
<caret>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
object A {
|
||||
private<caret>
|
||||
}
|
||||
+17
@@ -61,6 +61,11 @@ public class TypingIndentationTestBaseGenerated extends AbstractTypingIndentatio
|
||||
runTest("idea/testData/indentationOnNewline/Annotation.after.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("AnnotationInDeclaration.after.kt")
|
||||
public void testAnnotationInDeclaration() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/AnnotationInDeclaration.after.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ArgumentListNormalIndent.after.kt")
|
||||
public void testArgumentListNormalIndent() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/ArgumentListNormalIndent.after.kt");
|
||||
@@ -231,6 +236,18 @@ public class TypingIndentationTestBaseGenerated extends AbstractTypingIndentatio
|
||||
runTest("idea/testData/indentationOnNewline/KT20783.after.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("LambdaInCallWithAllightMultilineParameters.after.kt")
|
||||
public void testLambdaInCallWithAllightMultilineParameters() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/indentationOnNewline/LambdaInCallWithAllightMultilineParameters.after.kt");
|
||||
doNewlineTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ModifierListInUnfinishedDeclaration.after.kt")
|
||||
public void testModifierListInUnfinishedDeclaration() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/indentationOnNewline/ModifierListInUnfinishedDeclaration.after.kt");
|
||||
doNewlineTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("MultideclarationAfterEq.after.kt")
|
||||
public void testMultideclarationAfterEq() throws Exception {
|
||||
runTest("idea/testData/indentationOnNewline/MultideclarationAfterEq.after.kt");
|
||||
|
||||
Reference in New Issue
Block a user