From 84a89118223c4dc329926de4879dbbef663e71d1 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 27 Feb 2014 15:57:51 -0500 Subject: [PATCH] Add replacement intentions for operator functions Add intentions for replacing attribute calls that correspond to overloadable operators with their respective operators. This commit includes call replacements for: * Binary Infix Operators: plus, minus, times, rangeTo, mod, div * Unary Prefix Operators: plus, minus, not * Array Index Operator: get * In Operator: contains --- .../jet/generators/tests/GenerateTests.kt | 5 + .../after.kt.template | 6 + .../before.kt.template | 6 + .../description.html | 6 + .../after.kt.template | 1 + .../before.kt.template | 1 + .../ReplaceContainsIntention/description.html | 5 + .../ReplaceGetIntention/after.kt.template | 1 + .../ReplaceGetIntention/before.kt.template | 1 + .../ReplaceGetIntention/description.html | 5 + .../ReplaceInvokeIntention/after.kt.template | 1 + .../ReplaceInvokeIntention/before.kt.template | 1 + .../ReplaceInvokeIntention/description.html | 5 + .../after.kt.template | 3 + .../before.kt.template | 3 + .../description.html | 5 + idea/src/META-INF/plugin.xml | 25 ++ .../jetbrains/jet/plugin/JetBundle.properties | 24 + .../AttributeCallReplacementIntention.kt | 140 ++++++ .../ReplaceBinaryInfixIntention.kt | 61 +++ .../ReplaceContainsIntention.kt | 63 +++ .../ReplaceGetIntention.kt | 37 ++ .../ReplaceInvokeIntention.kt | 37 ++ .../ReplaceUnaryPrefixIntention.kt | 52 +++ .../acceptableVararg1.kt | 7 + .../acceptableVararg1.kt.after | 7 + .../acceptableVararg2.kt | 7 + .../acceptableVararg2.kt.after | 7 + .../allowableDefaultArgument.kt | 7 + .../allowableDefaultArgument.kt.after | 7 + .../divSanityTest.kt | 8 + .../divSanityTest.kt.after | 8 + .../extensionFunction.kt | 6 + .../extensionFunction.kt.after | 6 + .../functionLiteralArgument.kt | 9 + .../functionLiteralArgument.kt.after | 9 + .../minusSanityTest.kt | 8 + .../minusSanityTest.kt.after | 8 + .../missingDefaultArgument.kt | 8 + .../modSanityTest.kt | 8 + .../modSanityTest.kt.after | 8 + .../multipleArguments.kt | 8 + .../plusSanityTest.kt | 8 + .../plusSanityTest.kt.after | 8 + .../rangeToSanityTest.kt | 8 + .../rangeToSanityTest.kt.after | 8 + .../timesSanityTest.kt | 8 + .../timesSanityTest.kt.after | 8 + .../typeArguments.kt | 8 + .../unacceptableVararg1.kt | 8 + .../unacceptableVararg2.kt | 8 + .../validNamedArgument.kt | 7 + .../validNamedArgument.kt.after | 7 + .../acceptableVararg.kt | 7 + .../acceptableVararg.kt.after | 7 + .../acceptableVararg2.kt | 7 + .../acceptableVararg2.kt.after | 7 + .../allowableDefaultArgument.kt | 7 + .../allowableDefaultArgument.kt.after | 7 + .../containsInExpression.kt | 7 + .../containsInExpression.kt.after | 7 + .../extensionFunction.kt | 6 + .../extensionFunction.kt.after | 6 + .../functionLiteralArgument.kt | 9 + .../functionLiteralArgument.kt.after | 9 + .../functionLiteralArgumentAfterSemicolon.kt | 9 + ...tionLiteralArgumentAfterSemicolon.kt.after | 9 + .../functionLiteralArgumentAtStartOfBlock.kt | 11 + ...tionLiteralArgumentAtStartOfBlock.kt.after | 11 + .../functionLiteralArgumentInExpression.kt | 7 + ...nctionLiteralArgumentInExpression.kt.after | 7 + .../invalidArgument.kt | 8 + .../missingArgument.kt | 8 + .../missingDefaultArgument.kt | 8 + .../multipleArguments.kt | 8 + .../simpleArgument.kt | 7 + .../simpleArgument.kt.after | 7 + .../replaceContainsIntention/typeArguments.kt | 7 + .../typeArguments.kt.after | 7 + .../unacceptableVararg1.kt | 8 + .../unacceptableVararg2.kt | 8 + .../validNamedArgument.kt | 7 + .../validNamedArgument.kt.after | 7 + .../replaceGetIntention/acceptableVararg.kt | 7 + .../acceptableVararg.kt.after | 7 + .../argumentAndFunction.kt | 9 + .../argumentAndFunction.kt.after | 9 + .../replaceGetIntention/duplicateArguments.kt | 8 + .../replaceGetIntention/extensionFunction.kt | 7 + .../extensionFunction.kt.after | 7 + .../replaceGetIntention/functionalArgument.kt | 9 + .../functionalArgument.kt.after | 9 + .../replaceGetIntention/invalidArgument.kt | 8 + .../replaceGetIntention/missingArgument.kt | 8 + .../missingDefaultArgument.kt | 8 + .../replaceGetIntention/multiArgument.kt | 7 + .../multiArgument.kt.after | 7 + .../replaceGetIntention/namedAndFunction.kt | 9 + .../namedAndFunction.kt.after | 9 + .../replaceGetIntention/noArgument.kt | 8 + .../replaceGetIntention/sanityCheck.kt | 8 + .../replaceGetIntention/singleArgument.kt | 7 + .../singleArgument.kt.after | 7 + .../singleNamedArgument.kt | 7 + .../singleNamedArgument.kt.after | 7 + .../replaceGetIntention/unacceptableVararg.kt | 8 + .../replaceGetIntention/unnamedAndNamed.kt | 7 + .../unnamedAndNamed.kt.after | 7 + .../extensionFunction.kt | 8 + .../extensionFunction.kt.after | 8 + .../functionLiteralInvoke.kt | 9 + .../functionLiteralInvoke.kt.after | 9 + .../invokeInExpression.kt | 7 + .../invokeInExpression.kt.after | 7 + .../namedArgumentInvoke.kt | 7 + .../namedArgumentInvoke.kt.after | 7 + .../noArgumentInvoke.kt | 7 + .../noArgumentInvoke.kt.after | 7 + .../typeAndValueArgument.kt | 7 + .../typeAndValueArgument.kt.after | 7 + .../typeArgumentAndFunctionLiteral.kt | 7 + .../typeArgumentAndFunctionLiteral.kt.after | 7 + .../valueAndFunctionLiteralInvoke.kt | 9 + .../valueAndFunctionLiteralInvoke.kt.after | 9 + .../valueArgumentInvoke.kt | 7 + .../valueArgumentInvoke.kt.after | 7 + .../replaceInvokeIntention/varargInvoke.kt | 7 + .../varargInvoke.kt.after | 7 + .../acceptableVararg.kt | 7 + .../acceptableVararg.kt.after | 7 + .../complexPlus.kt | 9 + .../complexPlus.kt.after | 9 + .../defaultArgument.kt | 7 + .../defaultArgument.kt.after | 7 + .../extensionFunction.kt | 8 + .../extensionFunction.kt.after | 8 + .../functionLiteralArgument.kt | 8 + .../minusSanityTest.kt | 8 + .../minusSanityTest.kt.after | 8 + .../namedValueArgument.kt | 8 + .../notSanityTest.kt | 8 + .../notSanityTest.kt.after | 8 + .../replaceUnaryPrefixIntention/plusPlus.kt | 7 + .../plusPlus.kt.after | 7 + .../plusSanityTest.kt | 8 + .../plusSanityTest.kt.after | 8 + .../typeArguments.kt | 8 + .../unacceptableVararg.kt | 8 + .../valueArgument.kt | 8 + .../AbstractCodeTransformationTest.java | 20 + ...buteCallReplacementIntentionTestHelpers.kt | 32 ++ .../CodeTransformationTestGenerated.java | 417 +++++++++++++++++- 152 files changed, 1922 insertions(+), 1 deletion(-) create mode 100644 idea/resources/intentionDescriptions/ReplaceBinaryInfixIntention/after.kt.template create mode 100644 idea/resources/intentionDescriptions/ReplaceBinaryInfixIntention/before.kt.template create mode 100644 idea/resources/intentionDescriptions/ReplaceBinaryInfixIntention/description.html create mode 100644 idea/resources/intentionDescriptions/ReplaceContainsIntention/after.kt.template create mode 100644 idea/resources/intentionDescriptions/ReplaceContainsIntention/before.kt.template create mode 100644 idea/resources/intentionDescriptions/ReplaceContainsIntention/description.html create mode 100644 idea/resources/intentionDescriptions/ReplaceGetIntention/after.kt.template create mode 100644 idea/resources/intentionDescriptions/ReplaceGetIntention/before.kt.template create mode 100644 idea/resources/intentionDescriptions/ReplaceGetIntention/description.html create mode 100644 idea/resources/intentionDescriptions/ReplaceInvokeIntention/after.kt.template create mode 100644 idea/resources/intentionDescriptions/ReplaceInvokeIntention/before.kt.template create mode 100644 idea/resources/intentionDescriptions/ReplaceInvokeIntention/description.html create mode 100644 idea/resources/intentionDescriptions/ReplaceUnaryPrefixIntention/after.kt.template create mode 100644 idea/resources/intentionDescriptions/ReplaceUnaryPrefixIntention/before.kt.template create mode 100644 idea/resources/intentionDescriptions/ReplaceUnaryPrefixIntention/description.html create mode 100644 idea/src/org/jetbrains/jet/plugin/intentions/attributeCallReplacements/AttributeCallReplacementIntention.kt create mode 100644 idea/src/org/jetbrains/jet/plugin/intentions/attributeCallReplacements/ReplaceBinaryInfixIntention.kt create mode 100644 idea/src/org/jetbrains/jet/plugin/intentions/attributeCallReplacements/ReplaceContainsIntention.kt create mode 100644 idea/src/org/jetbrains/jet/plugin/intentions/attributeCallReplacements/ReplaceGetIntention.kt create mode 100644 idea/src/org/jetbrains/jet/plugin/intentions/attributeCallReplacements/ReplaceInvokeIntention.kt create mode 100644 idea/src/org/jetbrains/jet/plugin/intentions/attributeCallReplacements/ReplaceUnaryPrefixIntention.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/acceptableVararg1.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/acceptableVararg1.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/acceptableVararg2.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/acceptableVararg2.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/allowableDefaultArgument.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/allowableDefaultArgument.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/divSanityTest.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/divSanityTest.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/extensionFunction.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/extensionFunction.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/functionLiteralArgument.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/functionLiteralArgument.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/minusSanityTest.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/minusSanityTest.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/missingDefaultArgument.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/modSanityTest.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/modSanityTest.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/multipleArguments.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/plusSanityTest.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/plusSanityTest.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/rangeToSanityTest.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/rangeToSanityTest.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/timesSanityTest.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/timesSanityTest.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/typeArguments.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/unacceptableVararg1.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/unacceptableVararg2.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/validNamedArgument.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/validNamedArgument.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/acceptableVararg.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/acceptableVararg.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/acceptableVararg2.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/acceptableVararg2.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/allowableDefaultArgument.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/allowableDefaultArgument.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/containsInExpression.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/containsInExpression.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/extensionFunction.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/extensionFunction.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgument.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgument.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgumentAfterSemicolon.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgumentAfterSemicolon.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgumentAtStartOfBlock.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgumentAtStartOfBlock.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgumentInExpression.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgumentInExpression.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/invalidArgument.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/missingArgument.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/missingDefaultArgument.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/multipleArguments.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/simpleArgument.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/simpleArgument.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/typeArguments.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/typeArguments.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/unacceptableVararg1.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/unacceptableVararg2.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/validNamedArgument.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/validNamedArgument.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceGetIntention/acceptableVararg.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceGetIntention/acceptableVararg.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceGetIntention/argumentAndFunction.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceGetIntention/argumentAndFunction.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceGetIntention/duplicateArguments.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceGetIntention/extensionFunction.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceGetIntention/extensionFunction.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceGetIntention/functionalArgument.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceGetIntention/functionalArgument.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceGetIntention/invalidArgument.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceGetIntention/missingArgument.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceGetIntention/missingDefaultArgument.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceGetIntention/multiArgument.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceGetIntention/multiArgument.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceGetIntention/namedAndFunction.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceGetIntention/namedAndFunction.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceGetIntention/noArgument.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceGetIntention/sanityCheck.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceGetIntention/singleArgument.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceGetIntention/singleArgument.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceGetIntention/singleNamedArgument.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceGetIntention/singleNamedArgument.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceGetIntention/unacceptableVararg.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceGetIntention/unnamedAndNamed.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceGetIntention/unnamedAndNamed.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/extensionFunction.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/extensionFunction.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/functionLiteralInvoke.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/functionLiteralInvoke.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/invokeInExpression.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/invokeInExpression.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/namedArgumentInvoke.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/namedArgumentInvoke.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/noArgumentInvoke.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/noArgumentInvoke.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/typeAndValueArgument.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/typeAndValueArgument.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/typeArgumentAndFunctionLiteral.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/typeArgumentAndFunctionLiteral.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/valueAndFunctionLiteralInvoke.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/valueAndFunctionLiteralInvoke.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/valueArgumentInvoke.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/valueArgumentInvoke.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/varargInvoke.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/varargInvoke.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/acceptableVararg.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/acceptableVararg.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/complexPlus.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/complexPlus.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/defaultArgument.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/defaultArgument.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/extensionFunction.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/extensionFunction.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/functionLiteralArgument.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/minusSanityTest.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/minusSanityTest.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/namedValueArgument.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/notSanityTest.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/notSanityTest.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/plusPlus.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/plusPlus.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/plusSanityTest.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/plusSanityTest.kt.after create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/typeArguments.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/unacceptableVararg.kt create mode 100644 idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/valueArgument.kt create mode 100644 idea/tests/org/jetbrains/jet/plugin/intentions/AttributeCallReplacementIntentionTestHelpers.kt diff --git a/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt b/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt index 60d0e3b475a..24b3345531b 100644 --- a/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt +++ b/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt @@ -379,6 +379,11 @@ fun main(args: Array) { model("intentions/replaceItWithExplicitFunctionLiteralParam", testMethod = "doTestReplaceItWithExplicitFunctionLiteralParam") model("intentions/removeBraces", testMethod = "doTestRemoveBraces") model("intentions/addBraces", testMethod = "doTestAddBraces") + model("intentions/attributeCallReplacements/replaceGetIntention", testMethod = "doTestReplaceGetIntention") + model("intentions/attributeCallReplacements/replaceContainsIntention", testMethod = "doTestReplaceContainsIntention") + model("intentions/attributeCallReplacements/replaceBinaryInfixIntention", testMethod = "doTestReplaceBinaryInfixIntention") + model("intentions/attributeCallReplacements/replaceUnaryPrefixIntention", testMethod = "doTestReplaceUnaryPrefixIntention") + model("intentions/attributeCallReplacements/replaceInvokeIntention", testMethod = "doTestReplaceInvokeIntention") } testClass(javaClass()) { diff --git a/idea/resources/intentionDescriptions/ReplaceBinaryInfixIntention/after.kt.template b/idea/resources/intentionDescriptions/ReplaceBinaryInfixIntention/after.kt.template new file mode 100644 index 00000000000..ec1fb563f1d --- /dev/null +++ b/idea/resources/intentionDescriptions/ReplaceBinaryInfixIntention/after.kt.template @@ -0,0 +1,6 @@ +a + b +a - b +a * b +a / b +a % b +a .. b diff --git a/idea/resources/intentionDescriptions/ReplaceBinaryInfixIntention/before.kt.template b/idea/resources/intentionDescriptions/ReplaceBinaryInfixIntention/before.kt.template new file mode 100644 index 00000000000..b7900977148 --- /dev/null +++ b/idea/resources/intentionDescriptions/ReplaceBinaryInfixIntention/before.kt.template @@ -0,0 +1,6 @@ +a.plus(b) +a.minus(b) +a.times(b) +a.div(b) +a.mod(b) +a.rangeTo(b) diff --git a/idea/resources/intentionDescriptions/ReplaceBinaryInfixIntention/description.html b/idea/resources/intentionDescriptions/ReplaceBinaryInfixIntention/description.html new file mode 100644 index 00000000000..ce532c73157 --- /dev/null +++ b/idea/resources/intentionDescriptions/ReplaceBinaryInfixIntention/description.html @@ -0,0 +1,6 @@ + + +This intention replaces any calls to infix operators +(plus, minus, div, times, mod, rangeTo) with their respective infixes. + + \ No newline at end of file diff --git a/idea/resources/intentionDescriptions/ReplaceContainsIntention/after.kt.template b/idea/resources/intentionDescriptions/ReplaceContainsIntention/after.kt.template new file mode 100644 index 00000000000..964602fef81 --- /dev/null +++ b/idea/resources/intentionDescriptions/ReplaceContainsIntention/after.kt.template @@ -0,0 +1 @@ +b in a diff --git a/idea/resources/intentionDescriptions/ReplaceContainsIntention/before.kt.template b/idea/resources/intentionDescriptions/ReplaceContainsIntention/before.kt.template new file mode 100644 index 00000000000..28578de9706 --- /dev/null +++ b/idea/resources/intentionDescriptions/ReplaceContainsIntention/before.kt.template @@ -0,0 +1 @@ +a.contains(b) \ No newline at end of file diff --git a/idea/resources/intentionDescriptions/ReplaceContainsIntention/description.html b/idea/resources/intentionDescriptions/ReplaceContainsIntention/description.html new file mode 100644 index 00000000000..f2fea8dff8d --- /dev/null +++ b/idea/resources/intentionDescriptions/ReplaceContainsIntention/description.html @@ -0,0 +1,5 @@ + + +This intention replaces contains member calls with the in operator. + + diff --git a/idea/resources/intentionDescriptions/ReplaceGetIntention/after.kt.template b/idea/resources/intentionDescriptions/ReplaceGetIntention/after.kt.template new file mode 100644 index 00000000000..6d919b77d89 --- /dev/null +++ b/idea/resources/intentionDescriptions/ReplaceGetIntention/after.kt.template @@ -0,0 +1 @@ +inst[a, b] diff --git a/idea/resources/intentionDescriptions/ReplaceGetIntention/before.kt.template b/idea/resources/intentionDescriptions/ReplaceGetIntention/before.kt.template new file mode 100644 index 00000000000..efa185dc69c --- /dev/null +++ b/idea/resources/intentionDescriptions/ReplaceGetIntention/before.kt.template @@ -0,0 +1 @@ +inst.get(a, b) \ No newline at end of file diff --git a/idea/resources/intentionDescriptions/ReplaceGetIntention/description.html b/idea/resources/intentionDescriptions/ReplaceGetIntention/description.html new file mode 100644 index 00000000000..01c3553bfa2 --- /dev/null +++ b/idea/resources/intentionDescriptions/ReplaceGetIntention/description.html @@ -0,0 +1,5 @@ + + +This intention replaces get member calls with the array index operator ([]). + + \ No newline at end of file diff --git a/idea/resources/intentionDescriptions/ReplaceInvokeIntention/after.kt.template b/idea/resources/intentionDescriptions/ReplaceInvokeIntention/after.kt.template new file mode 100644 index 00000000000..10067646785 --- /dev/null +++ b/idea/resources/intentionDescriptions/ReplaceInvokeIntention/after.kt.template @@ -0,0 +1 @@ +inst(a, b) diff --git a/idea/resources/intentionDescriptions/ReplaceInvokeIntention/before.kt.template b/idea/resources/intentionDescriptions/ReplaceInvokeIntention/before.kt.template new file mode 100644 index 00000000000..9e88c38a428 --- /dev/null +++ b/idea/resources/intentionDescriptions/ReplaceInvokeIntention/before.kt.template @@ -0,0 +1 @@ +inst.invoke(a, b) \ No newline at end of file diff --git a/idea/resources/intentionDescriptions/ReplaceInvokeIntention/description.html b/idea/resources/intentionDescriptions/ReplaceInvokeIntention/description.html new file mode 100644 index 00000000000..2d8f95477f6 --- /dev/null +++ b/idea/resources/intentionDescriptions/ReplaceInvokeIntention/description.html @@ -0,0 +1,5 @@ + + +This intention replaces invoke member calls with a receiver call. + + \ No newline at end of file diff --git a/idea/resources/intentionDescriptions/ReplaceUnaryPrefixIntention/after.kt.template b/idea/resources/intentionDescriptions/ReplaceUnaryPrefixIntention/after.kt.template new file mode 100644 index 00000000000..2b86dd51fc1 --- /dev/null +++ b/idea/resources/intentionDescriptions/ReplaceUnaryPrefixIntention/after.kt.template @@ -0,0 +1,3 @@ +!inst ++inst +-inst \ No newline at end of file diff --git a/idea/resources/intentionDescriptions/ReplaceUnaryPrefixIntention/before.kt.template b/idea/resources/intentionDescriptions/ReplaceUnaryPrefixIntention/before.kt.template new file mode 100644 index 00000000000..0e7d9a3d3b8 --- /dev/null +++ b/idea/resources/intentionDescriptions/ReplaceUnaryPrefixIntention/before.kt.template @@ -0,0 +1,3 @@ +inst.not() +inst.plus() +inst.minus() diff --git a/idea/resources/intentionDescriptions/ReplaceUnaryPrefixIntention/description.html b/idea/resources/intentionDescriptions/ReplaceUnaryPrefixIntention/description.html new file mode 100644 index 00000000000..d8fc9cb5aab --- /dev/null +++ b/idea/resources/intentionDescriptions/ReplaceUnaryPrefixIntention/description.html @@ -0,0 +1,5 @@ + + +This intention replaces prefix member calls (plus, minus, not) with their respective prefixes. + + \ No newline at end of file diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index 40f90fe2009..5de46d65079 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -399,6 +399,31 @@ Kotlin + + org.jetbrains.jet.plugin.intentions.attributeCallReplacements.ReplaceGetIntention + Kotlin + + + + org.jetbrains.jet.plugin.intentions.attributeCallReplacements.ReplaceContainsIntention + Kotlin + + + + org.jetbrains.jet.plugin.intentions.attributeCallReplacements.ReplaceInvokeIntention + Kotlin + + + + org.jetbrains.jet.plugin.intentions.attributeCallReplacements.ReplaceUnaryPrefixIntention + Kotlin + + + + org.jetbrains.jet.plugin.intentions.attributeCallReplacements.ReplaceBinaryInfixIntention + Kotlin + + org.jetbrains.jet.plugin.intentions.branchedTransformations.intentions.FoldIfToReturnAsymmetricallyIntention Kotlin diff --git a/idea/src/org/jetbrains/jet/plugin/JetBundle.properties b/idea/src/org/jetbrains/jet/plugin/JetBundle.properties index 6c91e00d447..b7b0c7186ec 100644 --- a/idea/src/org/jetbrains/jet/plugin/JetBundle.properties +++ b/idea/src/org/jetbrains/jet/plugin/JetBundle.properties @@ -82,6 +82,30 @@ change.signature.family=Change signature of function/constructor cast.expression.to.type=Cast expression ''{0}'' to ''{1}'' cast.expression.family=Cast Expression +replace.call.error.skipped.defaults=Cannot skip default arguments. +replace.call.error.undefined.returntype=Unable to determine the return type. +replace.call.error.duplicate.or.missing.arguments=Duplicate or missing arguments. +replace.call.error.invalid.arguments=Invalid arguments included. + +replace.call.error.vararg.not.last=Cannot handle named arguments after a vararg. +replace.call.error.contains.returns_boolean=Contains must return a Boolean. + +replace.get.with.index=Replace 'get' call with index operator +replace.get.with.index.family=Replace Get + +replace.contains.with.in=Replace 'contains' call with in operator +replace.contains.with.in.family=Replace Contains + +replace.invoke.with.call=Replace 'invoke' with direct call +replace.invoke.with.call.family=Replace Invoke + +replace.unary.operator.with.prefix=Replace with ''{0}'' prefix +replace.unary.operator.with.prefix.family=Replace Unary Operator + +replace.binary.operator.with.infix=Replace with ''{0}'' operator +replace.binary.operator.with.infix.family=Replace Binary Operator + + add.kotlin.signature.action.family.name=Specify Custom Kotlin Signature add.kotlin.signature.action.text=Specify custom Kotlin signature edit.kotlin.signature.action.text=Edit custom Kotlin signature diff --git a/idea/src/org/jetbrains/jet/plugin/intentions/attributeCallReplacements/AttributeCallReplacementIntention.kt b/idea/src/org/jetbrains/jet/plugin/intentions/attributeCallReplacements/AttributeCallReplacementIntention.kt new file mode 100644 index 00000000000..fa74354040d --- /dev/null +++ b/idea/src/org/jetbrains/jet/plugin/intentions/attributeCallReplacements/AttributeCallReplacementIntention.kt @@ -0,0 +1,140 @@ +/* + * 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.attributeCallReplacements + +import org.jetbrains.jet.lang.psi.JetCallExpression +import com.intellij.openapi.editor.Editor +import org.jetbrains.jet.lang.psi.JetQualifiedExpression +import org.jetbrains.jet.lang.psi.JetDotQualifiedExpression +import org.jetbrains.jet.plugin.intentions.JetSelfTargetingIntention +import com.intellij.openapi.ui.popup.JBPopupFactory +import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall +import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache +import org.jetbrains.jet.lang.descriptors.CallableDescriptor +import org.jetbrains.jet.lang.resolve.BindingContext +import org.jetbrains.jet.lang.psi.ValueArgument +import org.jetbrains.jet.plugin.JetBundle +import org.jetbrains.jet.lang.resolve.calls.model.DefaultValueArgument +import org.jetbrains.jet.lang.resolve.calls.model.VarargValueArgument + +abstract class Maybe +public class Value(public val value: V) : Maybe() +public class Error(public val error: E) : Maybe() + +// Internal because you shouldn't construct this manually. You can end up with an inconsistant CallDescription. +public class CallDescription internal ( + public val element: JetQualifiedExpression, + public val callElement: JetCallExpression, + public val resolved: ResolvedCall +) { + public val functionName: String? + get() = callElement.getCalleeExpression()?.getText() + + public val argumentCount: Int + get() = callElement.getValueArguments().size + callElement.getFunctionLiteralArguments().size + + public val hasTypeArguments: Boolean + get() = callElement.getTypeArgumentList() != null + + public val hasEmptyArguments: Boolean + get() = callElement.getValueArguments().any { it?.getArgumentExpression() == null } + + public fun getPositionalArguments(): Maybe, String> { + + val resolvedValueArguments = resolved.getValueArgumentsByIndex() + ?: return Error("duplicate.or.missing.arguments") + + // Check for mixed default and passed arguments and return the passed parameters (or fail) + val indexOfFirstDefaultArgument = resolvedValueArguments.indexOf(DefaultValueArgument.DEFAULT) + val valueArgumentGroups = if (indexOfFirstDefaultArgument >= 0) { + if (resolvedValueArguments.listIterator(indexOfFirstDefaultArgument).any { it != DefaultValueArgument.DEFAULT }) { + return Error("skipped.defaults") + } + resolvedValueArguments.subList(0, indexOfFirstDefaultArgument) + } else { + resolvedValueArguments + } + + // The vararg must be the last (passed) argument + if (valueArgumentGroups.size > 0) { + val vararg = valueArgumentGroups.find { it is VarargValueArgument } + if (vararg != null && vararg != valueArgumentGroups.last) { + return Error("vararg.not.last") + } + } + + val valueArguments = valueArgumentGroups.flatMap { it.getArguments() } + if (valueArguments.size < argumentCount) { + // Only happens if invalid arguments were thrown away. + return Error("invalid.arguments") + } + + return Value(valueArguments) + } +} + +public fun JetQualifiedExpression.toCallDescription(): CallDescription? { + val call = getSelectorExpression() + if (call !is JetCallExpression) return null + + val bindingContext = AnalyzerFacadeWithCache.getContextForElement(call) + // This should work. Nothing that returns a CallableDescriptor returns null and (out T is T) + val resolvedCall = bindingContext[BindingContext.RESOLVED_CALL, call.getCalleeExpression()] ?: + return null + + return CallDescription(this, call, resolvedCall) +} + +public abstract class AttributeCallReplacementIntention(name: String) : JetSelfTargetingIntention(name, javaClass()) { + + protected abstract fun isApplicableToCall(call: CallDescription): Boolean + + protected abstract fun replaceCall(call: CallDescription, editor: Editor): Unit + protected open fun formatArgumentsFor(call: CallDescription): Array = array() + + final override fun isApplicableTo(element: JetDotQualifiedExpression): Boolean { + val callDescription = element.toCallDescription() + if (callDescription != null && isApplicableToCall(callDescription)) { + setText(JetBundle.message(key, *formatArgumentsFor(callDescription))) + return true + } else { + return false + } + } + + final override fun applyTo(element: JetDotQualifiedExpression, editor: Editor) { + // If this doesn't work, something is very wrong (isApplicableTo failed). + replaceCall(element.toCallDescription()!!, editor) + } + + protected open fun intentionFailed(editor: Editor, messageId: String, vararg values: Any?) { + JBPopupFactory.getInstance()!! + .createMessage("Intention Failed: ${JetBundle.message("replace.call.error.${messageId}", *values)}") + .showInBestPositionFor(editor) + } + + protected fun handleErrors(editor: Editor, maybeValue: Maybe): V? { + return when (maybeValue) { + is Value -> maybeValue.value + is Error -> { + intentionFailed(editor, maybeValue.error) + null + } + else -> throw NoWhenBranchMatchedException() + } + } +} diff --git a/idea/src/org/jetbrains/jet/plugin/intentions/attributeCallReplacements/ReplaceBinaryInfixIntention.kt b/idea/src/org/jetbrains/jet/plugin/intentions/attributeCallReplacements/ReplaceBinaryInfixIntention.kt new file mode 100644 index 00000000000..2042e719f26 --- /dev/null +++ b/idea/src/org/jetbrains/jet/plugin/intentions/attributeCallReplacements/ReplaceBinaryInfixIntention.kt @@ -0,0 +1,61 @@ +/* + * 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.attributeCallReplacements + +import com.intellij.openapi.editor.Editor +import org.jetbrains.jet.lang.psi.JetPsiFactory + +public open class ReplaceBinaryInfixIntention : AttributeCallReplacementIntention("replace.binary.operator.with.infix") { + + private fun lookup(name: String?): String? { + return when (name) { + "plus" -> "+" + "minus" -> "-" + "div" -> "/" + "times" -> "*" + "mod" -> "%" + "rangeTo" -> ".." + else -> null + } + } + + override fun formatArgumentsFor(call: CallDescription): Array { + return array(lookup(call.functionName)) + } + + override fun isApplicableToCall(call: CallDescription): Boolean { + return ( + lookup(call.functionName) != null && + call.argumentCount == 1 && + !call.hasTypeArguments && + !call.hasEmptyArguments + ) + } + + override fun replaceCall(call: CallDescription, editor: Editor) { + val argument = (handleErrors(editor, call.getPositionalArguments()) ?: return)[0].getArgumentExpression() + + call.element.replace( + JetPsiFactory.createBinaryExpression( + call.element.getProject(), + call.element.getReceiverExpression(), + lookup(call.functionName)!!, // Lookup must succeed + argument + ) + ) + } +} diff --git a/idea/src/org/jetbrains/jet/plugin/intentions/attributeCallReplacements/ReplaceContainsIntention.kt b/idea/src/org/jetbrains/jet/plugin/intentions/attributeCallReplacements/ReplaceContainsIntention.kt new file mode 100644 index 00000000000..00fd6a0167e --- /dev/null +++ b/idea/src/org/jetbrains/jet/plugin/intentions/attributeCallReplacements/ReplaceContainsIntention.kt @@ -0,0 +1,63 @@ +/* + * 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.attributeCallReplacements + +import org.jetbrains.jet.lang.psi.JetExpression +import org.jetbrains.jet.lexer.JetTokens +import com.intellij.openapi.editor.Editor +import org.jetbrains.jet.lang.types.checker.JetTypeChecker +import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns +import org.jetbrains.jet.lang.psi.JetPsiFactory +import org.jetbrains.jet.lang.psi.JetPsiUtil +import org.jetbrains.jet.lang.psi.JetFunctionLiteralExpression + +public open class ReplaceContainsIntention : AttributeCallReplacementIntention("replace.contains.with.in") { + + override fun isApplicableToCall(call: CallDescription): Boolean { + return call.functionName == "contains" && call.argumentCount == 1 && !call.hasEmptyArguments + } + + override fun replaceCall(call: CallDescription, editor: Editor) { + val ret = call.resolved.getResultingDescriptor().getReturnType() + ?: return intentionFailed(editor, "undefined.returntype") + + if (!JetTypeChecker.INSTANCE.isSubtypeOf(ret, KotlinBuiltIns.getInstance().getBooleanType())) { + return intentionFailed(editor, "contains.returns.boolean") + } + + val argument = (handleErrors(editor, call.getPositionalArguments()) ?: return)[0].getArgumentExpression() + + // Append semicolon to previous statement if needed + if (argument is JetFunctionLiteralExpression) { + val previousElement = JetPsiUtil.skipSiblingsBackwardByPredicate(call.element) { + // I checked, it can't be null. + it!!.getNode()?.getElementType() in JetTokens.WHITE_SPACE_OR_COMMENT_BIT_SET + } + if (previousElement != null && previousElement is JetExpression) { + // If the parent is null, something is very wrong. + previousElement.getParent()!!.addAfter(JetPsiFactory.createSemicolon(call.element.getProject()), previousElement) + } + } + + call.element.replace(JetPsiFactory.createBinaryExpression( + call.element.getProject(), + argument, + "in", + call.element.getReceiverExpression() + )) + } +} diff --git a/idea/src/org/jetbrains/jet/plugin/intentions/attributeCallReplacements/ReplaceGetIntention.kt b/idea/src/org/jetbrains/jet/plugin/intentions/attributeCallReplacements/ReplaceGetIntention.kt new file mode 100644 index 00000000000..d08a1f9c30f --- /dev/null +++ b/idea/src/org/jetbrains/jet/plugin/intentions/attributeCallReplacements/ReplaceGetIntention.kt @@ -0,0 +1,37 @@ +/* + * Copyright 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.attributeCallReplacements + +import com.intellij.openapi.editor.Editor +import org.jetbrains.jet.lang.psi.JetPsiFactory + +public open class ReplaceGetIntention : AttributeCallReplacementIntention("replace.get.with.index") { + + override fun isApplicableToCall(call: CallDescription): Boolean { + return (call.functionName == "get" && !call.hasTypeArguments && call.argumentCount > 0) + } + + override fun replaceCall(call: CallDescription, editor: Editor) { + val argumentString = (handleErrors(editor, call.getPositionalArguments()) ?: return).map { + it.getArgumentExpression()?.getText() ?: "" + }.makeString(", ") + + call.element.replace(JetPsiFactory.createExpression( + call.element.getProject(), + "${call.element.getReceiverExpression().getText()}[${argumentString}]" + )) + } +} diff --git a/idea/src/org/jetbrains/jet/plugin/intentions/attributeCallReplacements/ReplaceInvokeIntention.kt b/idea/src/org/jetbrains/jet/plugin/intentions/attributeCallReplacements/ReplaceInvokeIntention.kt new file mode 100644 index 00000000000..269419be122 --- /dev/null +++ b/idea/src/org/jetbrains/jet/plugin/intentions/attributeCallReplacements/ReplaceInvokeIntention.kt @@ -0,0 +1,37 @@ +/* + * 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.attributeCallReplacements + +import com.intellij.openapi.editor.Editor +import org.jetbrains.jet.lang.psi.JetPsiFactory + +public open class ReplaceInvokeIntention : AttributeCallReplacementIntention("replace.invoke.with.call") { + + override fun isApplicableToCall(call: CallDescription): Boolean { + return call.functionName == "invoke" + } + + override fun replaceCall(call: CallDescription, editor: Editor) { + call.element.replace(JetPsiFactory.createExpression( + call.element.getProject(), + call.element.getReceiverExpression().getText() + + (call.callElement.getTypeArgumentList()?.getText() ?: "") + + (call.callElement.getValueArgumentList()?.getText() ?: "") + + (call.callElement.getFunctionLiteralArguments().fold("") { a, b -> a + " " + b.getText() }) + )) + } +} diff --git a/idea/src/org/jetbrains/jet/plugin/intentions/attributeCallReplacements/ReplaceUnaryPrefixIntention.kt b/idea/src/org/jetbrains/jet/plugin/intentions/attributeCallReplacements/ReplaceUnaryPrefixIntention.kt new file mode 100644 index 00000000000..24dbd159d04 --- /dev/null +++ b/idea/src/org/jetbrains/jet/plugin/intentions/attributeCallReplacements/ReplaceUnaryPrefixIntention.kt @@ -0,0 +1,52 @@ +/* + * 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.attributeCallReplacements + +import com.intellij.openapi.editor.Editor +import org.jetbrains.jet.lang.psi.JetPsiFactory + +public open class ReplaceUnaryPrefixIntention : AttributeCallReplacementIntention("replace.unary.operator.with.prefix") { + + private fun lookup(name: String?) : String? { + return when (name) { + "plus" -> "+" + "minus" -> "-" + "not" -> "!" + else -> null + } + } + + override fun formatArgumentsFor(call: CallDescription): Array { + return array(lookup(call.functionName)) + } + + override fun isApplicableToCall(call: CallDescription): Boolean { + return ( + lookup(call.functionName) != null && + !call.hasTypeArguments && + call.argumentCount == 0 && + call.callElement.getValueArgumentList() != null // Has argument expression + ) + } + + override fun replaceCall(call: CallDescription, editor: Editor) { + call.element.replace(JetPsiFactory.createExpression( + call.element.getProject(), + lookup(call.functionName)!! + call.element.getReceiverExpression().getText() + )) + } +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/acceptableVararg1.kt b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/acceptableVararg1.kt new file mode 100644 index 00000000000..2f8bbef6a5d --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/acceptableVararg1.kt @@ -0,0 +1,7 @@ +fun test() { + class Test{ + fun plus(a: Int, vararg b: Int, c: Int = 0) : Int = 0 + } + val test = Test() + test.plus(1) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/acceptableVararg1.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/acceptableVararg1.kt.after new file mode 100644 index 00000000000..a1527122241 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/acceptableVararg1.kt.after @@ -0,0 +1,7 @@ +fun test() { + class Test{ + fun plus(a: Int, vararg b: Int, c: Int = 0) : Int = 0 + } + val test = Test() + test + 1 +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/acceptableVararg2.kt b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/acceptableVararg2.kt new file mode 100644 index 00000000000..78fad62961b --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/acceptableVararg2.kt @@ -0,0 +1,7 @@ +fun test() { + class Test{ + fun plus(vararg b: Int, c: Int = 0) : Int = 0 + } + val test = Test() + test.plus(1) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/acceptableVararg2.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/acceptableVararg2.kt.after new file mode 100644 index 00000000000..3b285907bd0 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/acceptableVararg2.kt.after @@ -0,0 +1,7 @@ +fun test() { + class Test{ + fun plus(vararg b: Int, c: Int = 0) : Int = 0 + } + val test = Test() + test + 1 +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/allowableDefaultArgument.kt b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/allowableDefaultArgument.kt new file mode 100644 index 00000000000..e9477012e61 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/allowableDefaultArgument.kt @@ -0,0 +1,7 @@ +fun test() { + class Test { + fun plus(a: Int, b: Int=5): Test = Test() + } + val test = Test() + test.plus(1) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/allowableDefaultArgument.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/allowableDefaultArgument.kt.after new file mode 100644 index 00000000000..aaf86a1162b --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/allowableDefaultArgument.kt.after @@ -0,0 +1,7 @@ +fun test() { + class Test { + fun plus(a: Int, b: Int=5): Test = Test() + } + val test = Test() + test + 1 +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/divSanityTest.kt b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/divSanityTest.kt new file mode 100644 index 00000000000..4ab1612f44e --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/divSanityTest.kt @@ -0,0 +1,8 @@ +// INTENTION_TEXT: Replace with '/' operator +fun test() { + class Test { + fun div(a: Int): Test = Test() + } + val test = Test() + test.div(1) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/divSanityTest.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/divSanityTest.kt.after new file mode 100644 index 00000000000..f3827a65410 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/divSanityTest.kt.after @@ -0,0 +1,8 @@ +// INTENTION_TEXT: Replace with '/' operator +fun test() { + class Test { + fun div(a: Int): Test = Test() + } + val test = Test() + test / 1 +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/extensionFunction.kt b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/extensionFunction.kt new file mode 100644 index 00000000000..16dd8dd1e63 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/extensionFunction.kt @@ -0,0 +1,6 @@ +fun test() { + class Test() + fun Test.div(a: Int): Test = Test() + val test = Test() + test.div(1) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/extensionFunction.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/extensionFunction.kt.after new file mode 100644 index 00000000000..3ac14ad2616 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/extensionFunction.kt.after @@ -0,0 +1,6 @@ +fun test() { + class Test() + fun Test.div(a: Int): Test = Test() + val test = Test() + test / 1 +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/functionLiteralArgument.kt b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/functionLiteralArgument.kt new file mode 100644 index 00000000000..b71bdcb781c --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/functionLiteralArgument.kt @@ -0,0 +1,9 @@ +fun test() { + class Test { + fun plus(fn: () -> Test): Test = fn() + } + val test = Test() + test.plus { + Test() + } +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/functionLiteralArgument.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/functionLiteralArgument.kt.after new file mode 100644 index 00000000000..1fef919ee52 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/functionLiteralArgument.kt.after @@ -0,0 +1,9 @@ +fun test() { + class Test { + fun plus(fn: () -> Test): Test = fn() + } + val test = Test() + test + { + Test() + } +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/minusSanityTest.kt b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/minusSanityTest.kt new file mode 100644 index 00000000000..fc6d757e70f --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/minusSanityTest.kt @@ -0,0 +1,8 @@ +// INTENTION_TEXT: Replace with '-' operator +fun test() { + class Test { + fun minus(a: Int): Test = Test() + } + val test = Test() + test.minus(1) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/minusSanityTest.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/minusSanityTest.kt.after new file mode 100644 index 00000000000..8d593dc7e80 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/minusSanityTest.kt.after @@ -0,0 +1,8 @@ +// INTENTION_TEXT: Replace with '-' operator +fun test() { + class Test { + fun minus(a: Int): Test = Test() + } + val test = Test() + test - 1 +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/missingDefaultArgument.kt b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/missingDefaultArgument.kt new file mode 100644 index 00000000000..208a6934658 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/missingDefaultArgument.kt @@ -0,0 +1,8 @@ +// SHOULD_FAIL_WITH: skipped.defaults +fun test() { + class Test{ + fun plus(a: Int=1, b: Int=2) : Int = 0 + } + val test = Test() + test.plus(b=3) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/modSanityTest.kt b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/modSanityTest.kt new file mode 100644 index 00000000000..c531db902cf --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/modSanityTest.kt @@ -0,0 +1,8 @@ +// INTENTION_TEXT: Replace with '%' operator +fun test() { + class Test { + fun mod(a: Int): Test = Test() + } + val test = Test() + test.mod(1) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/modSanityTest.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/modSanityTest.kt.after new file mode 100644 index 00000000000..5fd7dd42afc --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/modSanityTest.kt.after @@ -0,0 +1,8 @@ +// INTENTION_TEXT: Replace with '%' operator +fun test() { + class Test { + fun mod(a: Int): Test = Test() + } + val test = Test() + test % 1 +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/multipleArguments.kt b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/multipleArguments.kt new file mode 100644 index 00000000000..070a857b3ad --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/multipleArguments.kt @@ -0,0 +1,8 @@ +// IS_APPLICABLE: false +fun test() { + class Test { + fun plus(a: Int, b: Int): Test = Test() + } + val test = Test() + test.plus(1, 2) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/plusSanityTest.kt b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/plusSanityTest.kt new file mode 100644 index 00000000000..4e30ee94c65 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/plusSanityTest.kt @@ -0,0 +1,8 @@ +// INTENTION_TEXT: Replace with '+' operator +fun test() { + class Test { + fun plus(a: Int): Test = Test() + } + val test = Test() + test.plus(1) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/plusSanityTest.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/plusSanityTest.kt.after new file mode 100644 index 00000000000..c556279caf8 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/plusSanityTest.kt.after @@ -0,0 +1,8 @@ +// INTENTION_TEXT: Replace with '+' operator +fun test() { + class Test { + fun plus(a: Int): Test = Test() + } + val test = Test() + test + 1 +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/rangeToSanityTest.kt b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/rangeToSanityTest.kt new file mode 100644 index 00000000000..f9fc60a4103 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/rangeToSanityTest.kt @@ -0,0 +1,8 @@ +// INTENTION_TEXT: Replace with '..' operator +fun test() { + class Test { + fun rangeTo(a: Int): Test = Test() + } + val test = Test() + test.rangeTo(1) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/rangeToSanityTest.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/rangeToSanityTest.kt.after new file mode 100644 index 00000000000..d4ac64901e1 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/rangeToSanityTest.kt.after @@ -0,0 +1,8 @@ +// INTENTION_TEXT: Replace with '..' operator +fun test() { + class Test { + fun rangeTo(a: Int): Test = Test() + } + val test = Test() + test..1 +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/timesSanityTest.kt b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/timesSanityTest.kt new file mode 100644 index 00000000000..b8240982a9d --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/timesSanityTest.kt @@ -0,0 +1,8 @@ +// INTENTION_TEXT: Replace with '*' operator +fun test() { + class Test { + fun times(a: Int): Test = Test() + } + val test = Test() + test.times(1) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/timesSanityTest.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/timesSanityTest.kt.after new file mode 100644 index 00000000000..914632b2fbb --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/timesSanityTest.kt.after @@ -0,0 +1,8 @@ +// INTENTION_TEXT: Replace with '*' operator +fun test() { + class Test { + fun times(a: Int): Test = Test() + } + val test = Test() + test * 1 +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/typeArguments.kt b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/typeArguments.kt new file mode 100644 index 00000000000..c13036ac392 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/typeArguments.kt @@ -0,0 +1,8 @@ +// IS_APPLICABLE: false +fun test() { + class Test { + fun div(a: Test): T? = a as? T + } + val test = Test() + test.div(Test()) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/unacceptableVararg1.kt b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/unacceptableVararg1.kt new file mode 100644 index 00000000000..eacd3ae2b63 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/unacceptableVararg1.kt @@ -0,0 +1,8 @@ +// SHOULD_FAIL_WITH: vararg.not.last +fun test() { + class Test{ + fun plus(vararg b: Int, c: Int = 0): Int = 0 + } + val test = Test() + test.plus(c=5) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/unacceptableVararg2.kt b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/unacceptableVararg2.kt new file mode 100644 index 00000000000..87c1c386c3c --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/unacceptableVararg2.kt @@ -0,0 +1,8 @@ +// IS_APPLICABLE: false +fun test() { + class Test{ + fun plus(vararg b: Int, c: Int = 0): Int = 0 + } + val test = Test() + test.plus(0, 1) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/validNamedArgument.kt b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/validNamedArgument.kt new file mode 100644 index 00000000000..df8bed7ddde --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/validNamedArgument.kt @@ -0,0 +1,7 @@ +fun test() { + class Test { + fun plus(a: Int): Test = Test() + } + val test = Test() + test.plus(a=1) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/validNamedArgument.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/validNamedArgument.kt.after new file mode 100644 index 00000000000..04d84b939c6 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/validNamedArgument.kt.after @@ -0,0 +1,7 @@ +fun test() { + class Test { + fun plus(a: Int): Test = Test() + } + val test = Test() + test + 1 +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/acceptableVararg.kt b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/acceptableVararg.kt new file mode 100644 index 00000000000..3860aa08980 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/acceptableVararg.kt @@ -0,0 +1,7 @@ +fun test() { + class Test{ + fun contains(vararg a: Int, b: Int = 0): Boolean = true + } + val test = Test() + test.contains(1) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/acceptableVararg.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/acceptableVararg.kt.after new file mode 100644 index 00000000000..4182c82208c --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/acceptableVararg.kt.after @@ -0,0 +1,7 @@ +fun test() { + class Test{ + fun contains(vararg a: Int, b: Int = 0): Boolean = true + } + val test = Test() + 1 in test +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/acceptableVararg2.kt b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/acceptableVararg2.kt new file mode 100644 index 00000000000..a175d4ec7ae --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/acceptableVararg2.kt @@ -0,0 +1,7 @@ +fun test() { + class Test{ + fun contains(c: Int, vararg a: Int, b: Int = 0): Boolean = true + } + val test = Test() + test.contains(1) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/acceptableVararg2.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/acceptableVararg2.kt.after new file mode 100644 index 00000000000..a25a8616aa3 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/acceptableVararg2.kt.after @@ -0,0 +1,7 @@ +fun test() { + class Test{ + fun contains(c: Int, vararg a: Int, b: Int = 0): Boolean = true + } + val test = Test() + 1 in test +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/allowableDefaultArgument.kt b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/allowableDefaultArgument.kt new file mode 100644 index 00000000000..e7df2cb8f22 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/allowableDefaultArgument.kt @@ -0,0 +1,7 @@ +fun test() { + class Test{ + fun contains(a: Int, b: Int=5) : Boolean = true + } + val test = Test() + test.contains(1) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/allowableDefaultArgument.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/allowableDefaultArgument.kt.after new file mode 100644 index 00000000000..7a0d8c073d0 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/allowableDefaultArgument.kt.after @@ -0,0 +1,7 @@ +fun test() { + class Test{ + fun contains(a: Int, b: Int=5) : Boolean = true + } + val test = Test() + 1 in test +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/containsInExpression.kt b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/containsInExpression.kt new file mode 100644 index 00000000000..386acdbbd54 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/containsInExpression.kt @@ -0,0 +1,7 @@ +fun test() { + class Test{ + fun contains(a: Int) : Boolean = true + } + val test = Test() + println(test.contains(0).toString()) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/containsInExpression.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/containsInExpression.kt.after new file mode 100644 index 00000000000..fc03bcb1f4a --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/containsInExpression.kt.after @@ -0,0 +1,7 @@ +fun test() { + class Test{ + fun contains(a: Int) : Boolean = true + } + val test = Test() + println((0 in test).toString()) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/extensionFunction.kt b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/extensionFunction.kt new file mode 100644 index 00000000000..9825f3e1786 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/extensionFunction.kt @@ -0,0 +1,6 @@ +fun test() { + class Test() + fun Test.contains(a: Int) : Boolean = true + val test = Test() + test.contains(1) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/extensionFunction.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/extensionFunction.kt.after new file mode 100644 index 00000000000..8d5b91e3e3f --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/extensionFunction.kt.after @@ -0,0 +1,6 @@ +fun test() { + class Test() + fun Test.contains(a: Int) : Boolean = true + val test = Test() + 1 in test +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgument.kt b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgument.kt new file mode 100644 index 00000000000..407469cd411 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgument.kt @@ -0,0 +1,9 @@ +fun test() { + class Test{ + fun contains(fn: () -> Boolean) : Boolean = true + } + val test = Test() + test.contains { + true + } +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgument.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgument.kt.after new file mode 100644 index 00000000000..438c31eb857 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgument.kt.after @@ -0,0 +1,9 @@ +fun test() { + class Test{ + fun contains(fn: () -> Boolean) : Boolean = true + } + val test = Test(); + { + true + } in test +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgumentAfterSemicolon.kt b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgumentAfterSemicolon.kt new file mode 100644 index 00000000000..2a64e1e5e1a --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgumentAfterSemicolon.kt @@ -0,0 +1,9 @@ +fun test() { + class Test{ + fun contains(fn: () -> Boolean) : Boolean = true + } + val test = Test(); + test.contains { + true + } +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgumentAfterSemicolon.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgumentAfterSemicolon.kt.after new file mode 100644 index 00000000000..438c31eb857 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgumentAfterSemicolon.kt.after @@ -0,0 +1,9 @@ +fun test() { + class Test{ + fun contains(fn: () -> Boolean) : Boolean = true + } + val test = Test(); + { + true + } in test +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgumentAtStartOfBlock.kt b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgumentAtStartOfBlock.kt new file mode 100644 index 00000000000..e4723fdd7d8 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgumentAtStartOfBlock.kt @@ -0,0 +1,11 @@ +fun test() { + class Test{ + fun contains(fn: () -> Boolean) : Boolean = true + } + val test = Test() + if (true) { + test.contains { + true + } + } +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgumentAtStartOfBlock.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgumentAtStartOfBlock.kt.after new file mode 100644 index 00000000000..4e441ba8f23 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgumentAtStartOfBlock.kt.after @@ -0,0 +1,11 @@ +fun test() { + class Test{ + fun contains(fn: () -> Boolean) : Boolean = true + } + val test = Test() + if (true) { + { + true + } in test + } +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgumentInExpression.kt b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgumentInExpression.kt new file mode 100644 index 00000000000..dd0246a2835 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgumentInExpression.kt @@ -0,0 +1,7 @@ +fun test() { + class Test{ + fun contains(fn: () -> Boolean) : Boolean = true + } + val test = Test() + println(test.contains { true }.toString()) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgumentInExpression.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgumentInExpression.kt.after new file mode 100644 index 00000000000..9821d11aac7 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgumentInExpression.kt.after @@ -0,0 +1,7 @@ +fun test() { + class Test{ + fun contains(fn: () -> Boolean) : Boolean = true + } + val test = Test() + println(({ true } in test).toString()) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/invalidArgument.kt b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/invalidArgument.kt new file mode 100644 index 00000000000..c0e75af8254 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/invalidArgument.kt @@ -0,0 +1,8 @@ +// SHOULD_FAIL_WITH: invalid.arguments +fun test() { + class Test{ + fun contains(a: Int=1, b: Int=2): Boolean = true + } + val test = Test() + test.contains(c=3) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/missingArgument.kt b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/missingArgument.kt new file mode 100644 index 00000000000..813116eb6c4 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/missingArgument.kt @@ -0,0 +1,8 @@ +// SHOULD_FAIL_WITH: duplicate.or.missing.arguments +fun test() { + class Test{ + fun contains(a: Int, b: Int): Boolean = true + } + val test = Test() + test.contains(0) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/missingDefaultArgument.kt b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/missingDefaultArgument.kt new file mode 100644 index 00000000000..f832a3252ca --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/missingDefaultArgument.kt @@ -0,0 +1,8 @@ +// SHOULD_FAIL_WITH: skipped.defaults +fun test() { + class Test{ + fun contains(a: Int=1, b: Int=2) : Boolean = true + } + val test = Test() + test.contains(b=3) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/multipleArguments.kt b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/multipleArguments.kt new file mode 100644 index 00000000000..cc35f22faa7 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/multipleArguments.kt @@ -0,0 +1,8 @@ +// IS_APPLICABLE: false +fun test() { + class Test{ + fun contains(a: Int, b: Int) : Boolean = true + } + val test = Test() + test.contains(1, 2) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/simpleArgument.kt b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/simpleArgument.kt new file mode 100644 index 00000000000..65035e5d579 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/simpleArgument.kt @@ -0,0 +1,7 @@ +fun test() { + class Test{ + fun contains(a: Int) : Boolean = true + } + val test = Test() + test.contains(1) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/simpleArgument.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/simpleArgument.kt.after new file mode 100644 index 00000000000..edafd552176 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/simpleArgument.kt.after @@ -0,0 +1,7 @@ +fun test() { + class Test{ + fun contains(a: Int) : Boolean = true + } + val test = Test() + 1 in test +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/typeArguments.kt b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/typeArguments.kt new file mode 100644 index 00000000000..39f74eb1e4a --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/typeArguments.kt @@ -0,0 +1,7 @@ +fun test() { + class Test{ + fun contains(a: T): Boolean = false + } + val test = Test() + test.contains(1) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/typeArguments.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/typeArguments.kt.after new file mode 100644 index 00000000000..4828a41496d --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/typeArguments.kt.after @@ -0,0 +1,7 @@ +fun test() { + class Test{ + fun contains(a: T): Boolean = false + } + val test = Test() + 1 in test +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/unacceptableVararg1.kt b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/unacceptableVararg1.kt new file mode 100644 index 00000000000..28f06c033ab --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/unacceptableVararg1.kt @@ -0,0 +1,8 @@ +// SHOULD_FAIL_WITH: vararg.not.last +fun test() { + class Test{ + fun contains(vararg b: Int, c: Int = 0): Boolean = true + } + val test = Test() + test.contains(c=5) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/unacceptableVararg2.kt b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/unacceptableVararg2.kt new file mode 100644 index 00000000000..b16a21fcd17 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/unacceptableVararg2.kt @@ -0,0 +1,8 @@ +// IS_APPLICABLE: false +fun test() { + class Test{ + fun contains(vararg b: Int, c: Int = 0): Boolean = true + } + val test = Test() + test.contains(0, 1) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/validNamedArgument.kt b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/validNamedArgument.kt new file mode 100644 index 00000000000..e786019c960 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/validNamedArgument.kt @@ -0,0 +1,7 @@ +fun test() { + class Test{ + fun contains(a: Int=1, b: Int=2) : Boolean = true + } + val test = Test() + test.contains(a=5) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/validNamedArgument.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/validNamedArgument.kt.after new file mode 100644 index 00000000000..e4fc2da176b --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/validNamedArgument.kt.after @@ -0,0 +1,7 @@ +fun test() { + class Test{ + fun contains(a: Int=1, b: Int=2) : Boolean = true + } + val test = Test() + 5 in test +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/acceptableVararg.kt b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/acceptableVararg.kt new file mode 100644 index 00000000000..35c83c86a1a --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/acceptableVararg.kt @@ -0,0 +1,7 @@ +fun test() { + class Test{ + fun get(a: Int, vararg b: Int, c: Int = 0) : Int = 0 + } + val test = Test() + test.get(1, 3, 4, 5) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/acceptableVararg.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/acceptableVararg.kt.after new file mode 100644 index 00000000000..88114b5dab1 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/acceptableVararg.kt.after @@ -0,0 +1,7 @@ +fun test() { + class Test{ + fun get(a: Int, vararg b: Int, c: Int = 0) : Int = 0 + } + val test = Test() + test[1, 3, 4, 5] +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/argumentAndFunction.kt b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/argumentAndFunction.kt new file mode 100644 index 00000000000..a7ee2926496 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/argumentAndFunction.kt @@ -0,0 +1,9 @@ +fun test() { + class Test{ + fun get(a: Int, b: Int, fn: (i: Int) -> Int) : Int = 0 + } + val test = Test() + test.get(1, 2) { i -> + i + } +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/argumentAndFunction.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/argumentAndFunction.kt.after new file mode 100644 index 00000000000..3cb47e780b8 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/argumentAndFunction.kt.after @@ -0,0 +1,9 @@ +fun test() { + class Test{ + fun get(a: Int, b: Int, fn: (i: Int) -> Int) : Int = 0 + } + val test = Test() + test[1, 2, { i -> + i + }] +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/duplicateArguments.kt b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/duplicateArguments.kt new file mode 100644 index 00000000000..88cd7d9548d --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/duplicateArguments.kt @@ -0,0 +1,8 @@ +// SHOULD_FAIL_WITH: duplicate.or.missing.arguments +fun test() { + class Test{ + fun get(a: Int, b: Int) : Int = 0 + } + val test = Test() + test.get(a=0, a=1) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/extensionFunction.kt b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/extensionFunction.kt new file mode 100644 index 00000000000..8469dfa916e --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/extensionFunction.kt @@ -0,0 +1,7 @@ +fun test() { + class Test() + + fun Test.get(i: Int) : Int = 0 + val test = Test() + test.get(0) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/extensionFunction.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/extensionFunction.kt.after new file mode 100644 index 00000000000..c2829f5fe6a --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/extensionFunction.kt.after @@ -0,0 +1,7 @@ +fun test() { + class Test() + + fun Test.get(i: Int) : Int = 0 + val test = Test() + test[0] +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/functionalArgument.kt b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/functionalArgument.kt new file mode 100644 index 00000000000..3851f263ee9 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/functionalArgument.kt @@ -0,0 +1,9 @@ +fun test() { + class Test{ + fun get(fn: (i: Int) -> Int) : Int = 0 + } + val test = Test() + test.get() { i -> + i + } +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/functionalArgument.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/functionalArgument.kt.after new file mode 100644 index 00000000000..eb9b727bd88 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/functionalArgument.kt.after @@ -0,0 +1,9 @@ +fun test() { + class Test{ + fun get(fn: (i: Int) -> Int) : Int = 0 + } + val test = Test() + test[{ i -> + i + }] +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/invalidArgument.kt b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/invalidArgument.kt new file mode 100644 index 00000000000..244d2540616 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/invalidArgument.kt @@ -0,0 +1,8 @@ +// SHOULD_FAIL_WITH: invalid.arguments +fun test() { + class Test{ + fun get(a: Int=1, b: Int=2) : Int = 0 + } + val test = Test() + test.get(c=3) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/missingArgument.kt b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/missingArgument.kt new file mode 100644 index 00000000000..d9785c2f6a6 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/missingArgument.kt @@ -0,0 +1,8 @@ +// SHOULD_FAIL_WITH: duplicate.or.missing.arguments +fun test() { + class Test{ + fun get(a: Int, b: Int) : Int = 0 + } + val test = Test() + test.get(0) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/missingDefaultArgument.kt b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/missingDefaultArgument.kt new file mode 100644 index 00000000000..380f44662b4 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/missingDefaultArgument.kt @@ -0,0 +1,8 @@ +// SHOULD_FAIL_WITH: skipped.defaults +fun test() { + class Test{ + fun get(a: Int=1, b: Int=2) : Int = 0 + } + val test = Test() + test.get(b=3) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/multiArgument.kt b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/multiArgument.kt new file mode 100644 index 00000000000..5c4b2959191 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/multiArgument.kt @@ -0,0 +1,7 @@ +fun test() { + class Test{ + fun get(a: Int, b: Int) : Int = 0 + } + val test = Test() + test.get(1, 2) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/multiArgument.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/multiArgument.kt.after new file mode 100644 index 00000000000..5eb89b0a1c9 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/multiArgument.kt.after @@ -0,0 +1,7 @@ +fun test() { + class Test{ + fun get(a: Int, b: Int) : Int = 0 + } + val test = Test() + test[1, 2] +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/namedAndFunction.kt b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/namedAndFunction.kt new file mode 100644 index 00000000000..f3f91ae35f7 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/namedAndFunction.kt @@ -0,0 +1,9 @@ +fun test() { + class Test{ + fun get(a: Int, b: Int, c: Int = 1, d: Int = 1 fn: (i: Int) -> Int) : Int = 0 + } + val test = Test() + test.get(1, c=3, b=2) { i -> + i + } +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/namedAndFunction.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/namedAndFunction.kt.after new file mode 100644 index 00000000000..4adac0b69f2 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/namedAndFunction.kt.after @@ -0,0 +1,9 @@ +fun test() { + class Test{ + fun get(a: Int, b: Int, c: Int = 1, d: Int = 1 fn: (i: Int) -> Int) : Int = 0 + } + val test = Test() + test[1, 2, 3, { i -> + i + }] +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/noArgument.kt b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/noArgument.kt new file mode 100644 index 00000000000..aaf20659585 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/noArgument.kt @@ -0,0 +1,8 @@ +// IS_APPLICABLE: false +fun test() { + class Test{ + fun get() : Int = 0 + } + val test = Test() + test.get() +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/sanityCheck.kt b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/sanityCheck.kt new file mode 100644 index 00000000000..299d8f3814c --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/sanityCheck.kt @@ -0,0 +1,8 @@ +// IS_APPLICABLE: false +fun test() { + class Test{ + fun get(i: Int) : Int = 0 + } + val test = Test() + test.got(0) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/singleArgument.kt b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/singleArgument.kt new file mode 100644 index 00000000000..4037a712af3 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/singleArgument.kt @@ -0,0 +1,7 @@ +fun test() { + class Test{ + fun get(i: Int) : Int = 0 + } + val test = Test() + test.get(0) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/singleArgument.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/singleArgument.kt.after new file mode 100644 index 00000000000..fdc57ef9fbf --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/singleArgument.kt.after @@ -0,0 +1,7 @@ +fun test() { + class Test{ + fun get(i: Int) : Int = 0 + } + val test = Test() + test[0] +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/singleNamedArgument.kt b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/singleNamedArgument.kt new file mode 100644 index 00000000000..d9053a2d5e6 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/singleNamedArgument.kt @@ -0,0 +1,7 @@ +fun test() { + class Test{ + fun get(a: Int) : Int = 0 + } + val test = Test() + test.get(a=1) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/singleNamedArgument.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/singleNamedArgument.kt.after new file mode 100644 index 00000000000..2af31855c25 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/singleNamedArgument.kt.after @@ -0,0 +1,7 @@ +fun test() { + class Test{ + fun get(a: Int) : Int = 0 + } + val test = Test() + test[1] +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/unacceptableVararg.kt b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/unacceptableVararg.kt new file mode 100644 index 00000000000..9934d4c2f15 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/unacceptableVararg.kt @@ -0,0 +1,8 @@ +// SHOULD_FAIL_WITH: vararg.not.last +fun test() { + class Test{ + fun get(a: Int, vararg b: Int, c: Int = 0) : Int = 0 + } + val test = Test() + test.get(1, 3, 4, c=5) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/unnamedAndNamed.kt b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/unnamedAndNamed.kt new file mode 100644 index 00000000000..15ff47bc460 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/unnamedAndNamed.kt @@ -0,0 +1,7 @@ +fun test() { + class Test{ + fun get(a: Int = 0, b: Int = 1, c: Int = 2, d: Int = 3) : Int = 0 + } + val test = Test() + test.get(1, c=3, b=2) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/unnamedAndNamed.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/unnamedAndNamed.kt.after new file mode 100644 index 00000000000..24494f9a21a --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceGetIntention/unnamedAndNamed.kt.after @@ -0,0 +1,7 @@ +fun test() { + class Test{ + fun get(a: Int = 0, b: Int = 1, c: Int = 2, d: Int = 3) : Int = 0 + } + val test = Test() + test[1, 2, 3] +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/extensionFunction.kt b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/extensionFunction.kt new file mode 100644 index 00000000000..28bc6e83874 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/extensionFunction.kt @@ -0,0 +1,8 @@ +fun test() { + class Test() + + fun Test.invoke(): Unit = Unit.VALUE + + val test = Test() + test.invoke() +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/extensionFunction.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/extensionFunction.kt.after new file mode 100644 index 00000000000..185e12cad3d --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/extensionFunction.kt.after @@ -0,0 +1,8 @@ +fun test() { + class Test() + + fun Test.invoke(): Unit = Unit.VALUE + + val test = Test() + test() +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/functionLiteralInvoke.kt b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/functionLiteralInvoke.kt new file mode 100644 index 00000000000..9da6577f5e6 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/functionLiteralInvoke.kt @@ -0,0 +1,9 @@ +fun test() { + class Test { + fun invoke(fn: () -> Unit) {} + } + val test = Test() + test.invoke { + + } +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/functionLiteralInvoke.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/functionLiteralInvoke.kt.after new file mode 100644 index 00000000000..1f0edb533f1 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/functionLiteralInvoke.kt.after @@ -0,0 +1,9 @@ +fun test() { + class Test { + fun invoke(fn: () -> Unit) {} + } + val test = Test() + test { + + } +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/invokeInExpression.kt b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/invokeInExpression.kt new file mode 100644 index 00000000000..4be86600219 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/invokeInExpression.kt @@ -0,0 +1,7 @@ +fun test() { + class Test { + fun invoke(a: Int, vararg b: String, fn: () -> Unit): String = "test" + } + val test = Test() + println(test.invoke(1, "a", "b") { }) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/invokeInExpression.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/invokeInExpression.kt.after new file mode 100644 index 00000000000..8385d874977 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/invokeInExpression.kt.after @@ -0,0 +1,7 @@ +fun test() { + class Test { + fun invoke(a: Int, vararg b: String, fn: () -> Unit): String = "test" + } + val test = Test() + println(test(1, "a", "b") { }) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/namedArgumentInvoke.kt b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/namedArgumentInvoke.kt new file mode 100644 index 00000000000..9ee3bb06493 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/namedArgumentInvoke.kt @@ -0,0 +1,7 @@ +fun test() { + class Test { + fun invoke(a: Int, b: String) {} + } + val test = Test() + test.invoke(b = "s", a = 1) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/namedArgumentInvoke.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/namedArgumentInvoke.kt.after new file mode 100644 index 00000000000..1f17340167a --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/namedArgumentInvoke.kt.after @@ -0,0 +1,7 @@ +fun test() { + class Test { + fun invoke(a: Int, b: String) {} + } + val test = Test() + test(b = "s", a = 1) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/noArgumentInvoke.kt b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/noArgumentInvoke.kt new file mode 100644 index 00000000000..c8c0e864b24 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/noArgumentInvoke.kt @@ -0,0 +1,7 @@ +fun test() { + class Test { + fun invoke() {} + } + val test = Test() + test.invoke() +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/noArgumentInvoke.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/noArgumentInvoke.kt.after new file mode 100644 index 00000000000..3e9df5c9e02 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/noArgumentInvoke.kt.after @@ -0,0 +1,7 @@ +fun test() { + class Test { + fun invoke() {} + } + val test = Test() + test() +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/typeAndValueArgument.kt b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/typeAndValueArgument.kt new file mode 100644 index 00000000000..63e08dd9212 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/typeAndValueArgument.kt @@ -0,0 +1,7 @@ +fun test() { + class Test { + fun invoke(a: Int) {} + } + val test = Test() + test.invoke(0) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/typeAndValueArgument.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/typeAndValueArgument.kt.after new file mode 100644 index 00000000000..113d946fbff --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/typeAndValueArgument.kt.after @@ -0,0 +1,7 @@ +fun test() { + class Test { + fun invoke(a: Int) {} + } + val test = Test() + test(0) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/typeArgumentAndFunctionLiteral.kt b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/typeArgumentAndFunctionLiteral.kt new file mode 100644 index 00000000000..9df69867bd0 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/typeArgumentAndFunctionLiteral.kt @@ -0,0 +1,7 @@ +fun test() { + class Test { + fun invoke(fn: () -> T) {} + } + val test = Test() + test.invoke { 0 } +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/typeArgumentAndFunctionLiteral.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/typeArgumentAndFunctionLiteral.kt.after new file mode 100644 index 00000000000..0999a897c0d --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/typeArgumentAndFunctionLiteral.kt.after @@ -0,0 +1,7 @@ +fun test() { + class Test { + fun invoke(fn: () -> T) {} + } + val test = Test() + test { 0 } +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/valueAndFunctionLiteralInvoke.kt b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/valueAndFunctionLiteralInvoke.kt new file mode 100644 index 00000000000..198f73f5a3c --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/valueAndFunctionLiteralInvoke.kt @@ -0,0 +1,9 @@ +fun test() { + class Test { + fun invoke(a: Int, fn: () -> Unit) {} + } + val test = Test() + test.invoke(0) { + + } +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/valueAndFunctionLiteralInvoke.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/valueAndFunctionLiteralInvoke.kt.after new file mode 100644 index 00000000000..2a1a40488d4 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/valueAndFunctionLiteralInvoke.kt.after @@ -0,0 +1,9 @@ +fun test() { + class Test { + fun invoke(a: Int, fn: () -> Unit) {} + } + val test = Test() + test(0) { + + } +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/valueArgumentInvoke.kt b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/valueArgumentInvoke.kt new file mode 100644 index 00000000000..bab839a4149 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/valueArgumentInvoke.kt @@ -0,0 +1,7 @@ +fun test() { + class Test { + fun invoke(a: Int, b: String) {} + } + val test = Test() + test.invoke(1, "s") +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/valueArgumentInvoke.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/valueArgumentInvoke.kt.after new file mode 100644 index 00000000000..f9050721e12 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/valueArgumentInvoke.kt.after @@ -0,0 +1,7 @@ +fun test() { + class Test { + fun invoke(a: Int, b: String) {} + } + val test = Test() + test(1, "s") +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/varargInvoke.kt b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/varargInvoke.kt new file mode 100644 index 00000000000..4c7bfae4740 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/varargInvoke.kt @@ -0,0 +1,7 @@ +fun test() { + class Test { + fun invoke(a: Int, vararg b: String) {} + } + val test = Test() + test.invoke(1, "a", "b") +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/varargInvoke.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/varargInvoke.kt.after new file mode 100644 index 00000000000..57093bbb90c --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/varargInvoke.kt.after @@ -0,0 +1,7 @@ +fun test() { + class Test { + fun invoke(a: Int, vararg b: String) {} + } + val test = Test() + test(1, "a", "b") +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/acceptableVararg.kt b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/acceptableVararg.kt new file mode 100644 index 00000000000..12890d712c2 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/acceptableVararg.kt @@ -0,0 +1,7 @@ +fun test() { + class Test { + fun plus(vararg a: Int): Test = Test() + } + val test = Test() + test.plus() +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/acceptableVararg.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/acceptableVararg.kt.after new file mode 100644 index 00000000000..ebe6c099378 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/acceptableVararg.kt.after @@ -0,0 +1,7 @@ +fun test() { + class Test { + fun plus(vararg a: Int): Test = Test() + } + val test = Test() + +test +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/complexPlus.kt b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/complexPlus.kt new file mode 100644 index 00000000000..4b0be765b63 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/complexPlus.kt @@ -0,0 +1,9 @@ +fun test() { + class Test { + fun plus(): Test = Test() + fun plus(a: Test): Test = Test() + fun minus(): Test = Test() + } + val test = Test() + println(-(test + test).plus().toString()) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/complexPlus.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/complexPlus.kt.after new file mode 100644 index 00000000000..8284c66d761 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/complexPlus.kt.after @@ -0,0 +1,9 @@ +fun test() { + class Test { + fun plus(): Test = Test() + fun plus(a: Test): Test = Test() + fun minus(): Test = Test() + } + val test = Test() + println(-(+(test + test)).toString()) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/defaultArgument.kt b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/defaultArgument.kt new file mode 100644 index 00000000000..77fe11625ab --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/defaultArgument.kt @@ -0,0 +1,7 @@ +fun test() { + class Test { + fun plus(a: Int=1): Test = Test() + } + val test = Test() + test.plus() +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/defaultArgument.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/defaultArgument.kt.after new file mode 100644 index 00000000000..ba8be21f613 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/defaultArgument.kt.after @@ -0,0 +1,7 @@ +fun test() { + class Test { + fun plus(a: Int=1): Test = Test() + } + val test = Test() + +test +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/extensionFunction.kt b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/extensionFunction.kt new file mode 100644 index 00000000000..f30fa09115b --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/extensionFunction.kt @@ -0,0 +1,8 @@ +fun test() { + class Test() + + fun Test.plus(): Test = Test() + + val test = Test() + test.plus() +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/extensionFunction.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/extensionFunction.kt.after new file mode 100644 index 00000000000..e351cadc88d --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/extensionFunction.kt.after @@ -0,0 +1,8 @@ +fun test() { + class Test() + + fun Test.plus(): Test = Test() + + val test = Test() + +test +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/functionLiteralArgument.kt b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/functionLiteralArgument.kt new file mode 100644 index 00000000000..7ed78bd9398 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/functionLiteralArgument.kt @@ -0,0 +1,8 @@ +// IS_APPLICABLE: false +fun test() { + class Test { + fun plus(fn: () -> Unit): Test = Test() + } + val test = Test() + test.plus {} +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/minusSanityTest.kt b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/minusSanityTest.kt new file mode 100644 index 00000000000..e1444ef9b23 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/minusSanityTest.kt @@ -0,0 +1,8 @@ +// INTENTION_TEXT: Replace with '-' prefix +fun test() { + class Test { + fun minus(): Test = Test() + } + val test = Test() + test.minus() +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/minusSanityTest.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/minusSanityTest.kt.after new file mode 100644 index 00000000000..67a51f3adbf --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/minusSanityTest.kt.after @@ -0,0 +1,8 @@ +// INTENTION_TEXT: Replace with '-' prefix +fun test() { + class Test { + fun minus(): Test = Test() + } + val test = Test() + -test +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/namedValueArgument.kt b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/namedValueArgument.kt new file mode 100644 index 00000000000..dcff041a47d --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/namedValueArgument.kt @@ -0,0 +1,8 @@ +// IS_APPLICABLE: false +fun test() { + class Test { + fun plus(a: Int): Test = Test() + } + val test = Test() + test.plus(a=1) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/notSanityTest.kt b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/notSanityTest.kt new file mode 100644 index 00000000000..5e7e28f86a2 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/notSanityTest.kt @@ -0,0 +1,8 @@ +// INTENTION_TEXT: Replace with '!' prefix +fun test() { + class Test { + fun not(): Test = Test() + } + val test = Test() + test.not() +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/notSanityTest.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/notSanityTest.kt.after new file mode 100644 index 00000000000..12911afe6cd --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/notSanityTest.kt.after @@ -0,0 +1,8 @@ +// INTENTION_TEXT: Replace with '!' prefix +fun test() { + class Test { + fun not(): Test = Test() + } + val test = Test() + !test +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/plusPlus.kt b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/plusPlus.kt new file mode 100644 index 00000000000..6e5de0567e6 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/plusPlus.kt @@ -0,0 +1,7 @@ +fun test() { + class Test { + fun plus(): Test = Test() + } + val test = Test() + +test.plus() +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/plusPlus.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/plusPlus.kt.after new file mode 100644 index 00000000000..de09519575a --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/plusPlus.kt.after @@ -0,0 +1,7 @@ +fun test() { + class Test { + fun plus(): Test = Test() + } + val test = Test() + +(+test) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/plusSanityTest.kt b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/plusSanityTest.kt new file mode 100644 index 00000000000..9698dda4932 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/plusSanityTest.kt @@ -0,0 +1,8 @@ +// INTENTION_TEXT: Replace with '+' prefix +fun test() { + class Test { + fun plus(): Test = Test() + } + val test = Test() + test.plus() +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/plusSanityTest.kt.after b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/plusSanityTest.kt.after new file mode 100644 index 00000000000..d3ca91bb988 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/plusSanityTest.kt.after @@ -0,0 +1,8 @@ +// INTENTION_TEXT: Replace with '+' prefix +fun test() { + class Test { + fun plus(): Test = Test() + } + val test = Test() + +test +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/typeArguments.kt b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/typeArguments.kt new file mode 100644 index 00000000000..3c62355df69 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/typeArguments.kt @@ -0,0 +1,8 @@ +// IS_APPLICABLE: false +fun test() { + class Test { + fun plus(): T? = this as? T + } + val test = Test() + test.plus() +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/unacceptableVararg.kt b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/unacceptableVararg.kt new file mode 100644 index 00000000000..b89a096aebe --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/unacceptableVararg.kt @@ -0,0 +1,8 @@ +// IS_APPLICABLE: false +fun test() { + class Test { + fun plus(vararg a: Int): Test = Test() + } + val test = Test() + test.plus(0) +} diff --git a/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/valueArgument.kt b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/valueArgument.kt new file mode 100644 index 00000000000..7d4336574b6 --- /dev/null +++ b/idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/valueArgument.kt @@ -0,0 +1,8 @@ +// IS_APPLICABLE: false +fun test() { + class Test { + fun plus(a: Int): Test = Test() + } + val test = Test() + test.plus(1) +} diff --git a/idea/tests/org/jetbrains/jet/plugin/intentions/AbstractCodeTransformationTest.java b/idea/tests/org/jetbrains/jet/plugin/intentions/AbstractCodeTransformationTest.java index ccd8c368756..b8c02f6f57f 100644 --- a/idea/tests/org/jetbrains/jet/plugin/intentions/AbstractCodeTransformationTest.java +++ b/idea/tests/org/jetbrains/jet/plugin/intentions/AbstractCodeTransformationTest.java @@ -159,6 +159,26 @@ public abstract class AbstractCodeTransformationTest extends LightCodeInsightTes doTestIntention(path, new AddBracesIntention()); } + public void doTestReplaceGetIntention(@NotNull String path) throws Exception { + doTestIntention(path, new TestableReplaceGetIntention()); + } + + public void doTestReplaceContainsIntention(@NotNull String path) throws Exception { + doTestIntention(path, new TestableReplaceContainsIntention()); + } + + public void doTestReplaceBinaryInfixIntention(@NotNull String path) throws Exception { + doTestIntention(path, new TestableReplaceBinaryInfixIntention()); + } + + public void doTestReplaceUnaryPrefixIntention(@NotNull String path) throws Exception { + doTestIntention(path, new TestableReplaceUnaryPrefixIntention()); + } + + public void doTestReplaceInvokeIntention(@NotNull String path) throws Exception { + doTestIntention(path, new TestableReplaceInvokeIntention()); + } + private void doTestIntention(@NotNull String path, @NotNull IntentionAction intentionAction) throws Exception { configureByFile(path); diff --git a/idea/tests/org/jetbrains/jet/plugin/intentions/AttributeCallReplacementIntentionTestHelpers.kt b/idea/tests/org/jetbrains/jet/plugin/intentions/AttributeCallReplacementIntentionTestHelpers.kt new file mode 100644 index 00000000000..287b6ad20f1 --- /dev/null +++ b/idea/tests/org/jetbrains/jet/plugin/intentions/AttributeCallReplacementIntentionTestHelpers.kt @@ -0,0 +1,32 @@ +/* + * 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 com.intellij.openapi.editor.Editor +import org.jetbrains.jet.plugin.intentions.attributeCallReplacements.* + +trait AttributeCallReplacementIntentionTestMixin : AttributeCallReplacementIntention { + protected override fun intentionFailed(editor: Editor, messageId: String, vararg values: Any?) { + throw IntentionTestException(messageId) + } +} + +class TestableReplaceGetIntention() : ReplaceGetIntention(), AttributeCallReplacementIntentionTestMixin +class TestableReplaceContainsIntention() : ReplaceContainsIntention(), AttributeCallReplacementIntentionTestMixin +class TestableReplaceBinaryInfixIntention() : ReplaceBinaryInfixIntention(), AttributeCallReplacementIntentionTestMixin +class TestableReplaceUnaryPrefixIntention() : ReplaceUnaryPrefixIntention(), AttributeCallReplacementIntentionTestMixin +class TestableReplaceInvokeIntention() : ReplaceInvokeIntention(), AttributeCallReplacementIntentionTestMixin diff --git a/idea/tests/org/jetbrains/jet/plugin/intentions/CodeTransformationTestGenerated.java b/idea/tests/org/jetbrains/jet/plugin/intentions/CodeTransformationTestGenerated.java index 44901d93781..89a18c8cc87 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, CodeTransformationTestGenerated.ReplaceWithInfixFunctionCall.class, CodeTransformationTestGenerated.RemoveCurlyBracesFromTemplate.class, CodeTransformationTestGenerated.MoveLambdaInsideParentheses.class, CodeTransformationTestGenerated.MoveLambdaOutsideParentheses.class, CodeTransformationTestGenerated.ReplaceExplicitFunctionLiteralParamWithIt.class, CodeTransformationTestGenerated.ReplaceItWithExplicitFunctionLiteralParam.class, CodeTransformationTestGenerated.RemoveBraces.class, CodeTransformationTestGenerated.AddBraces.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, CodeTransformationTestGenerated.RemoveCurlyBracesFromTemplate.class, CodeTransformationTestGenerated.MoveLambdaInsideParentheses.class, CodeTransformationTestGenerated.MoveLambdaOutsideParentheses.class, CodeTransformationTestGenerated.ReplaceExplicitFunctionLiteralParamWithIt.class, CodeTransformationTestGenerated.ReplaceItWithExplicitFunctionLiteralParam.class, CodeTransformationTestGenerated.RemoveBraces.class, CodeTransformationTestGenerated.AddBraces.class, CodeTransformationTestGenerated.ReplaceGetIntention.class, CodeTransformationTestGenerated.ReplaceContainsIntention.class, CodeTransformationTestGenerated.ReplaceBinaryInfixIntention.class, CodeTransformationTestGenerated.ReplaceUnaryPrefixIntention.class, CodeTransformationTestGenerated.ReplaceInvokeIntention.class}) public class CodeTransformationTestGenerated extends AbstractCodeTransformationTest { @TestMetadata("idea/testData/intentions/branched/folding/ifToAssignment") public static class IfToAssignment extends AbstractCodeTransformationTest { @@ -1670,6 +1670,416 @@ public class CodeTransformationTestGenerated extends AbstractCodeTransformationT } + @TestMetadata("idea/testData/intentions/attributeCallReplacements/replaceGetIntention") + public static class ReplaceGetIntention extends AbstractCodeTransformationTest { + @TestMetadata("acceptableVararg.kt") + public void testAcceptableVararg() throws Exception { + doTestReplaceGetIntention("idea/testData/intentions/attributeCallReplacements/replaceGetIntention/acceptableVararg.kt"); + } + + public void testAllFilesPresentInReplaceGetIntention() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/intentions/attributeCallReplacements/replaceGetIntention"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("argumentAndFunction.kt") + public void testArgumentAndFunction() throws Exception { + doTestReplaceGetIntention("idea/testData/intentions/attributeCallReplacements/replaceGetIntention/argumentAndFunction.kt"); + } + + @TestMetadata("duplicateArguments.kt") + public void testDuplicateArguments() throws Exception { + doTestReplaceGetIntention("idea/testData/intentions/attributeCallReplacements/replaceGetIntention/duplicateArguments.kt"); + } + + @TestMetadata("extensionFunction.kt") + public void testExtensionFunction() throws Exception { + doTestReplaceGetIntention("idea/testData/intentions/attributeCallReplacements/replaceGetIntention/extensionFunction.kt"); + } + + @TestMetadata("functionalArgument.kt") + public void testFunctionalArgument() throws Exception { + doTestReplaceGetIntention("idea/testData/intentions/attributeCallReplacements/replaceGetIntention/functionalArgument.kt"); + } + + @TestMetadata("invalidArgument.kt") + public void testInvalidArgument() throws Exception { + doTestReplaceGetIntention("idea/testData/intentions/attributeCallReplacements/replaceGetIntention/invalidArgument.kt"); + } + + @TestMetadata("missingArgument.kt") + public void testMissingArgument() throws Exception { + doTestReplaceGetIntention("idea/testData/intentions/attributeCallReplacements/replaceGetIntention/missingArgument.kt"); + } + + @TestMetadata("missingDefaultArgument.kt") + public void testMissingDefaultArgument() throws Exception { + doTestReplaceGetIntention("idea/testData/intentions/attributeCallReplacements/replaceGetIntention/missingDefaultArgument.kt"); + } + + @TestMetadata("multiArgument.kt") + public void testMultiArgument() throws Exception { + doTestReplaceGetIntention("idea/testData/intentions/attributeCallReplacements/replaceGetIntention/multiArgument.kt"); + } + + @TestMetadata("namedAndFunction.kt") + public void testNamedAndFunction() throws Exception { + doTestReplaceGetIntention("idea/testData/intentions/attributeCallReplacements/replaceGetIntention/namedAndFunction.kt"); + } + + @TestMetadata("noArgument.kt") + public void testNoArgument() throws Exception { + doTestReplaceGetIntention("idea/testData/intentions/attributeCallReplacements/replaceGetIntention/noArgument.kt"); + } + + @TestMetadata("sanityCheck.kt") + public void testSanityCheck() throws Exception { + doTestReplaceGetIntention("idea/testData/intentions/attributeCallReplacements/replaceGetIntention/sanityCheck.kt"); + } + + @TestMetadata("singleArgument.kt") + public void testSingleArgument() throws Exception { + doTestReplaceGetIntention("idea/testData/intentions/attributeCallReplacements/replaceGetIntention/singleArgument.kt"); + } + + @TestMetadata("singleNamedArgument.kt") + public void testSingleNamedArgument() throws Exception { + doTestReplaceGetIntention("idea/testData/intentions/attributeCallReplacements/replaceGetIntention/singleNamedArgument.kt"); + } + + @TestMetadata("unacceptableVararg.kt") + public void testUnacceptableVararg() throws Exception { + doTestReplaceGetIntention("idea/testData/intentions/attributeCallReplacements/replaceGetIntention/unacceptableVararg.kt"); + } + + @TestMetadata("unnamedAndNamed.kt") + public void testUnnamedAndNamed() throws Exception { + doTestReplaceGetIntention("idea/testData/intentions/attributeCallReplacements/replaceGetIntention/unnamedAndNamed.kt"); + } + + } + + @TestMetadata("idea/testData/intentions/attributeCallReplacements/replaceContainsIntention") + public static class ReplaceContainsIntention extends AbstractCodeTransformationTest { + @TestMetadata("acceptableVararg.kt") + public void testAcceptableVararg() throws Exception { + doTestReplaceContainsIntention("idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/acceptableVararg.kt"); + } + + @TestMetadata("acceptableVararg2.kt") + public void testAcceptableVararg2() throws Exception { + doTestReplaceContainsIntention("idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/acceptableVararg2.kt"); + } + + public void testAllFilesPresentInReplaceContainsIntention() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/intentions/attributeCallReplacements/replaceContainsIntention"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("allowableDefaultArgument.kt") + public void testAllowableDefaultArgument() throws Exception { + doTestReplaceContainsIntention("idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/allowableDefaultArgument.kt"); + } + + @TestMetadata("containsInExpression.kt") + public void testContainsInExpression() throws Exception { + doTestReplaceContainsIntention("idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/containsInExpression.kt"); + } + + @TestMetadata("extensionFunction.kt") + public void testExtensionFunction() throws Exception { + doTestReplaceContainsIntention("idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/extensionFunction.kt"); + } + + @TestMetadata("functionLiteralArgument.kt") + public void testFunctionLiteralArgument() throws Exception { + doTestReplaceContainsIntention("idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgument.kt"); + } + + @TestMetadata("functionLiteralArgumentAfterSemicolon.kt") + public void testFunctionLiteralArgumentAfterSemicolon() throws Exception { + doTestReplaceContainsIntention("idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgumentAfterSemicolon.kt"); + } + + @TestMetadata("functionLiteralArgumentAtStartOfBlock.kt") + public void testFunctionLiteralArgumentAtStartOfBlock() throws Exception { + doTestReplaceContainsIntention("idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgumentAtStartOfBlock.kt"); + } + + @TestMetadata("functionLiteralArgumentInExpression.kt") + public void testFunctionLiteralArgumentInExpression() throws Exception { + doTestReplaceContainsIntention("idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/functionLiteralArgumentInExpression.kt"); + } + + @TestMetadata("invalidArgument.kt") + public void testInvalidArgument() throws Exception { + doTestReplaceContainsIntention("idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/invalidArgument.kt"); + } + + @TestMetadata("missingArgument.kt") + public void testMissingArgument() throws Exception { + doTestReplaceContainsIntention("idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/missingArgument.kt"); + } + + @TestMetadata("missingDefaultArgument.kt") + public void testMissingDefaultArgument() throws Exception { + doTestReplaceContainsIntention("idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/missingDefaultArgument.kt"); + } + + @TestMetadata("multipleArguments.kt") + public void testMultipleArguments() throws Exception { + doTestReplaceContainsIntention("idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/multipleArguments.kt"); + } + + @TestMetadata("simpleArgument.kt") + public void testSimpleArgument() throws Exception { + doTestReplaceContainsIntention("idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/simpleArgument.kt"); + } + + @TestMetadata("typeArguments.kt") + public void testTypeArguments() throws Exception { + doTestReplaceContainsIntention("idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/typeArguments.kt"); + } + + @TestMetadata("unacceptableVararg1.kt") + public void testUnacceptableVararg1() throws Exception { + doTestReplaceContainsIntention("idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/unacceptableVararg1.kt"); + } + + @TestMetadata("unacceptableVararg2.kt") + public void testUnacceptableVararg2() throws Exception { + doTestReplaceContainsIntention("idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/unacceptableVararg2.kt"); + } + + @TestMetadata("validNamedArgument.kt") + public void testValidNamedArgument() throws Exception { + doTestReplaceContainsIntention("idea/testData/intentions/attributeCallReplacements/replaceContainsIntention/validNamedArgument.kt"); + } + + } + + @TestMetadata("idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention") + public static class ReplaceBinaryInfixIntention extends AbstractCodeTransformationTest { + @TestMetadata("acceptableVararg1.kt") + public void testAcceptableVararg1() throws Exception { + doTestReplaceBinaryInfixIntention("idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/acceptableVararg1.kt"); + } + + @TestMetadata("acceptableVararg2.kt") + public void testAcceptableVararg2() throws Exception { + doTestReplaceBinaryInfixIntention("idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/acceptableVararg2.kt"); + } + + public void testAllFilesPresentInReplaceBinaryInfixIntention() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("allowableDefaultArgument.kt") + public void testAllowableDefaultArgument() throws Exception { + doTestReplaceBinaryInfixIntention("idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/allowableDefaultArgument.kt"); + } + + @TestMetadata("divSanityTest.kt") + public void testDivSanityTest() throws Exception { + doTestReplaceBinaryInfixIntention("idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/divSanityTest.kt"); + } + + @TestMetadata("extensionFunction.kt") + public void testExtensionFunction() throws Exception { + doTestReplaceBinaryInfixIntention("idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/extensionFunction.kt"); + } + + @TestMetadata("functionLiteralArgument.kt") + public void testFunctionLiteralArgument() throws Exception { + doTestReplaceBinaryInfixIntention("idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/functionLiteralArgument.kt"); + } + + @TestMetadata("minusSanityTest.kt") + public void testMinusSanityTest() throws Exception { + doTestReplaceBinaryInfixIntention("idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/minusSanityTest.kt"); + } + + @TestMetadata("missingDefaultArgument.kt") + public void testMissingDefaultArgument() throws Exception { + doTestReplaceBinaryInfixIntention("idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/missingDefaultArgument.kt"); + } + + @TestMetadata("modSanityTest.kt") + public void testModSanityTest() throws Exception { + doTestReplaceBinaryInfixIntention("idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/modSanityTest.kt"); + } + + @TestMetadata("multipleArguments.kt") + public void testMultipleArguments() throws Exception { + doTestReplaceBinaryInfixIntention("idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/multipleArguments.kt"); + } + + @TestMetadata("plusSanityTest.kt") + public void testPlusSanityTest() throws Exception { + doTestReplaceBinaryInfixIntention("idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/plusSanityTest.kt"); + } + + @TestMetadata("rangeToSanityTest.kt") + public void testRangeToSanityTest() throws Exception { + doTestReplaceBinaryInfixIntention("idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/rangeToSanityTest.kt"); + } + + @TestMetadata("timesSanityTest.kt") + public void testTimesSanityTest() throws Exception { + doTestReplaceBinaryInfixIntention("idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/timesSanityTest.kt"); + } + + @TestMetadata("typeArguments.kt") + public void testTypeArguments() throws Exception { + doTestReplaceBinaryInfixIntention("idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/typeArguments.kt"); + } + + @TestMetadata("unacceptableVararg1.kt") + public void testUnacceptableVararg1() throws Exception { + doTestReplaceBinaryInfixIntention("idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/unacceptableVararg1.kt"); + } + + @TestMetadata("unacceptableVararg2.kt") + public void testUnacceptableVararg2() throws Exception { + doTestReplaceBinaryInfixIntention("idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/unacceptableVararg2.kt"); + } + + @TestMetadata("validNamedArgument.kt") + public void testValidNamedArgument() throws Exception { + doTestReplaceBinaryInfixIntention("idea/testData/intentions/attributeCallReplacements/replaceBinaryInfixIntention/validNamedArgument.kt"); + } + + } + + @TestMetadata("idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention") + public static class ReplaceUnaryPrefixIntention extends AbstractCodeTransformationTest { + @TestMetadata("acceptableVararg.kt") + public void testAcceptableVararg() throws Exception { + doTestReplaceUnaryPrefixIntention("idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/acceptableVararg.kt"); + } + + public void testAllFilesPresentInReplaceUnaryPrefixIntention() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("complexPlus.kt") + public void testComplexPlus() throws Exception { + doTestReplaceUnaryPrefixIntention("idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/complexPlus.kt"); + } + + @TestMetadata("defaultArgument.kt") + public void testDefaultArgument() throws Exception { + doTestReplaceUnaryPrefixIntention("idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/defaultArgument.kt"); + } + + @TestMetadata("extensionFunction.kt") + public void testExtensionFunction() throws Exception { + doTestReplaceUnaryPrefixIntention("idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/extensionFunction.kt"); + } + + @TestMetadata("functionLiteralArgument.kt") + public void testFunctionLiteralArgument() throws Exception { + doTestReplaceUnaryPrefixIntention("idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/functionLiteralArgument.kt"); + } + + @TestMetadata("minusSanityTest.kt") + public void testMinusSanityTest() throws Exception { + doTestReplaceUnaryPrefixIntention("idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/minusSanityTest.kt"); + } + + @TestMetadata("namedValueArgument.kt") + public void testNamedValueArgument() throws Exception { + doTestReplaceUnaryPrefixIntention("idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/namedValueArgument.kt"); + } + + @TestMetadata("notSanityTest.kt") + public void testNotSanityTest() throws Exception { + doTestReplaceUnaryPrefixIntention("idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/notSanityTest.kt"); + } + + @TestMetadata("plusPlus.kt") + public void testPlusPlus() throws Exception { + doTestReplaceUnaryPrefixIntention("idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/plusPlus.kt"); + } + + @TestMetadata("plusSanityTest.kt") + public void testPlusSanityTest() throws Exception { + doTestReplaceUnaryPrefixIntention("idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/plusSanityTest.kt"); + } + + @TestMetadata("typeArguments.kt") + public void testTypeArguments() throws Exception { + doTestReplaceUnaryPrefixIntention("idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/typeArguments.kt"); + } + + @TestMetadata("unacceptableVararg.kt") + public void testUnacceptableVararg() throws Exception { + doTestReplaceUnaryPrefixIntention("idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/unacceptableVararg.kt"); + } + + @TestMetadata("valueArgument.kt") + public void testValueArgument() throws Exception { + doTestReplaceUnaryPrefixIntention("idea/testData/intentions/attributeCallReplacements/replaceUnaryPrefixIntention/valueArgument.kt"); + } + + } + + @TestMetadata("idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention") + public static class ReplaceInvokeIntention extends AbstractCodeTransformationTest { + public void testAllFilesPresentInReplaceInvokeIntention() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("extensionFunction.kt") + public void testExtensionFunction() throws Exception { + doTestReplaceInvokeIntention("idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/extensionFunction.kt"); + } + + @TestMetadata("functionLiteralInvoke.kt") + public void testFunctionLiteralInvoke() throws Exception { + doTestReplaceInvokeIntention("idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/functionLiteralInvoke.kt"); + } + + @TestMetadata("invokeInExpression.kt") + public void testInvokeInExpression() throws Exception { + doTestReplaceInvokeIntention("idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/invokeInExpression.kt"); + } + + @TestMetadata("namedArgumentInvoke.kt") + public void testNamedArgumentInvoke() throws Exception { + doTestReplaceInvokeIntention("idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/namedArgumentInvoke.kt"); + } + + @TestMetadata("noArgumentInvoke.kt") + public void testNoArgumentInvoke() throws Exception { + doTestReplaceInvokeIntention("idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/noArgumentInvoke.kt"); + } + + @TestMetadata("typeAndValueArgument.kt") + public void testTypeAndValueArgument() throws Exception { + doTestReplaceInvokeIntention("idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/typeAndValueArgument.kt"); + } + + @TestMetadata("typeArgumentAndFunctionLiteral.kt") + public void testTypeArgumentAndFunctionLiteral() throws Exception { + doTestReplaceInvokeIntention("idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/typeArgumentAndFunctionLiteral.kt"); + } + + @TestMetadata("valueAndFunctionLiteralInvoke.kt") + public void testValueAndFunctionLiteralInvoke() throws Exception { + doTestReplaceInvokeIntention("idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/valueAndFunctionLiteralInvoke.kt"); + } + + @TestMetadata("valueArgumentInvoke.kt") + public void testValueArgumentInvoke() throws Exception { + doTestReplaceInvokeIntention("idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/valueArgumentInvoke.kt"); + } + + @TestMetadata("varargInvoke.kt") + public void testVarargInvoke() throws Exception { + doTestReplaceInvokeIntention("idea/testData/intentions/attributeCallReplacements/replaceInvokeIntention/varargInvoke.kt"); + } + + } + public static Test suite() { TestSuite suite = new TestSuite("CodeTransformationTestGenerated"); suite.addTestSuite(IfToAssignment.class); @@ -1703,6 +2113,11 @@ public class CodeTransformationTestGenerated extends AbstractCodeTransformationT suite.addTestSuite(ReplaceItWithExplicitFunctionLiteralParam.class); suite.addTestSuite(RemoveBraces.class); suite.addTestSuite(AddBraces.class); + suite.addTestSuite(ReplaceGetIntention.class); + suite.addTestSuite(ReplaceContainsIntention.class); + suite.addTestSuite(ReplaceBinaryInfixIntention.class); + suite.addTestSuite(ReplaceUnaryPrefixIntention.class); + suite.addTestSuite(ReplaceInvokeIntention.class); return suite; } }