From 5564102a3e4c64213c2431776edeb783186f57a6 Mon Sep 17 00:00:00 2001 From: Toshiaki Kameyama Date: Fri, 11 May 2018 15:20:21 +0900 Subject: [PATCH] Add "Create secondary constructor" quick fix on NONE_APPLICABLE error #KT-22371 Fixed --- .../jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt | 1 + .../superCallNoneApplicable.kt | 8 ++++++++ .../superCallNoneApplicable.kt.after | 9 +++++++++ .../kotlin/idea/quickfix/QuickFixTestGenerated.java | 5 +++++ 4 files changed, 23 insertions(+) create mode 100644 idea/testData/quickfix/createFromUsage/createSecondaryConstructor/superCallNoneApplicable.kt create mode 100644 idea/testData/quickfix/createFromUsage/createSecondaryConstructor/superCallNoneApplicable.kt.after diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt index a723eded0d5..5632f1f3f60 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt @@ -340,6 +340,7 @@ class QuickFixRegistrar : QuickFixContributor { NO_VALUE_FOR_PARAMETER.registerFactory(CreateConstructorFromSuperTypeCallActionFactory) TOO_MANY_ARGUMENTS.registerFactory(CreateConstructorFromSuperTypeCallActionFactory) + NONE_APPLICABLE.registerFactory(CreateConstructorFromSuperTypeCallActionFactory) UNRESOLVED_REFERENCE_WRONG_RECEIVER.registerFactory(CreateClassFromConstructorCallActionFactory) UNRESOLVED_REFERENCE.registerFactory(CreateClassFromConstructorCallActionFactory) diff --git a/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/superCallNoneApplicable.kt b/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/superCallNoneApplicable.kt new file mode 100644 index 00000000000..3a7a660fa9a --- /dev/null +++ b/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/superCallNoneApplicable.kt @@ -0,0 +1,8 @@ +// "Create secondary constructor" "true" + +open class A { + constructor(x: Int, y: Int) + constructor(x: Int, y: String) +} + +class B : A(1) \ No newline at end of file diff --git a/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/superCallNoneApplicable.kt.after b/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/superCallNoneApplicable.kt.after new file mode 100644 index 00000000000..fa0017bb81e --- /dev/null +++ b/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/superCallNoneApplicable.kt.after @@ -0,0 +1,9 @@ +// "Create secondary constructor" "true" + +open class A { + constructor(x: Int, y: Int) + constructor(x: Int, y: String) + constructor(i: Int) +} + +class B : A(1) \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java index 55f5e66596d..95635f22616 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java @@ -3825,6 +3825,11 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest { runTest("idea/testData/quickfix/createFromUsage/createSecondaryConstructor/superCallNoClass.kt"); } + @TestMetadata("superCallNoneApplicable.kt") + public void testSuperCallNoneApplicable() throws Exception { + runTest("idea/testData/quickfix/createFromUsage/createSecondaryConstructor/superCallNoneApplicable.kt"); + } + @TestMetadata("thisCall.kt") public void testThisCall() throws Exception { runTest("idea/testData/quickfix/createFromUsage/createSecondaryConstructor/thisCall.kt");