From 44234c7c0ab2ec9ec525f0e7945dd6e35f82fb0d Mon Sep 17 00:00:00 2001 From: Pradyoth Kukkapalli Date: Thu, 13 Feb 2014 23:52:31 -0500 Subject: [PATCH] New Intention Action: Replace a dot-qualified function call with an infix function call. --- .../jet/generators/tests/GenerateTests.kt | 1 + .../after.kt.template | 3 + .../before.kt.template | 3 + .../description.html | 5 ++ idea/src/META-INF/plugin.xml | 5 ++ .../jetbrains/jet/plugin/JetBundle.properties | 2 + .../ReplaceWithInfixFunctionCallIntention.kt | 88 +++++++++++++++++++ .../binaryExpressionArgument.kt | 3 + .../binaryExpressionArgument.kt.after | 3 + .../doubleFunctionCall.kt | 3 + .../doubleFunctionCall.kt.after | 3 + .../doubleFunctionCallWithoutParentheses.kt | 3 + ...bleFunctionCallWithoutParentheses.kt.after | 3 + .../firstParameterLabeled.kt | 9 ++ .../firstParameterLabeled.kt.after | 9 ++ .../functionLiteralArgument.kt | 3 + .../functionLiteralArgument.kt.after | 3 + .../functionSafeCall.kt | 4 + .../multipleArguments.kt | 4 + .../namedArgument.kt | 4 + .../nullAssertedReceiver.kt | 3 + .../nullAssertedReceiver.kt.after | 3 + .../propertyAccess.kt | 4 + .../secondParameterLabeled.kt | 10 +++ ...impleArgumentAndFunctionLiteralArgument.kt | 4 + .../simpleMethodCall.kt | 3 + .../simpleMethodCall.kt.after | 3 + .../zeroArguments.kt | 4 + .../AbstractCodeTransformationTest.java | 4 + .../CodeTransformationTestGenerated.java | 81 ++++++++++++++++- 30 files changed, 279 insertions(+), 1 deletion(-) create mode 100644 idea/resources/intentionDescriptions/ReplaceWithInfixFunctionCallIntention/after.kt.template create mode 100644 idea/resources/intentionDescriptions/ReplaceWithInfixFunctionCallIntention/before.kt.template create mode 100644 idea/resources/intentionDescriptions/ReplaceWithInfixFunctionCallIntention/description.html create mode 100644 idea/src/org/jetbrains/jet/plugin/intentions/ReplaceWithInfixFunctionCallIntention.kt create mode 100644 idea/testData/intentions/replaceWithInfixFunctionCall/binaryExpressionArgument.kt create mode 100644 idea/testData/intentions/replaceWithInfixFunctionCall/binaryExpressionArgument.kt.after create mode 100644 idea/testData/intentions/replaceWithInfixFunctionCall/doubleFunctionCall.kt create mode 100644 idea/testData/intentions/replaceWithInfixFunctionCall/doubleFunctionCall.kt.after create mode 100644 idea/testData/intentions/replaceWithInfixFunctionCall/doubleFunctionCallWithoutParentheses.kt create mode 100644 idea/testData/intentions/replaceWithInfixFunctionCall/doubleFunctionCallWithoutParentheses.kt.after create mode 100644 idea/testData/intentions/replaceWithInfixFunctionCall/firstParameterLabeled.kt create mode 100644 idea/testData/intentions/replaceWithInfixFunctionCall/firstParameterLabeled.kt.after create mode 100644 idea/testData/intentions/replaceWithInfixFunctionCall/functionLiteralArgument.kt create mode 100644 idea/testData/intentions/replaceWithInfixFunctionCall/functionLiteralArgument.kt.after create mode 100644 idea/testData/intentions/replaceWithInfixFunctionCall/functionSafeCall.kt create mode 100644 idea/testData/intentions/replaceWithInfixFunctionCall/multipleArguments.kt create mode 100644 idea/testData/intentions/replaceWithInfixFunctionCall/namedArgument.kt create mode 100644 idea/testData/intentions/replaceWithInfixFunctionCall/nullAssertedReceiver.kt create mode 100644 idea/testData/intentions/replaceWithInfixFunctionCall/nullAssertedReceiver.kt.after create mode 100644 idea/testData/intentions/replaceWithInfixFunctionCall/propertyAccess.kt create mode 100644 idea/testData/intentions/replaceWithInfixFunctionCall/secondParameterLabeled.kt create mode 100644 idea/testData/intentions/replaceWithInfixFunctionCall/simpleArgumentAndFunctionLiteralArgument.kt create mode 100644 idea/testData/intentions/replaceWithInfixFunctionCall/simpleMethodCall.kt create mode 100644 idea/testData/intentions/replaceWithInfixFunctionCall/simpleMethodCall.kt.after create mode 100644 idea/testData/intentions/replaceWithInfixFunctionCall/zeroArguments.kt diff --git a/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt b/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt index 4310239281e..9d45b5852aa 100644 --- a/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt +++ b/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt @@ -343,6 +343,7 @@ fun main(args: Array) { model("intentions/reconstructedType", testMethod = "doTestReconstructType") model("intentions/removeUnnecessaryParentheses", testMethod = "doTestRemoveUnnecessaryParentheses") model("intentions/replaceWithDotQualifiedMethodCall", testMethod = "doTestReplaceWithDotQualifiedMethodCall") + model("intentions/replaceWithInfixFunctionCall", testMethod = "doTestReplaceWithInfixFunctionCall") } testClass(javaClass()) { diff --git a/idea/resources/intentionDescriptions/ReplaceWithInfixFunctionCallIntention/after.kt.template b/idea/resources/intentionDescriptions/ReplaceWithInfixFunctionCallIntention/after.kt.template new file mode 100644 index 00000000000..49811bc3de2 --- /dev/null +++ b/idea/resources/intentionDescriptions/ReplaceWithInfixFunctionCallIntention/after.kt.template @@ -0,0 +1,3 @@ +fun foo(x: Foo) { + x foo 1 +} \ No newline at end of file diff --git a/idea/resources/intentionDescriptions/ReplaceWithInfixFunctionCallIntention/before.kt.template b/idea/resources/intentionDescriptions/ReplaceWithInfixFunctionCallIntention/before.kt.template new file mode 100644 index 00000000000..c9369b5f578 --- /dev/null +++ b/idea/resources/intentionDescriptions/ReplaceWithInfixFunctionCallIntention/before.kt.template @@ -0,0 +1,3 @@ +fun foo(x: Foo) { + x.foo(1) +} \ No newline at end of file diff --git a/idea/resources/intentionDescriptions/ReplaceWithInfixFunctionCallIntention/description.html b/idea/resources/intentionDescriptions/ReplaceWithInfixFunctionCallIntention/description.html new file mode 100644 index 00000000000..4d335f98204 --- /dev/null +++ b/idea/resources/intentionDescriptions/ReplaceWithInfixFunctionCallIntention/description.html @@ -0,0 +1,5 @@ + + +This intention converts a dot qualified method call to an infix function call. + + \ No newline at end of file diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index 479dea6fa9f..eb111a864ef 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -493,6 +493,11 @@ Kotlin + + org.jetbrains.jet.plugin.intentions.ReplaceWithInfixFunctionCallIntention + Kotlin + + diff --git a/idea/src/org/jetbrains/jet/plugin/JetBundle.properties b/idea/src/org/jetbrains/jet/plugin/JetBundle.properties index faac0da1282..e74bdad69af 100644 --- a/idea/src/org/jetbrains/jet/plugin/JetBundle.properties +++ b/idea/src/org/jetbrains/jet/plugin/JetBundle.properties @@ -224,6 +224,8 @@ add.name.to.argument.action=Add name to argument... add.name.to.parameter.name.chooser.title=Choose parameter name replace.with.dot.qualified.method.call.intention=Replace with simple method call replace.with.dot.qualified.method.call.intention.family=Replace with simple method call +replace.with.infix.function.call.intention=Replace with infix function call +replace.with.infix.function.call.intention.family=Replace with infix function call property.is.implemented.too.many=Has implementations property.is.overridden.too.many=Is overridden in subclasses diff --git a/idea/src/org/jetbrains/jet/plugin/intentions/ReplaceWithInfixFunctionCallIntention.kt b/idea/src/org/jetbrains/jet/plugin/intentions/ReplaceWithInfixFunctionCallIntention.kt new file mode 100644 index 00000000000..75d45b23226 --- /dev/null +++ b/idea/src/org/jetbrains/jet/plugin/intentions/ReplaceWithInfixFunctionCallIntention.kt @@ -0,0 +1,88 @@ +/* + * Copyright 2010-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.plugin.intentions + +import org.jetbrains.jet.lang.psi.JetCallExpression +import com.intellij.openapi.editor.Editor +import org.jetbrains.jet.lang.psi.JetDotQualifiedExpression +import org.jetbrains.jet.lang.psi.JetValueArgumentList +import org.jetbrains.jet.lang.psi.JetValueArgument +import org.jetbrains.jet.lang.psi.JetPsiFactory +import org.jetbrains.jet.lang.psi.JetPsiUtil +import org.jetbrains.jet.lang.psi.JetBinaryExpression +import org.jetbrains.jet.lang.psi.JetParenthesizedExpression +import org.jetbrains.jet.lang.psi.JetBinaryExpressionWithTypeRHS +import org.jetbrains.jet.lang.psi.JetPsiUnparsingUtils +import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache +import javax.naming.Binding +import org.jetbrains.jet.lang.resolve.BindingContext +import org.jetbrains.jet.lang.psi.JetFile + +public class ReplaceWithInfixFunctionCallIntention : JetSelfTargetingIntention("replace.with.infix.function.call.intention", javaClass()) { + override fun isApplicableTo(element: JetCallExpression): Boolean { + val parent = element.getParent() + + if (parent is JetDotQualifiedExpression) { + val callee = element.getCalleeExpression() + val typeArguments = element.getTypeArgumentList() + val valueArguments = element.getValueArgumentList() + val functionLiteralArguments = element.getFunctionLiteralArguments() + val numOfTotalValueArguments = (valueArguments?.getArguments()?.size() ?: 0) + functionLiteralArguments.size() + + if (typeArguments?.getArguments()?.size() ?: 0 == 0 && + numOfTotalValueArguments == 1 && + callee != null) { + if (valueArguments?.getArguments()?.size() == 1 && valueArguments?.getArguments()?.first()?.isNamed() ?: false) { + val file: JetFile = element.getContainingFile() as JetFile + val bindingContext = AnalyzerFacadeWithCache.analyzeFileWithCache(file).getBindingContext() + val descriptor = bindingContext.get(BindingContext.RESOLVED_CALL, callee) + val valueArgumentsMap = descriptor?.getValueArguments() + val firstArgument = valueArguments?.getArguments()?.first() + + return valueArgumentsMap?.keySet()?.any { it.getName().asString() == firstArgument?.getArgumentName()?.getText() && it.getIndex() == 0 } ?: false + } else { + return true + } + } else { + return false + } + } else { + return false + } + } + + override fun applyTo(element: JetCallExpression, editor: Editor) { + val parent = element.getParent() as JetDotQualifiedExpression + val leftHandText = parent.getReceiverExpression().getText() + val rightHandTextStringBuilder = StringBuilder() + val operatorText = element.getCalleeExpression()!!.getText() + val valueArguments = element.getValueArgumentList()?.getArguments() ?: listOf() + val functionLiteralArguments = element.getFunctionLiteralArguments() + + rightHandTextStringBuilder.append( + if (valueArguments.size() > 0) + JetPsiUnparsingUtils.parenthesizeIfNeeded(valueArguments.first().getArgumentExpression()) + else + functionLiteralArguments.first().getText() + ) + + val replacement = JetPsiFactory.createExpression(element.getProject(), "$leftHandText $operatorText ${rightHandTextStringBuilder.toString()}") + + parent.replace(replacement) + } +} + diff --git a/idea/testData/intentions/replaceWithInfixFunctionCall/binaryExpressionArgument.kt b/idea/testData/intentions/replaceWithInfixFunctionCall/binaryExpressionArgument.kt new file mode 100644 index 00000000000..d07530c24c5 --- /dev/null +++ b/idea/testData/intentions/replaceWithInfixFunctionCall/binaryExpressionArgument.kt @@ -0,0 +1,3 @@ +fun foo(x: Foo) { + x.foo(1 + 2) +} \ No newline at end of file diff --git a/idea/testData/intentions/replaceWithInfixFunctionCall/binaryExpressionArgument.kt.after b/idea/testData/intentions/replaceWithInfixFunctionCall/binaryExpressionArgument.kt.after new file mode 100644 index 00000000000..09647c106b7 --- /dev/null +++ b/idea/testData/intentions/replaceWithInfixFunctionCall/binaryExpressionArgument.kt.after @@ -0,0 +1,3 @@ +fun foo(x: Foo) { + x foo (1 + 2) +} \ No newline at end of file diff --git a/idea/testData/intentions/replaceWithInfixFunctionCall/doubleFunctionCall.kt b/idea/testData/intentions/replaceWithInfixFunctionCall/doubleFunctionCall.kt new file mode 100644 index 00000000000..6f44b90ac9b --- /dev/null +++ b/idea/testData/intentions/replaceWithInfixFunctionCall/doubleFunctionCall.kt @@ -0,0 +1,3 @@ +fun foo(x: Foo) { + (x.foo(1)).bar(2) +} \ No newline at end of file diff --git a/idea/testData/intentions/replaceWithInfixFunctionCall/doubleFunctionCall.kt.after b/idea/testData/intentions/replaceWithInfixFunctionCall/doubleFunctionCall.kt.after new file mode 100644 index 00000000000..de1fe05bd52 --- /dev/null +++ b/idea/testData/intentions/replaceWithInfixFunctionCall/doubleFunctionCall.kt.after @@ -0,0 +1,3 @@ +fun foo(x: Foo) { + (x foo 1).bar(2) +} \ No newline at end of file diff --git a/idea/testData/intentions/replaceWithInfixFunctionCall/doubleFunctionCallWithoutParentheses.kt b/idea/testData/intentions/replaceWithInfixFunctionCall/doubleFunctionCallWithoutParentheses.kt new file mode 100644 index 00000000000..4f53bb517ca --- /dev/null +++ b/idea/testData/intentions/replaceWithInfixFunctionCall/doubleFunctionCallWithoutParentheses.kt @@ -0,0 +1,3 @@ +fun foo(x: Foo) { + x.foo(1).bar(2) +} \ No newline at end of file diff --git a/idea/testData/intentions/replaceWithInfixFunctionCall/doubleFunctionCallWithoutParentheses.kt.after b/idea/testData/intentions/replaceWithInfixFunctionCall/doubleFunctionCallWithoutParentheses.kt.after new file mode 100644 index 00000000000..de1fe05bd52 --- /dev/null +++ b/idea/testData/intentions/replaceWithInfixFunctionCall/doubleFunctionCallWithoutParentheses.kt.after @@ -0,0 +1,3 @@ +fun foo(x: Foo) { + (x foo 1).bar(2) +} \ No newline at end of file diff --git a/idea/testData/intentions/replaceWithInfixFunctionCall/firstParameterLabeled.kt b/idea/testData/intentions/replaceWithInfixFunctionCall/firstParameterLabeled.kt new file mode 100644 index 00000000000..4cb841b23be --- /dev/null +++ b/idea/testData/intentions/replaceWithInfixFunctionCall/firstParameterLabeled.kt @@ -0,0 +1,9 @@ +class Foo { + fun foo(x: Int) { + println("lol") + } +} + +fun bar(baz: Foo) { + baz.foo(x = 1) +} \ No newline at end of file diff --git a/idea/testData/intentions/replaceWithInfixFunctionCall/firstParameterLabeled.kt.after b/idea/testData/intentions/replaceWithInfixFunctionCall/firstParameterLabeled.kt.after new file mode 100644 index 00000000000..cc79e8c716f --- /dev/null +++ b/idea/testData/intentions/replaceWithInfixFunctionCall/firstParameterLabeled.kt.after @@ -0,0 +1,9 @@ +class Foo { + fun foo(x: Int) { + println("lol") + } +} + +fun bar(baz: Foo) { + baz foo 1 +} \ No newline at end of file diff --git a/idea/testData/intentions/replaceWithInfixFunctionCall/functionLiteralArgument.kt b/idea/testData/intentions/replaceWithInfixFunctionCall/functionLiteralArgument.kt new file mode 100644 index 00000000000..44cfbc29082 --- /dev/null +++ b/idea/testData/intentions/replaceWithInfixFunctionCall/functionLiteralArgument.kt @@ -0,0 +1,3 @@ +fun foo(x: Foo) { + x.foo { it * 2 } +} \ No newline at end of file diff --git a/idea/testData/intentions/replaceWithInfixFunctionCall/functionLiteralArgument.kt.after b/idea/testData/intentions/replaceWithInfixFunctionCall/functionLiteralArgument.kt.after new file mode 100644 index 00000000000..cfb30b4d639 --- /dev/null +++ b/idea/testData/intentions/replaceWithInfixFunctionCall/functionLiteralArgument.kt.after @@ -0,0 +1,3 @@ +fun foo(x: Foo) { + x foo { it * 2 } +} \ No newline at end of file diff --git a/idea/testData/intentions/replaceWithInfixFunctionCall/functionSafeCall.kt b/idea/testData/intentions/replaceWithInfixFunctionCall/functionSafeCall.kt new file mode 100644 index 00000000000..b4e1e8bc973 --- /dev/null +++ b/idea/testData/intentions/replaceWithInfixFunctionCall/functionSafeCall.kt @@ -0,0 +1,4 @@ +// IS_APPLICABLE: false +fun foo(x: Foo) { + x?.foo(1) +} \ No newline at end of file diff --git a/idea/testData/intentions/replaceWithInfixFunctionCall/multipleArguments.kt b/idea/testData/intentions/replaceWithInfixFunctionCall/multipleArguments.kt new file mode 100644 index 00000000000..3ac351e4031 --- /dev/null +++ b/idea/testData/intentions/replaceWithInfixFunctionCall/multipleArguments.kt @@ -0,0 +1,4 @@ +// IS_APPLICABLE: false +fun foo(x: Foo) { + x.foo(1, 2) +} \ No newline at end of file diff --git a/idea/testData/intentions/replaceWithInfixFunctionCall/namedArgument.kt b/idea/testData/intentions/replaceWithInfixFunctionCall/namedArgument.kt new file mode 100644 index 00000000000..d42db6104c2 --- /dev/null +++ b/idea/testData/intentions/replaceWithInfixFunctionCall/namedArgument.kt @@ -0,0 +1,4 @@ +// IS_APPLICABLE: false +fun foo(x: Foo) { + x.foo(bar = x) +} \ No newline at end of file diff --git a/idea/testData/intentions/replaceWithInfixFunctionCall/nullAssertedReceiver.kt b/idea/testData/intentions/replaceWithInfixFunctionCall/nullAssertedReceiver.kt new file mode 100644 index 00000000000..00385018b4b --- /dev/null +++ b/idea/testData/intentions/replaceWithInfixFunctionCall/nullAssertedReceiver.kt @@ -0,0 +1,3 @@ +fun foo(x: Foo) { + x!!.foo(1) +} \ No newline at end of file diff --git a/idea/testData/intentions/replaceWithInfixFunctionCall/nullAssertedReceiver.kt.after b/idea/testData/intentions/replaceWithInfixFunctionCall/nullAssertedReceiver.kt.after new file mode 100644 index 00000000000..9cdf9e38864 --- /dev/null +++ b/idea/testData/intentions/replaceWithInfixFunctionCall/nullAssertedReceiver.kt.after @@ -0,0 +1,3 @@ +fun foo(x: Foo) { + x!! foo 1 +} \ No newline at end of file diff --git a/idea/testData/intentions/replaceWithInfixFunctionCall/propertyAccess.kt b/idea/testData/intentions/replaceWithInfixFunctionCall/propertyAccess.kt new file mode 100644 index 00000000000..4c5835f02df --- /dev/null +++ b/idea/testData/intentions/replaceWithInfixFunctionCall/propertyAccess.kt @@ -0,0 +1,4 @@ +// IS_APPLICABLE: false +fun foo(x: foo) { + x.foo +} \ No newline at end of file diff --git a/idea/testData/intentions/replaceWithInfixFunctionCall/secondParameterLabeled.kt b/idea/testData/intentions/replaceWithInfixFunctionCall/secondParameterLabeled.kt new file mode 100644 index 00000000000..f5b3108c610 --- /dev/null +++ b/idea/testData/intentions/replaceWithInfixFunctionCall/secondParameterLabeled.kt @@ -0,0 +1,10 @@ +// IS_APPLICABLE: false +class Foo { + fun foo(x: Int = 0, y: Int = 0) { + println("lol") + } +} + +fun bar(baz: Foo) { + baz.foo(y = 1) +} \ No newline at end of file diff --git a/idea/testData/intentions/replaceWithInfixFunctionCall/simpleArgumentAndFunctionLiteralArgument.kt b/idea/testData/intentions/replaceWithInfixFunctionCall/simpleArgumentAndFunctionLiteralArgument.kt new file mode 100644 index 00000000000..03f887129a5 --- /dev/null +++ b/idea/testData/intentions/replaceWithInfixFunctionCall/simpleArgumentAndFunctionLiteralArgument.kt @@ -0,0 +1,4 @@ +// IS_APPLICABLE: false +fun foo(x: Foo) { + x.foo(1) { it * 2 } +} \ No newline at end of file diff --git a/idea/testData/intentions/replaceWithInfixFunctionCall/simpleMethodCall.kt b/idea/testData/intentions/replaceWithInfixFunctionCall/simpleMethodCall.kt new file mode 100644 index 00000000000..ba565ab4fb0 --- /dev/null +++ b/idea/testData/intentions/replaceWithInfixFunctionCall/simpleMethodCall.kt @@ -0,0 +1,3 @@ +fun foo(x: Foo) { + x.foo(1) +} \ No newline at end of file diff --git a/idea/testData/intentions/replaceWithInfixFunctionCall/simpleMethodCall.kt.after b/idea/testData/intentions/replaceWithInfixFunctionCall/simpleMethodCall.kt.after new file mode 100644 index 00000000000..dedbef8172f --- /dev/null +++ b/idea/testData/intentions/replaceWithInfixFunctionCall/simpleMethodCall.kt.after @@ -0,0 +1,3 @@ +fun foo(x: Foo) { + x foo 1 +} \ No newline at end of file diff --git a/idea/testData/intentions/replaceWithInfixFunctionCall/zeroArguments.kt b/idea/testData/intentions/replaceWithInfixFunctionCall/zeroArguments.kt new file mode 100644 index 00000000000..f0a2356242e --- /dev/null +++ b/idea/testData/intentions/replaceWithInfixFunctionCall/zeroArguments.kt @@ -0,0 +1,4 @@ +// IS_APPLICABLE: false +fun foo(x: Foo) { + x.foo() +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/jet/plugin/intentions/AbstractCodeTransformationTest.java b/idea/tests/org/jetbrains/jet/plugin/intentions/AbstractCodeTransformationTest.java index eac6e58589d..a500035e7f0 100644 --- a/idea/tests/org/jetbrains/jet/plugin/intentions/AbstractCodeTransformationTest.java +++ b/idea/tests/org/jetbrains/jet/plugin/intentions/AbstractCodeTransformationTest.java @@ -122,6 +122,10 @@ public abstract class AbstractCodeTransformationTest extends LightCodeInsightTes doTestIntention(path, new ReplaceWithDotQualifiedMethodCallIntention()); } + public void doTestReplaceWithInfixFunctionCall(@NotNull String path) throws Exception { + doTestIntention(path, new ReplaceWithInfixFunctionCallIntention()); + } + private void doTestIntention(@NotNull String path, @NotNull IntentionAction intentionAction) throws Exception { configureByFile(path); diff --git a/idea/tests/org/jetbrains/jet/plugin/intentions/CodeTransformationTestGenerated.java b/idea/tests/org/jetbrains/jet/plugin/intentions/CodeTransformationTestGenerated.java index 3662d761c05..24f01b498a5 100644 --- a/idea/tests/org/jetbrains/jet/plugin/intentions/CodeTransformationTestGenerated.java +++ b/idea/tests/org/jetbrains/jet/plugin/intentions/CodeTransformationTestGenerated.java @@ -30,7 +30,7 @@ import org.jetbrains.jet.plugin.intentions.AbstractCodeTransformationTest; /** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ @SuppressWarnings("all") -@InnerTestClasses({CodeTransformationTestGenerated.IfToAssignment.class, CodeTransformationTestGenerated.IfToReturn.class, CodeTransformationTestGenerated.IfToReturnAsymmetrically.class, CodeTransformationTestGenerated.WhenToAssignment.class, CodeTransformationTestGenerated.WhenToReturn.class, CodeTransformationTestGenerated.AssignmentToIf.class, CodeTransformationTestGenerated.AssignmentToWhen.class, CodeTransformationTestGenerated.PropertyToIf.class, CodeTransformationTestGenerated.PropertyToWhen.class, CodeTransformationTestGenerated.ReturnToIf.class, CodeTransformationTestGenerated.ReturnToWhen.class, CodeTransformationTestGenerated.IfToWhen.class, CodeTransformationTestGenerated.WhenToIf.class, CodeTransformationTestGenerated.Flatten.class, CodeTransformationTestGenerated.Merge.class, CodeTransformationTestGenerated.IntroduceSubject.class, CodeTransformationTestGenerated.EliminateSubject.class, CodeTransformationTestGenerated.Split.class, CodeTransformationTestGenerated.Join.class, CodeTransformationTestGenerated.ConvertMemberToExtension.class, CodeTransformationTestGenerated.ReconstructedType.class, CodeTransformationTestGenerated.RemoveUnnecessaryParentheses.class, CodeTransformationTestGenerated.ReplaceWithDotQualifiedMethodCall.class}) +@InnerTestClasses({CodeTransformationTestGenerated.IfToAssignment.class, CodeTransformationTestGenerated.IfToReturn.class, CodeTransformationTestGenerated.IfToReturnAsymmetrically.class, CodeTransformationTestGenerated.WhenToAssignment.class, CodeTransformationTestGenerated.WhenToReturn.class, CodeTransformationTestGenerated.AssignmentToIf.class, CodeTransformationTestGenerated.AssignmentToWhen.class, CodeTransformationTestGenerated.PropertyToIf.class, CodeTransformationTestGenerated.PropertyToWhen.class, CodeTransformationTestGenerated.ReturnToIf.class, CodeTransformationTestGenerated.ReturnToWhen.class, CodeTransformationTestGenerated.IfToWhen.class, CodeTransformationTestGenerated.WhenToIf.class, CodeTransformationTestGenerated.Flatten.class, CodeTransformationTestGenerated.Merge.class, CodeTransformationTestGenerated.IntroduceSubject.class, CodeTransformationTestGenerated.EliminateSubject.class, CodeTransformationTestGenerated.Split.class, CodeTransformationTestGenerated.Join.class, CodeTransformationTestGenerated.ConvertMemberToExtension.class, CodeTransformationTestGenerated.ReconstructedType.class, CodeTransformationTestGenerated.RemoveUnnecessaryParentheses.class, CodeTransformationTestGenerated.ReplaceWithDotQualifiedMethodCall.class, CodeTransformationTestGenerated.ReplaceWithInfixFunctionCall.class}) public class CodeTransformationTestGenerated extends AbstractCodeTransformationTest { @TestMetadata("idea/testData/intentions/branched/folding/ifToAssignment") public static class IfToAssignment extends AbstractCodeTransformationTest { @@ -1221,6 +1221,84 @@ public class CodeTransformationTestGenerated extends AbstractCodeTransformationT } + @TestMetadata("idea/testData/intentions/replaceWithInfixFunctionCall") + public static class ReplaceWithInfixFunctionCall extends AbstractCodeTransformationTest { + public void testAllFilesPresentInReplaceWithInfixFunctionCall() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/intentions/replaceWithInfixFunctionCall"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("binaryExpressionArgument.kt") + public void testBinaryExpressionArgument() throws Exception { + doTestReplaceWithInfixFunctionCall("idea/testData/intentions/replaceWithInfixFunctionCall/binaryExpressionArgument.kt"); + } + + @TestMetadata("doubleFunctionCall.kt") + public void testDoubleFunctionCall() throws Exception { + doTestReplaceWithInfixFunctionCall("idea/testData/intentions/replaceWithInfixFunctionCall/doubleFunctionCall.kt"); + } + + @TestMetadata("doubleFunctionCallWithoutParentheses.kt") + public void testDoubleFunctionCallWithoutParentheses() throws Exception { + doTestReplaceWithInfixFunctionCall("idea/testData/intentions/replaceWithInfixFunctionCall/doubleFunctionCallWithoutParentheses.kt"); + } + + @TestMetadata("firstParameterLabeled.kt") + public void testFirstParameterLabeled() throws Exception { + doTestReplaceWithInfixFunctionCall("idea/testData/intentions/replaceWithInfixFunctionCall/firstParameterLabeled.kt"); + } + + @TestMetadata("functionLiteralArgument.kt") + public void testFunctionLiteralArgument() throws Exception { + doTestReplaceWithInfixFunctionCall("idea/testData/intentions/replaceWithInfixFunctionCall/functionLiteralArgument.kt"); + } + + @TestMetadata("functionSafeCall.kt") + public void testFunctionSafeCall() throws Exception { + doTestReplaceWithInfixFunctionCall("idea/testData/intentions/replaceWithInfixFunctionCall/functionSafeCall.kt"); + } + + @TestMetadata("multipleArguments.kt") + public void testMultipleArguments() throws Exception { + doTestReplaceWithInfixFunctionCall("idea/testData/intentions/replaceWithInfixFunctionCall/multipleArguments.kt"); + } + + @TestMetadata("namedArgument.kt") + public void testNamedArgument() throws Exception { + doTestReplaceWithInfixFunctionCall("idea/testData/intentions/replaceWithInfixFunctionCall/namedArgument.kt"); + } + + @TestMetadata("nullAssertedReceiver.kt") + public void testNullAssertedReceiver() throws Exception { + doTestReplaceWithInfixFunctionCall("idea/testData/intentions/replaceWithInfixFunctionCall/nullAssertedReceiver.kt"); + } + + @TestMetadata("propertyAccess.kt") + public void testPropertyAccess() throws Exception { + doTestReplaceWithInfixFunctionCall("idea/testData/intentions/replaceWithInfixFunctionCall/propertyAccess.kt"); + } + + @TestMetadata("secondParameterLabeled.kt") + public void testSecondParameterLabeled() throws Exception { + doTestReplaceWithInfixFunctionCall("idea/testData/intentions/replaceWithInfixFunctionCall/secondParameterLabeled.kt"); + } + + @TestMetadata("simpleArgumentAndFunctionLiteralArgument.kt") + public void testSimpleArgumentAndFunctionLiteralArgument() throws Exception { + doTestReplaceWithInfixFunctionCall("idea/testData/intentions/replaceWithInfixFunctionCall/simpleArgumentAndFunctionLiteralArgument.kt"); + } + + @TestMetadata("simpleMethodCall.kt") + public void testSimpleMethodCall() throws Exception { + doTestReplaceWithInfixFunctionCall("idea/testData/intentions/replaceWithInfixFunctionCall/simpleMethodCall.kt"); + } + + @TestMetadata("zeroArguments.kt") + public void testZeroArguments() throws Exception { + doTestReplaceWithInfixFunctionCall("idea/testData/intentions/replaceWithInfixFunctionCall/zeroArguments.kt"); + } + + } + public static Test suite() { TestSuite suite = new TestSuite("CodeTransformationTestGenerated"); suite.addTestSuite(IfToAssignment.class); @@ -1246,6 +1324,7 @@ public class CodeTransformationTestGenerated extends AbstractCodeTransformationT suite.addTestSuite(ReconstructedType.class); suite.addTestSuite(RemoveUnnecessaryParentheses.class); suite.addTestSuite(ReplaceWithDotQualifiedMethodCall.class); + suite.addTestSuite(ReplaceWithInfixFunctionCall.class); return suite; } }