Formatter: fix line break before value parameter with annotation

#KT-23811 Fixed
This commit is contained in:
Dmitry Gridin
2019-12-10 16:43:40 +07:00
parent f05a452ef2
commit e7ff0315d4
3 changed files with 51 additions and 8 deletions
@@ -594,12 +594,7 @@ abstract class KotlinCommonBlock(
parentElementType === SECONDARY_CONSTRUCTOR
) {
val wrap = Wrap.createWrap(commonSettings.METHOD_PARAMETERS_WRAP, false)
return { childElement ->
if (childElement.elementType === VALUE_PARAMETER && !childElement.startsWithAnnotation())
wrap
else
null
}
return { childElement -> wrap.takeIf { childElement.elementType === VALUE_PARAMETER } }
}
}
@@ -701,8 +696,6 @@ abstract class KotlinCommonBlock(
}
}
private fun ASTNode.startsWithAnnotation() = firstChildNode?.firstChildNode?.elementType == ANNOTATION_ENTRY
private fun ASTNode.isFirstParameter(): Boolean = treePrev?.elementType == LPAR
private fun wrapAfterAnnotation(wrapType: Int): WrappingStrategy {
@@ -18,6 +18,16 @@ fun testtesttesttest(foofoo: Int,
foobar: Int,
barfoo: Int)
fun testtesttesttest(foofoo: Int,
@Some barbar: Int,
foobar: Int,
barfoo: Int)
fun testtesttesttest(@Some foofoo: Int,
@Some barbar: Int,
@Some foobar: Int,
barfoo: Int)
fun test() {
for (foo: Int in bar) {
@@ -130,3 +140,34 @@ class H(sn1: SN,
constructor(sn1: SN) {
}
}
class I(sn1: SN,
@field:Some val sn2: SN,
sn3: SN,
sn4: SN,
sn5: SN,
sn6: SN,
sn6: SN,
sn8: SN,
sn9: SN,
sn10: SN,
sn11: SN,
sn12: SN,
sn13: SN,
sn14: SN) {
constructor(sn1: SN,
sn2: SN,
sn3: SN,
@Some sn4: SN,
sn5: SN,
sn6: SN,
sn6: SN,
sn8: SN,
sn9: SN,
sn10: SN,
sn11: SN,
sn12: SN,
sn13: SN,
sn14: SN) {
}
}
@@ -14,6 +14,10 @@ fun test(foo: Int, bar: Int)
fun testtesttesttest(foofoo: Int, barbar: Int, foobar: Int, barfoo: Int)
fun testtesttesttest(foofoo: Int, @Some barbar: Int, foobar: Int, barfoo: Int)
fun testtesttesttest(@Some foofoo: Int, @Some barbar: Int, @Some foobar: Int, barfoo: Int)
fun test() {
for (foo: Int in bar) {
@@ -75,3 +79,8 @@ class H(sn1: SN, sn2 : SN) {
constructor(sn1: SN) {
}
}
class I(sn1: SN, @field:Some val sn2 : SN, sn3 : SN, sn4 : SN, sn5 : SN, sn6 : SN, sn6 : SN, sn8 : SN, sn9 : SN, sn10: SN, sn11: SN, sn12: SN, sn13: SN, sn14: SN) {
constructor(sn1: SN, sn2 : SN, sn3 : SN, @Some sn4 : SN, sn5 : SN, sn6 : SN, sn6 : SN, sn8 : SN, sn9 : SN, sn10: SN, sn11: SN, sn12: SN, sn13: SN, sn14: SN) {
}
}