From 7448042b68270bebd88c70a845bb23214e5c0cb5 Mon Sep 17 00:00:00 2001 From: Toshiaki Kameyama Date: Wed, 22 Nov 2017 14:56:44 +0300 Subject: [PATCH] Fix callable code factory (parameter with default value case) Before we can have end of '' and '=' joined as '>=' breaking PSI So #KT-15941 Fixed --- .../frontend/src/org/jetbrains/kotlin/psi/KtPsiFactory.kt | 2 +- .../genericParamWithDefaultValue.kt | 1 + .../genericParamWithDefaultValue.kt.after | 7 +++++++ .../kotlin/idea/intentions/IntentionTestGenerated.java | 6 ++++++ 4 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 idea/testData/intentions/convertPrimaryConstructorToSecondary/genericParamWithDefaultValue.kt create mode 100644 idea/testData/intentions/convertPrimaryConstructorToSecondary/genericParamWithDefaultValue.kt.after diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiFactory.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiFactory.kt index 41b2dd3fc35..f9b367957b2 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiFactory.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiFactory.kt @@ -691,7 +691,7 @@ class KtPsiFactory @JvmOverloads constructor(private val project: Project, val m } sb.append(name).append(": ").append(type) if (defaultValue != null) { - sb.append("= ").append(defaultValue) + sb.append(" = ").append(defaultValue) } if (state == State.FIRST_PARAM) { state = State.REST_PARAMS diff --git a/idea/testData/intentions/convertPrimaryConstructorToSecondary/genericParamWithDefaultValue.kt b/idea/testData/intentions/convertPrimaryConstructorToSecondary/genericParamWithDefaultValue.kt new file mode 100644 index 00000000000..14da1240d22 --- /dev/null +++ b/idea/testData/intentions/convertPrimaryConstructorToSecondary/genericParamWithDefaultValue.kt @@ -0,0 +1 @@ +class Test(val a: Array = arrayOf(0)) \ No newline at end of file diff --git a/idea/testData/intentions/convertPrimaryConstructorToSecondary/genericParamWithDefaultValue.kt.after b/idea/testData/intentions/convertPrimaryConstructorToSecondary/genericParamWithDefaultValue.kt.after new file mode 100644 index 00000000000..111864735d5 --- /dev/null +++ b/idea/testData/intentions/convertPrimaryConstructorToSecondary/genericParamWithDefaultValue.kt.after @@ -0,0 +1,7 @@ +class Test { + val a: Array + + constructor(a: Array = arrayOf(0)) { + this.a = a + } +} \ 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 79d86902462..0d01bd40e41 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java @@ -5624,6 +5624,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest { doTest(fileName); } + @TestMetadata("genericParamWithDefaultValue.kt") + public void testGenericParamWithDefaultValue() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/convertPrimaryConstructorToSecondary/genericParamWithDefaultValue.kt"); + doTest(fileName); + } + @TestMetadata("independentProperty.kt") public void testIndependentProperty() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/convertPrimaryConstructorToSecondary/independentProperty.kt");