From 30366148bf82cf5a760f3fdc1856d88688c7a032 Mon Sep 17 00:00:00 2001 From: Toshiaki Kameyama Date: Wed, 15 Jan 2020 12:19:00 +0900 Subject: [PATCH] Convert to block body: adjust line indent #KT-22368 Fixed --- .../kotlin/idea/intentions/ConvertToBlockBodyIntention.kt | 6 +++++- .../intentions/convertToBlockBody/adjustLineIndent.kt | 2 ++ .../intentions/convertToBlockBody/adjustLineIndent.kt.after | 4 ++++ .../kotlin/idea/intentions/IntentionTestGenerated.java | 5 +++++ 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 idea/testData/intentions/convertToBlockBody/adjustLineIndent.kt create mode 100644 idea/testData/intentions/convertToBlockBody/adjustLineIndent.kt.after diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToBlockBodyIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToBlockBodyIntention.kt index e192cae1d72..3d6d5f37a5c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToBlockBodyIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToBlockBodyIntention.kt @@ -23,7 +23,10 @@ import org.jetbrains.kotlin.idea.KotlinBundle import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny import org.jetbrains.kotlin.idea.core.setType +import org.jetbrains.kotlin.idea.formatter.adjustLineIndent import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.psiUtil.endOffset +import org.jetbrains.kotlin.psi.psiUtil.startOffset import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.isError import org.jetbrains.kotlin.types.typeUtil.isNothing @@ -93,7 +96,8 @@ class ConvertToBlockBodyIntention : SelfTargetingIntentionx + y \ No newline at end of file diff --git a/idea/testData/intentions/convertToBlockBody/adjustLineIndent.kt.after b/idea/testData/intentions/convertToBlockBody/adjustLineIndent.kt.after new file mode 100644 index 00000000000..b16372e4d8f --- /dev/null +++ b/idea/testData/intentions/convertToBlockBody/adjustLineIndent.kt.after @@ -0,0 +1,4 @@ +fun foo(x: Int, + y: Int): Int { + return x + y +} \ 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 dde93b0ec42..3106b2f6685 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java @@ -6595,6 +6595,11 @@ public class IntentionTestGenerated extends AbstractIntentionTest { runTest("idea/testData/intentions/convertToBlockBody/addSpace.kt"); } + @TestMetadata("adjustLineIndent.kt") + public void testAdjustLineIndent() throws Exception { + runTest("idea/testData/intentions/convertToBlockBody/adjustLineIndent.kt"); + } + public void testAllFilesPresentInConvertToBlockBody() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/intentions/convertToBlockBody"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), null, true); }