From af63fcb3bee3f8d3056aae3d7e3e8b7d4aaaeb87 Mon Sep 17 00:00:00 2001 From: Nicolay Mitropolsky Date: Tue, 19 Mar 2019 15:36:32 +0300 Subject: [PATCH] KotlinElementActionsFactory: adding empty annotations without parenthesises --- .../quickfix/crossLanguage/KotlinElementActionsFactory.kt | 4 ++-- .../kotlin/idea/quickfix/CommonIntentionActionsTest.kt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/crossLanguage/KotlinElementActionsFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/crossLanguage/KotlinElementActionsFactory.kt index dbf09308628..cc829854788 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/crossLanguage/KotlinElementActionsFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/crossLanguage/KotlinElementActionsFactory.kt @@ -479,12 +479,12 @@ internal fun addAnnotationEntry( KtPsiFactory(target) .createAnnotationEntry( "@$annotationUseSiteTargetPrefix${request.qualifiedName}${ - request.attributes.mapIndexed { i, p -> + request.attributes.takeIf { it.isNotEmpty() }?.mapIndexed { i, p -> if (!kotlinAnnotation && i == 0 && p.name == "value") renderAttributeValue(p.value).toString() else "${p.name} = ${renderAttributeValue(p.value)}" - }.joinToString(", ", "(", ")") + }?.joinToString(", ", "(", ")") ?: "" }" ) ) diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/CommonIntentionActionsTest.kt b/idea/tests/org/jetbrains/kotlin/idea/quickfix/CommonIntentionActionsTest.kt index 0f1c907871f..4d16b012287 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/CommonIntentionActionsTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/CommonIntentionActionsTest.kt @@ -272,7 +272,7 @@ class CommonIntentionActionsTest : LightPlatformCodeInsightFixtureTestCase() { import pkg.myannotation.JavaAnnotation class Foo { - @field:JavaAnnotation() + @field:JavaAnnotation val bar: String = null } """.trimIndent(), true @@ -324,7 +324,7 @@ class CommonIntentionActionsTest : LightPlatformCodeInsightFixtureTestCase() { import pkg.myannotation.JavaAnnotation class Foo { - @JavaAnnotation() + @JavaAnnotation val bar: String = null } """.trimIndent(), true