From d735637f1ea587673af3e3da2f126ab2e7ea4efd Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Sat, 24 Oct 2020 00:19:21 +0900 Subject: [PATCH] Revert "RemoveBracesIntention: add new line for long expression" This reverts commit f4b9c477 --- .../kotlin/idea/intentions/RemoveBracesIntention.kt | 7 ------- idea/testData/intentions/removeBraces/ifLong.kt | 8 -------- idea/testData/intentions/removeBraces/ifLong.kt.after | 7 ------- idea/testData/intentions/removeBraces/whenLong.kt | 10 ---------- .../testData/intentions/removeBraces/whenLong.kt.after | 9 --------- .../kotlin/idea/intentions/IntentionTestGenerated.java | 10 ---------- 6 files changed, 51 deletions(-) delete mode 100644 idea/testData/intentions/removeBraces/ifLong.kt delete mode 100644 idea/testData/intentions/removeBraces/ifLong.kt.after delete mode 100644 idea/testData/intentions/removeBraces/whenLong.kt delete mode 100644 idea/testData/intentions/removeBraces/whenLong.kt.after diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveBracesIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveBracesIntention.kt index 6052564469e..35024fde68b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveBracesIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveBracesIntention.kt @@ -62,13 +62,6 @@ class RemoveBracesIntention : SelfTargetingIntention(KtElement::class if (construct is KtDoWhileExpression) { newElement.parent!!.addAfter(factory.createNewLine(), newElement) - } else if (editor != null) { - val document = editor.document - val line = document.getLineNumber(newElement.startOffset) - val rightMargin = editor.settings.getRightMargin(editor.project) - if (document.getLineEndOffset(line) - document.getLineStartOffset(line) >= rightMargin) { - newElement.parent.addBefore(factory.createNewLine(), newElement) - } } if (construct is KtIfExpression && diff --git a/idea/testData/intentions/removeBraces/ifLong.kt b/idea/testData/intentions/removeBraces/ifLong.kt deleted file mode 100644 index 6b4a6e94cef..00000000000 --- a/idea/testData/intentions/removeBraces/ifLong.kt +++ /dev/null @@ -1,8 +0,0 @@ -fun foo( - aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: Boolean -): Int { - if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) { - return 1 - } - return 2 -} \ No newline at end of file diff --git a/idea/testData/intentions/removeBraces/ifLong.kt.after b/idea/testData/intentions/removeBraces/ifLong.kt.after deleted file mode 100644 index 1be6a289d81..00000000000 --- a/idea/testData/intentions/removeBraces/ifLong.kt.after +++ /dev/null @@ -1,7 +0,0 @@ -fun foo( - aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: Boolean -): Int { - if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) - return 1 - return 2 -} \ No newline at end of file diff --git a/idea/testData/intentions/removeBraces/whenLong.kt b/idea/testData/intentions/removeBraces/whenLong.kt deleted file mode 100644 index cccadaf2ae6..00000000000 --- a/idea/testData/intentions/removeBraces/whenLong.kt +++ /dev/null @@ -1,10 +0,0 @@ -fun foo( - aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: Boolean -): Int { - when { - aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -> { - return 1 - } - else -> return 2 - } -} \ No newline at end of file diff --git a/idea/testData/intentions/removeBraces/whenLong.kt.after b/idea/testData/intentions/removeBraces/whenLong.kt.after deleted file mode 100644 index 1c766484983..00000000000 --- a/idea/testData/intentions/removeBraces/whenLong.kt.after +++ /dev/null @@ -1,9 +0,0 @@ -fun foo( - aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: Boolean -): Int { - when { - aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -> - return 1 - else -> return 2 - } -} \ 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 36fc2095db6..8b6bd38507d 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java @@ -13781,11 +13781,6 @@ public class IntentionTestGenerated extends AbstractIntentionTest { runTest("idea/testData/intentions/removeBraces/ifLambda2.kt"); } - @TestMetadata("ifLong.kt") - public void testIfLong() throws Exception { - runTest("idea/testData/intentions/removeBraces/ifLong.kt"); - } - @TestMetadata("ifWithComment.kt") public void testIfWithComment() throws Exception { runTest("idea/testData/intentions/removeBraces/ifWithComment.kt"); @@ -13831,11 +13826,6 @@ public class IntentionTestGenerated extends AbstractIntentionTest { runTest("idea/testData/intentions/removeBraces/whenLambda3.kt"); } - @TestMetadata("whenLong.kt") - public void testWhenLong() throws Exception { - runTest("idea/testData/intentions/removeBraces/whenLong.kt"); - } - @TestMetadata("whenMultiple.kt") public void testWhenMultiple() throws Exception { runTest("idea/testData/intentions/removeBraces/whenMultiple.kt");