KT-14391 RemoveUnnecessaryParenthesesIntention lost comment
on closing parenthesis ^KT-14391 Fixed
This commit is contained in:
committed by
Natalia Selezneva
parent
143c3ccb95
commit
534cbae4ef
+4
-1
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.idea.intentions
|
|||||||
|
|
||||||
import com.intellij.openapi.editor.Editor
|
import com.intellij.openapi.editor.Editor
|
||||||
import com.intellij.openapi.util.TextRange
|
import com.intellij.openapi.util.TextRange
|
||||||
|
import org.jetbrains.kotlin.idea.util.CommentSaver
|
||||||
import org.jetbrains.kotlin.psi.KtParenthesizedExpression
|
import org.jetbrains.kotlin.psi.KtParenthesizedExpression
|
||||||
import org.jetbrains.kotlin.psi.KtPsiUtil
|
import org.jetbrains.kotlin.psi.KtPsiUtil
|
||||||
|
|
||||||
@@ -29,6 +30,8 @@ class RemoveUnnecessaryParenthesesIntention : SelfTargetingRangeIntention<KtPare
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun applyTo(element: KtParenthesizedExpression, editor: Editor?) {
|
override fun applyTo(element: KtParenthesizedExpression, editor: Editor?) {
|
||||||
element.replace(element.expression!!)
|
val commentSaver = CommentSaver(element)
|
||||||
|
val replaced = element.replace(element.expression!!)
|
||||||
|
commentSaver.restore(replaced)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
fun foo(x: Int): Int {
|
||||||
|
return <caret>(/* aaa */ x /* bbb */)/* ccc */
|
||||||
|
}
|
||||||
Vendored
+3
@@ -0,0 +1,3 @@
|
|||||||
|
fun foo(x: Int): Int {
|
||||||
|
return /* aaa */ x /* bbb *//* ccc */
|
||||||
|
}
|
||||||
@@ -13075,6 +13075,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
|||||||
public void testUnnecessaryParentheses8() throws Exception {
|
public void testUnnecessaryParentheses8() throws Exception {
|
||||||
runTest("idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParentheses8.kt");
|
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")
|
@TestMetadata("idea/testData/intentions/replaceAddWithPlusAssign")
|
||||||
|
|||||||
Reference in New Issue
Block a user