From d1958be2a8b0543e52b3a704d9a9f2f795d2b2bd Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Fri, 30 Sep 2016 11:23:46 +0300 Subject: [PATCH] KT-9839 related, secondary constructor to primary: comment restoration (cherry picked from commit 998e39e) --- ...ConvertSecondaryConstructorToPrimaryIntention.kt | 12 ++++++++++-- .../withComments.kt | 13 +++++++++++++ .../withComments.kt.after | 10 ++++++++++ .../idea/intentions/IntentionTestGenerated.java | 6 ++++++ 4 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 idea/testData/intentions/convertSecondaryConstructorToPrimary/withComments.kt create mode 100644 idea/testData/intentions/convertSecondaryConstructorToPrimary/withComments.kt.after diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertSecondaryConstructorToPrimaryIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertSecondaryConstructorToPrimaryIntention.kt index 2c4a228abda..b98772b1c47 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertSecondaryConstructorToPrimaryIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertSecondaryConstructorToPrimaryIntention.kt @@ -20,6 +20,7 @@ import com.intellij.openapi.editor.Editor import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.idea.caches.resolve.analyzeFully +import org.jetbrains.kotlin.idea.util.CommentSaver import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject @@ -83,6 +84,7 @@ class ConvertSecondaryConstructorToPrimaryIntention : SelfTargetingIntention(/* Some parameter */veryImportant: Any) { + this.veryImportant = veryImportant + } +} \ No newline at end of file diff --git a/idea/testData/intentions/convertSecondaryConstructorToPrimary/withComments.kt.after b/idea/testData/intentions/convertSecondaryConstructorToPrimary/withComments.kt.after new file mode 100644 index 00000000000..dcc3cce5813 --- /dev/null +++ b/idea/testData/intentions/convertSecondaryConstructorToPrimary/withComments.kt.after @@ -0,0 +1,10 @@ +class WithComments/* Some parameter */ +/** + * A constructor + */( + /** + * A very important property + */ + val veryImportant: Any) { + +} \ 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 b95aad17552..5392bdae553 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java @@ -4774,6 +4774,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest { doTest(fileName); } + @TestMetadata("withComments.kt") + public void testWithComments() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/convertSecondaryConstructorToPrimary/withComments.kt"); + doTest(fileName); + } + @TestMetadata("withDelegation.kt") public void testWithDelegation() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/convertSecondaryConstructorToPrimary/withDelegation.kt");