diff --git a/plugins/kotlin/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinCommonBlock.kt b/plugins/kotlin/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinCommonBlock.kt index acc6a1a93a75..45beb3a019ef 100644 --- a/plugins/kotlin/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinCommonBlock.kt +++ b/plugins/kotlin/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinCommonBlock.kt @@ -792,7 +792,14 @@ private fun getWrappingStrategyForItemList(wrapType: Int, itemTypes: TokenSet, w val itemWrap = Wrap.createWrap(wrapType, wrapFirstElement) return object : WrappingStrategy { override fun getWrap(childElement: ASTNode): Wrap? { - return if (childElement.elementType in itemTypes) itemWrap else null + val thisType = childElement.elementType + val prevType = getPrevWithoutWhitespace(childElement)?.elementType + return if (thisType in itemTypes || prevType in itemTypes && + thisType != KtTokens.EOL_COMMENT && prevType != KtTokens.EOL_COMMENT + ) + itemWrap + else + null } } } diff --git a/plugins/kotlin/idea/tests/testData/copyPaste/conversion/FieldWithNoModifierAndNoSemicolon.expected.kt b/plugins/kotlin/idea/tests/testData/copyPaste/conversion/FieldWithNoModifierAndNoSemicolon.expected.kt index 690eea3078ef..21b1689d4ae6 100644 --- a/plugins/kotlin/idea/tests/testData/copyPaste/conversion/FieldWithNoModifierAndNoSemicolon.expected.kt +++ b/plugins/kotlin/idea/tests/testData/copyPaste/conversion/FieldWithNoModifierAndNoSemicolon.expected.kt @@ -1,3 +1,4 @@ package to -@Volatile internal var field = 1 \ No newline at end of file +@Volatile +internal var field = 1 \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/formatter/ClassAnnotationWrapping.after.kt b/plugins/kotlin/idea/tests/testData/formatter/ClassAnnotationWrapping.after.kt index ba65118a5e9e..58873837ac0d 100644 --- a/plugins/kotlin/idea/tests/testData/formatter/ClassAnnotationWrapping.after.kt +++ b/plugins/kotlin/idea/tests/testData/formatter/ClassAnnotationWrapping.after.kt @@ -1,4 +1,8 @@ @Deprecated("Foo") @Deprecated("Bar") class Foo { -} \ No newline at end of file +} + +@Deprecated("Foo") +public class Q { +} diff --git a/plugins/kotlin/idea/tests/testData/formatter/ClassAnnotationWrapping.kt b/plugins/kotlin/idea/tests/testData/formatter/ClassAnnotationWrapping.kt index 8946d6a86aa6..6b3ea41a6a00 100644 --- a/plugins/kotlin/idea/tests/testData/formatter/ClassAnnotationWrapping.kt +++ b/plugins/kotlin/idea/tests/testData/formatter/ClassAnnotationWrapping.kt @@ -1,2 +1,5 @@ @Deprecated("Foo") @Deprecated("Bar") class Foo { +} + +@Deprecated("Foo") public class Q { } \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/intentions/changeVisibility/private/onAnnotation.kt.after b/plugins/kotlin/idea/tests/testData/intentions/changeVisibility/private/onAnnotation.kt.after index c4bb083d66ff..9cb8abca7521 100644 --- a/plugins/kotlin/idea/tests/testData/intentions/changeVisibility/private/onAnnotation.kt.after +++ b/plugins/kotlin/idea/tests/testData/intentions/changeVisibility/private/onAnnotation.kt.after @@ -1,5 +1,6 @@ annotation class Small(val i: Int, val s: String) -@Small(1, "2") private fun test1() { +@Small(1, "2") +private fun test1() { } \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/intentions/changeVisibility/private/onAnnotationParameter.kt.after b/plugins/kotlin/idea/tests/testData/intentions/changeVisibility/private/onAnnotationParameter.kt.after index 034b6bf9d17b..9cb8abca7521 100644 --- a/plugins/kotlin/idea/tests/testData/intentions/changeVisibility/private/onAnnotationParameter.kt.after +++ b/plugins/kotlin/idea/tests/testData/intentions/changeVisibility/private/onAnnotationParameter.kt.after @@ -1,5 +1,6 @@ annotation class Small(val i: Int, val s: String) -@Small(1, "2") private fun test1() { +@Small(1, "2") +private fun test1() { } \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/addAnnotationTarget/basic1.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/addAnnotationTarget/basic1.kt.after index f75a533e4017..b06950eadae2 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/addAnnotationTarget/basic1.kt.after +++ b/plugins/kotlin/idea/tests/testData/quickfix/addAnnotationTarget/basic1.kt.after @@ -1,6 +1,7 @@ // "Add annotation target" "true" -@Target(AnnotationTarget.TYPE) annotation class Foo +@Target(AnnotationTarget.TYPE) +annotation class Foo class Test { fun foo(): @Foo Int = 1 diff --git a/plugins/kotlin/idea/tests/testData/quickfix/addAnnotationTarget/basic4.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/addAnnotationTarget/basic4.kt.after index fa19d1955f54..b2aa9fc111f0 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/addAnnotationTarget/basic4.kt.after +++ b/plugins/kotlin/idea/tests/testData/quickfix/addAnnotationTarget/basic4.kt.after @@ -1,6 +1,7 @@ // "Add annotation target" "true" -@Target(AnnotationTarget.TYPE, AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) annotation class Foo +@Target(AnnotationTarget.TYPE, AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +annotation class Foo @Foo class Test { diff --git a/plugins/kotlin/idea/tests/testData/quickfix/modifiers/openMemberInFinalClass4.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/modifiers/openMemberInFinalClass4.kt.after index a7bc02674766..4474a90dfa3d 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/modifiers/openMemberInFinalClass4.kt.after +++ b/plugins/kotlin/idea/tests/testData/quickfix/modifiers/openMemberInFinalClass4.kt.after @@ -1,4 +1,5 @@ // "Make 'A' open" "true" -@Deprecated("") open class A() { +@Deprecated("") +open class A() { open fun foo() {} } diff --git a/plugins/kotlin/idea/tests/testData/refactoring/extractSuperclass/reformatModifierList.kt.after b/plugins/kotlin/idea/tests/testData/refactoring/extractSuperclass/reformatModifierList.kt.after index 4a6b9c8efbc0..c3988bffd3cb 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/extractSuperclass/reformatModifierList.kt.after +++ b/plugins/kotlin/idea/tests/testData/refactoring/extractSuperclass/reformatModifierList.kt.after @@ -3,11 +3,13 @@ annotation class Concat abstract class A { // INFO: {"checked": "true", "toAbstract": "true"} - @Concat abstract var extraction: Int + @Concat + abstract var extraction: Int } // SIBLING: class Abstraction : A() { // INFO: {"checked": "true", "toAbstract": "true"} - @Concat override var extraction = 0 + @Concat + override var extraction = 0 } \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/refactoring/pullUp/k2k/reformatModifierList.kt.after b/plugins/kotlin/idea/tests/testData/refactoring/pullUp/k2k/reformatModifierList.kt.after index 8b7acea5b13e..5d145a4f2209 100644 --- a/plugins/kotlin/idea/tests/testData/refactoring/pullUp/k2k/reformatModifierList.kt.after +++ b/plugins/kotlin/idea/tests/testData/refactoring/pullUp/k2k/reformatModifierList.kt.after @@ -2,10 +2,12 @@ annotation class Concat abstract class A { // INFO: {"checked": "true", "toAbstract": "true"} - @Concat abstract var extraction: Int + @Concat + abstract var extraction: Int } class Abstraction : A() { // INFO: {"checked": "true", "toAbstract": "true"} - @Concat override var extraction = 0 + @Concat + override var extraction = 0 } \ No newline at end of file diff --git a/plugins/kotlin/j2k/old/tests/testData/fileOrElement/annotations/annotationUsages.kt b/plugins/kotlin/j2k/old/tests/testData/fileOrElement/annotations/annotationUsages.kt index 20fddfbf1cd6..cda834c6abb0 100644 --- a/plugins/kotlin/j2k/old/tests/testData/fileOrElement/annotations/annotationUsages.kt +++ b/plugins/kotlin/j2k/old/tests/testData/fileOrElement/annotations/annotationUsages.kt @@ -13,7 +13,8 @@ import javaApi.* @Anon8(classes = arrayOf(String::class, StringBuilder::class)) internal class C { @Anon5(1) - @Deprecated("") private val field1 = 0 + @Deprecated("") + private val field1 = 0 @Anon5(1) private val field2 = 0 diff --git a/plugins/kotlin/j2k/old/tests/testData/fileOrElement/annotations/modifiersToAnnotationsFromPropertyAccessors.kt b/plugins/kotlin/j2k/old/tests/testData/fileOrElement/annotations/modifiersToAnnotationsFromPropertyAccessors.kt index 7feea6f92022..536bfccfd279 100644 --- a/plugins/kotlin/j2k/old/tests/testData/fileOrElement/annotations/modifiersToAnnotationsFromPropertyAccessors.kt +++ b/plugins/kotlin/j2k/old/tests/testData/fileOrElement/annotations/modifiersToAnnotationsFromPropertyAccessors.kt @@ -7,6 +7,11 @@ class WithModifiersOnAccessors { @get:Strictfp var strict = 0.0 - @Synchronized private fun methSync() {} - @Strictfp protected fun methStrict() {} + @Synchronized + private fun methSync() { + } + + @Strictfp + protected fun methStrict() { + } } \ No newline at end of file