From 534cbae4ef55856949f6f5023093fd80ff409a53 Mon Sep 17 00:00:00 2001 From: Toshiaki Kameyama Date: Mon, 7 May 2018 10:40:28 +0300 Subject: [PATCH] KT-14391 RemoveUnnecessaryParenthesesIntention lost comment on closing parenthesis ^KT-14391 Fixed --- .../intentions/RemoveUnnecessaryParenthesesIntention.kt | 5 ++++- .../unnecessaryParenthesesWithComment.kt | 3 +++ .../unnecessaryParenthesesWithComment.kt.after | 3 +++ .../kotlin/idea/intentions/IntentionTestGenerated.java | 6 ++++++ 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParenthesesWithComment.kt create mode 100644 idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParenthesesWithComment.kt.after diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveUnnecessaryParenthesesIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveUnnecessaryParenthesesIntention.kt index 74174219671..856c830727b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveUnnecessaryParenthesesIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveUnnecessaryParenthesesIntention.kt @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.idea.intentions import com.intellij.openapi.editor.Editor import com.intellij.openapi.util.TextRange +import org.jetbrains.kotlin.idea.util.CommentSaver import org.jetbrains.kotlin.psi.KtParenthesizedExpression import org.jetbrains.kotlin.psi.KtPsiUtil @@ -29,6 +30,8 @@ class RemoveUnnecessaryParenthesesIntention : SelfTargetingRangeIntention(/* aaa */ x /* bbb */)/* ccc */ +} \ No newline at end of file diff --git a/idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParenthesesWithComment.kt.after b/idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParenthesesWithComment.kt.after new file mode 100644 index 00000000000..17c81b12a7f --- /dev/null +++ b/idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParenthesesWithComment.kt.after @@ -0,0 +1,3 @@ +fun foo(x: Int): Int { + return /* aaa */ x /* bbb *//* ccc */ +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java index 99ea7d3bf10..5cf8dcfa73a 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java @@ -13075,6 +13075,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest { public void testUnnecessaryParentheses8() throws Exception { runTest("idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParentheses8.kt"); } + + @TestMetadata("unnecessaryParenthesesWithComment.kt") + public void testUnnecessaryParenthesesWithComment() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParenthesesWithComment.kt"); + doTest(fileName); + } } @TestMetadata("idea/testData/intentions/replaceAddWithPlusAssign")