From 9c0bcee9a3523ad582a2f881e004e42f09b9ae66 Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Wed, 25 Mar 2015 13:16:56 +0300 Subject: [PATCH] Create from Usage: Generate secondary constructors by call expressions --- .../idea/quickfix/QuickFixRegistrar.java | 10 ++--- ...=> CreateCallableFromCallActionFactory.kt} | 34 ++++++++++++---- .../callExpression/beforeCallWithExtraArgs.kt | 1 + .../beforeCallWithMissingArgs.kt | 1 + .../afterCallWithExpectedType.kt | 13 ++++++ .../afterClassWithBody.kt | 12 ++++++ .../afterClassWithoutBody.kt | 11 +++++ .../beforeCallWithExpectedType.kt | 9 +++++ .../beforeCallWithTypeArguments.kt | 12 ++++++ .../beforeClassWithBody.kt | 9 +++++ .../beforeClassWithoutBody.kt | 7 ++++ .../beforeWrongExpectedType.kt | 15 +++++++ .../groovyConstructor.before.Main.kt | 7 ++++ ...roovyConstructor.before.data.Sample.groovy | 3 ++ .../javaConstructor.after.data.Sample.java | 6 +++ .../javaConstructor.after.kt | 4 ++ .../javaConstructor.before.Main.kt | 4 ++ .../javaConstructor.before.data.Sample.java | 3 ++ .../QuickFixMultiFileTestGenerated.java | 22 ++++++++++ .../idea/quickfix/QuickFixTestGenerated.java | 40 +++++++++++++++++++ 20 files changed, 210 insertions(+), 13 deletions(-) rename idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/{CreateFunctionOrPropertyFromCallActionFactory.kt => CreateCallableFromCallActionFactory.kt} (77%) create mode 100644 idea/testData/quickfix/createFromUsage/createSecondaryConstructor/afterCallWithExpectedType.kt create mode 100644 idea/testData/quickfix/createFromUsage/createSecondaryConstructor/afterClassWithBody.kt create mode 100644 idea/testData/quickfix/createFromUsage/createSecondaryConstructor/afterClassWithoutBody.kt create mode 100644 idea/testData/quickfix/createFromUsage/createSecondaryConstructor/beforeCallWithExpectedType.kt create mode 100644 idea/testData/quickfix/createFromUsage/createSecondaryConstructor/beforeCallWithTypeArguments.kt create mode 100644 idea/testData/quickfix/createFromUsage/createSecondaryConstructor/beforeClassWithBody.kt create mode 100644 idea/testData/quickfix/createFromUsage/createSecondaryConstructor/beforeClassWithoutBody.kt create mode 100644 idea/testData/quickfix/createFromUsage/createSecondaryConstructor/beforeWrongExpectedType.kt create mode 100644 idea/testData/quickfix/createFromUsage/createSecondaryConstructor/groovyConstructor.before.Main.kt create mode 100644 idea/testData/quickfix/createFromUsage/createSecondaryConstructor/groovyConstructor.before.data.Sample.groovy create mode 100644 idea/testData/quickfix/createFromUsage/createSecondaryConstructor/javaConstructor.after.data.Sample.java create mode 100644 idea/testData/quickfix/createFromUsage/createSecondaryConstructor/javaConstructor.after.kt create mode 100644 idea/testData/quickfix/createFromUsage/createSecondaryConstructor/javaConstructor.before.Main.kt create mode 100644 idea/testData/quickfix/createFromUsage/createSecondaryConstructor/javaConstructor.before.data.Sample.java diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.java b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.java index 7a9a5862958..26bc5c5bcff 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.java +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.java @@ -252,11 +252,11 @@ public class QuickFixRegistrar { QuickFixes.factories.put(NO_VALUE_FOR_PARAMETER, CreateBinaryOperationActionFactory.INSTANCE$); QuickFixes.factories.put(TOO_MANY_ARGUMENTS, CreateBinaryOperationActionFactory.INSTANCE$); - QuickFixes.factories.put(UNRESOLVED_REFERENCE_WRONG_RECEIVER, CreateFunctionOrPropertyFromCallActionFactory.INSTANCE$); - QuickFixes.factories.put(UNRESOLVED_REFERENCE, CreateFunctionOrPropertyFromCallActionFactory.INSTANCE$); - QuickFixes.factories.put(NO_VALUE_FOR_PARAMETER, CreateFunctionOrPropertyFromCallActionFactory.INSTANCE$); - QuickFixes.factories.put(TOO_MANY_ARGUMENTS, CreateFunctionOrPropertyFromCallActionFactory.INSTANCE$); - QuickFixes.factories.put(EXPRESSION_EXPECTED_PACKAGE_FOUND, CreateFunctionOrPropertyFromCallActionFactory.INSTANCE$); + QuickFixes.factories.put(UNRESOLVED_REFERENCE_WRONG_RECEIVER, CreateCallableFromCallActionFactory.INSTANCE$); + QuickFixes.factories.put(UNRESOLVED_REFERENCE, CreateCallableFromCallActionFactory.INSTANCE$); + QuickFixes.factories.put(NO_VALUE_FOR_PARAMETER, CreateCallableFromCallActionFactory.INSTANCE$); + QuickFixes.factories.put(TOO_MANY_ARGUMENTS, CreateCallableFromCallActionFactory.INSTANCE$); + QuickFixes.factories.put(EXPRESSION_EXPECTED_PACKAGE_FOUND, CreateCallableFromCallActionFactory.INSTANCE$); QuickFixes.factories.put(UNRESOLVED_REFERENCE_WRONG_RECEIVER, CreateClassFromConstructorCallActionFactory.INSTANCE$); QuickFixes.factories.put(UNRESOLVED_REFERENCE, CreateClassFromConstructorCallActionFactory.INSTANCE$); diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateFunctionOrPropertyFromCallActionFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateCallableFromCallActionFactory.kt similarity index 77% rename from idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateFunctionOrPropertyFromCallActionFactory.kt rename to idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateCallableFromCallActionFactory.kt index 8dfe8a8f37b..6b64b456205 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateFunctionOrPropertyFromCallActionFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateCallableFromCallActionFactory.kt @@ -37,10 +37,17 @@ import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde import com.intellij.psi.PsiClass import com.intellij.openapi.project.Project +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.descriptors.ConstructorDescriptor +import org.jetbrains.kotlin.idea.caches.resolve.analyzeAndGetResult import org.jetbrains.kotlin.idea.refactoring.* import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall +import org.jetbrains.kotlin.types.TypeUtils +import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf +import java.util.ArrayList -object CreateFunctionOrPropertyFromCallActionFactory : JetIntentionActionsFactory() { +object CreateCallableFromCallActionFactory : JetIntentionActionsFactory() { override fun doCreateActions(diagnostic: Diagnostic): List? { val diagElement = diagnostic.getPsiElement() if (PsiTreeUtil.getParentOfType( @@ -87,9 +94,12 @@ object CreateFunctionOrPropertyFromCallActionFactory : JetIntentionActionsFactor } else Collections.emptyList() - val callableInfo = when (callExpr) { + val name = calleeExpr.getReferencedName() + val anyType = KotlinBuiltIns.getInstance().getNullableAnyType() + + val callableInfos = ArrayList(2) + when (callExpr) { is JetCallExpression -> { - val anyType = KotlinBuiltIns.getInstance().getNullableAnyType() val parameters = callExpr.getValueArguments().map { ParameterInfo( it.getArgumentExpression()?.let { TypeInfo(it, Variance.IN_VARIANCE) } ?: TypeInfo(anyType, Variance.IN_VARIANCE), @@ -98,7 +108,17 @@ object CreateFunctionOrPropertyFromCallActionFactory : JetIntentionActionsFactor } val typeParameters = callExpr.getTypeInfoForTypeArguments() val returnType = TypeInfo(fullCallExpr, Variance.OUT_VARIANCE) - FunctionInfo(calleeExpr.getReferencedName(), receiverType, returnType, possibleContainers, parameters, typeParameters) + callableInfos.add(FunctionInfo(name, receiverType, returnType, possibleContainers, parameters, typeParameters)) + + val expectedType = context[BindingContext.EXPECTED_EXPRESSION_TYPE, fullCallExpr] ?: anyType + val constructorDescriptor = callExpr.getResolvedCall(context)?.getResultingDescriptor() as? ConstructorDescriptor + val classDescriptor = constructorDescriptor?.getContainingDeclaration() as? ClassDescriptor + val klass = classDescriptor?.let { DescriptorToSourceUtilsIde.getAnyDeclaration(project, it) } + if ((klass is JetClass || klass is PsiClass) && klass.canRefactor() + && typeParameters.isEmpty() + && classDescriptor!!.getDefaultType().isSubtypeOf(expectedType)) { + callableInfos.add(SecondaryConstructorInfo(parameters, klass)) + } } is JetSimpleNameExpression -> { @@ -107,13 +127,11 @@ object CreateFunctionOrPropertyFromCallActionFactory : JetIntentionActionsFactor fullCallExpr.getExpressionForTypeGuess(), if (varExpected) Variance.INVARIANT else Variance.OUT_VARIANCE ) - PropertyInfo(calleeExpr.getReferencedName(), receiverType, returnType, varExpected, possibleContainers) + callableInfos.add(PropertyInfo(name, receiverType, returnType, varExpected, possibleContainers)) } - - else -> return null } - return CreateCallableFromUsageFixes(callExpr, callableInfo) + return callableInfos.flatMap{ CreateCallableFromUsageFixes(callExpr, it) } } private fun getReceiverTypeInfo(context: BindingContext, project: Project, receiver: ReceiverValue): TypeInfo? { diff --git a/idea/testData/quickfix/createFromUsage/createClass/callExpression/beforeCallWithExtraArgs.kt b/idea/testData/quickfix/createFromUsage/createClass/callExpression/beforeCallWithExtraArgs.kt index 0df97111c85..79138bb4799 100644 --- a/idea/testData/quickfix/createFromUsage/createClass/callExpression/beforeCallWithExtraArgs.kt +++ b/idea/testData/quickfix/createFromUsage/createClass/callExpression/beforeCallWithExtraArgs.kt @@ -2,6 +2,7 @@ // ACTION: Create function 'Foo' // ACTION: Add parameter to constructor 'Foo' // ACTION: Split property declaration +// ACTION: Create secondary constructor // ERROR: Too many arguments for public constructor Foo(a: kotlin.Int) defined in Foo class Foo(a: Int) diff --git a/idea/testData/quickfix/createFromUsage/createClass/callExpression/beforeCallWithMissingArgs.kt b/idea/testData/quickfix/createFromUsage/createClass/callExpression/beforeCallWithMissingArgs.kt index b7531fc132b..91a5a43bc6e 100644 --- a/idea/testData/quickfix/createFromUsage/createClass/callExpression/beforeCallWithMissingArgs.kt +++ b/idea/testData/quickfix/createFromUsage/createClass/callExpression/beforeCallWithMissingArgs.kt @@ -2,6 +2,7 @@ // ACTION: Create function 'Foo' // ACTION: Remove parameter 's' // ACTION: Split property declaration +// ACTION: Create secondary constructor // ERROR: No value passed for parameter s class Foo(i: Int, s: String) diff --git a/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/afterCallWithExpectedType.kt b/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/afterCallWithExpectedType.kt new file mode 100644 index 00000000000..f1429ffb3e2 --- /dev/null +++ b/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/afterCallWithExpectedType.kt @@ -0,0 +1,13 @@ +// "Create secondary constructor" "true" + +trait T + +class A: T { + constructor(i: Int) { + //To change body of created constructors use File | Settings | File Templates. + } +} + +fun test() { + val t: T = A(1) +} \ No newline at end of file diff --git a/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/afterClassWithBody.kt b/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/afterClassWithBody.kt new file mode 100644 index 00000000000..13c3e1f70ff --- /dev/null +++ b/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/afterClassWithBody.kt @@ -0,0 +1,12 @@ +// "Create secondary constructor" "true" + +class A { + constructor(i: Int) { + //To change body of created constructors use File | Settings | File Templates. + } + +} + +fun test() { + val a = A(1) +} \ No newline at end of file diff --git a/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/afterClassWithoutBody.kt b/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/afterClassWithoutBody.kt new file mode 100644 index 00000000000..0391e59f299 --- /dev/null +++ b/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/afterClassWithoutBody.kt @@ -0,0 +1,11 @@ +// "Create secondary constructor" "true" + +class A { + constructor(i: Int) { + //To change body of created constructors use File | Settings | File Templates. + } +} + +fun test() { + val a = A(1) +} \ No newline at end of file diff --git a/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/beforeCallWithExpectedType.kt b/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/beforeCallWithExpectedType.kt new file mode 100644 index 00000000000..5bab8f1fcd5 --- /dev/null +++ b/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/beforeCallWithExpectedType.kt @@ -0,0 +1,9 @@ +// "Create secondary constructor" "true" + +trait T + +class A: T + +fun test() { + val t: T = A(1) +} \ No newline at end of file diff --git a/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/beforeCallWithTypeArguments.kt b/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/beforeCallWithTypeArguments.kt new file mode 100644 index 00000000000..799d6d80b56 --- /dev/null +++ b/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/beforeCallWithTypeArguments.kt @@ -0,0 +1,12 @@ +// "Create secondary constructor" "false" +// ACTION: Add parameter to constructor 'A' +// ACTION: Create function 'A' +// ACTION: Split property declaration +// ERROR: No type arguments expected +// ERROR: Too many arguments for public constructor A() defined in A + +class A + +fun test() { + val a = A(1) +} \ No newline at end of file diff --git a/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/beforeClassWithBody.kt b/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/beforeClassWithBody.kt new file mode 100644 index 00000000000..18896f553ce --- /dev/null +++ b/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/beforeClassWithBody.kt @@ -0,0 +1,9 @@ +// "Create secondary constructor" "true" + +class A { + +} + +fun test() { + val a = A(1) +} \ No newline at end of file diff --git a/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/beforeClassWithoutBody.kt b/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/beforeClassWithoutBody.kt new file mode 100644 index 00000000000..dc8bd5ffe69 --- /dev/null +++ b/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/beforeClassWithoutBody.kt @@ -0,0 +1,7 @@ +// "Create secondary constructor" "true" + +class A + +fun test() { + val a = A(1) +} \ No newline at end of file diff --git a/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/beforeWrongExpectedType.kt b/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/beforeWrongExpectedType.kt new file mode 100644 index 00000000000..55cfad0dfff --- /dev/null +++ b/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/beforeWrongExpectedType.kt @@ -0,0 +1,15 @@ +// "Create secondary constructor" "false" +// ACTION: Add parameter to constructor 'A' +// ACTION: Change 'b' type to 'A' +// ACTION: Create function 'A' +// ACTION: Split property declaration +// ERROR: Type mismatch.
Required:B
Found:A
+// ERROR: Too many arguments for public constructor A() defined in A + +class A + +class B + +fun test() { + val b: B = A(1) +} \ No newline at end of file diff --git a/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/groovyConstructor.before.Main.kt b/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/groovyConstructor.before.Main.kt new file mode 100644 index 00000000000..1b5ed9017fe --- /dev/null +++ b/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/groovyConstructor.before.Main.kt @@ -0,0 +1,7 @@ +// "Create secondary constructor" "false" +// ERROR: Too many arguments for public constructor G() defined in G +// ACTION: Add parameter to constructor 'G' +// ACTION: Convert to block body +// ACTION: Create function 'G' + +fun test() = G(1) \ No newline at end of file diff --git a/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/groovyConstructor.before.data.Sample.groovy b/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/groovyConstructor.before.data.Sample.groovy new file mode 100644 index 00000000000..459c46519ee --- /dev/null +++ b/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/groovyConstructor.before.data.Sample.groovy @@ -0,0 +1,3 @@ +class G { + +} \ No newline at end of file diff --git a/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/javaConstructor.after.data.Sample.java b/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/javaConstructor.after.data.Sample.java new file mode 100644 index 00000000000..34daf278dc2 --- /dev/null +++ b/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/javaConstructor.after.data.Sample.java @@ -0,0 +1,6 @@ +class J { + + public J(int i) { + + } +} \ No newline at end of file diff --git a/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/javaConstructor.after.kt b/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/javaConstructor.after.kt new file mode 100644 index 00000000000..5d70f9f80c1 --- /dev/null +++ b/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/javaConstructor.after.kt @@ -0,0 +1,4 @@ +// "Create secondary constructor" "true" +// ERROR: Too many arguments for public/*package*/ constructor J() defined in J + +fun test() = J(1) \ No newline at end of file diff --git a/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/javaConstructor.before.Main.kt b/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/javaConstructor.before.Main.kt new file mode 100644 index 00000000000..33cbd48a75d --- /dev/null +++ b/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/javaConstructor.before.Main.kt @@ -0,0 +1,4 @@ +// "Create secondary constructor" "true" +// ERROR: Too many arguments for public/*package*/ constructor J() defined in J + +fun test() = J(1) \ No newline at end of file diff --git a/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/javaConstructor.before.data.Sample.java b/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/javaConstructor.before.data.Sample.java new file mode 100644 index 00000000000..cfa2a621482 --- /dev/null +++ b/idea/testData/quickfix/createFromUsage/createSecondaryConstructor/javaConstructor.before.data.Sample.java @@ -0,0 +1,3 @@ +class J { + +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java index 5a3ea0ccf25..b10de5b0f79 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java @@ -289,6 +289,7 @@ public class QuickFixMultiFileTestGenerated extends AbstractQuickFixMultiFileTes @InnerTestClasses({ CreateFromUsage.CreateClass.class, CreateFromUsage.CreateFunction.class, + CreateFromUsage.CreateSecondaryConstructor.class, CreateFromUsage.CreateVariable.class, }) @RunWith(JUnit3RunnerWithInners.class) @@ -756,6 +757,27 @@ public class QuickFixMultiFileTestGenerated extends AbstractQuickFixMultiFileTes } + @TestMetadata("idea/testData/quickfix/createFromUsage/createSecondaryConstructor") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class CreateSecondaryConstructor extends AbstractQuickFixMultiFileTest { + public void testAllFilesPresentInCreateSecondaryConstructor() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/createFromUsage/createSecondaryConstructor"), Pattern.compile("^(\\w+)\\.before\\.Main\\.kt$"), true); + } + + @TestMetadata("groovyConstructor.before.Main.kt") + public void testGroovyConstructor() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/createFromUsage/createSecondaryConstructor/groovyConstructor.before.Main.kt"); + doTestWithExtraFile(fileName); + } + + @TestMetadata("javaConstructor.before.Main.kt") + public void testJavaConstructor() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/createFromUsage/createSecondaryConstructor/javaConstructor.before.Main.kt"); + doTestWithExtraFile(fileName); + } + } + @TestMetadata("idea/testData/quickfix/createFromUsage/createVariable") @TestDataPath("$PROJECT_ROOT") @InnerTestClasses({ diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java index 0df0f048386..abd05090685 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java @@ -698,6 +698,7 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest { @InnerTestClasses({ CreateFromUsage.CreateClass.class, CreateFromUsage.CreateFunction.class, + CreateFromUsage.CreateSecondaryConstructor.class, CreateFromUsage.CreateVariable.class, }) @RunWith(JUnit3RunnerWithInners.class) @@ -2266,6 +2267,45 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest { } } + @TestMetadata("idea/testData/quickfix/createFromUsage/createSecondaryConstructor") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class CreateSecondaryConstructor extends AbstractQuickFixTest { + public void testAllFilesPresentInCreateSecondaryConstructor() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/createFromUsage/createSecondaryConstructor"), Pattern.compile("^before(\\w+)\\.kt$"), true); + } + + @TestMetadata("beforeCallWithExpectedType.kt") + public void testCallWithExpectedType() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/createFromUsage/createSecondaryConstructor/beforeCallWithExpectedType.kt"); + doTest(fileName); + } + + @TestMetadata("beforeCallWithTypeArguments.kt") + public void testCallWithTypeArguments() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/createFromUsage/createSecondaryConstructor/beforeCallWithTypeArguments.kt"); + doTest(fileName); + } + + @TestMetadata("beforeClassWithBody.kt") + public void testClassWithBody() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/createFromUsage/createSecondaryConstructor/beforeClassWithBody.kt"); + doTest(fileName); + } + + @TestMetadata("beforeClassWithoutBody.kt") + public void testClassWithoutBody() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/createFromUsage/createSecondaryConstructor/beforeClassWithoutBody.kt"); + doTest(fileName); + } + + @TestMetadata("beforeWrongExpectedType.kt") + public void testWrongExpectedType() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/createFromUsage/createSecondaryConstructor/beforeWrongExpectedType.kt"); + doTest(fileName); + } + } + @TestMetadata("idea/testData/quickfix/createFromUsage/createVariable") @TestDataPath("$PROJECT_ROOT") @InnerTestClasses({