From 224affe3a24d6ceefb1cafaaae92478733e70fcc Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Wed, 7 Oct 2015 19:25:32 +0300 Subject: [PATCH] Rename unary plus() and minus() to unaryPlus() and unaryMinus() GitOrigin-RevId: 148c5575e1d1e8d8f1c0d03645dc52b41f5127d7 --- .../kotlin/idea/search/usagesSearch/conventions.kt | 2 +- .../highlighter/KotlinRecursiveCallLineMarkerProvider.kt | 7 ++++++- .../kotlin/idea/inspections/OperatorModifierInspection.kt | 1 + .../createCallable/CreateBinaryOperationActionFactory.kt | 2 +- .../createCallable/CreateUnaryOperationActionFactory.kt | 2 +- .../codeInsight/lineMarker/recursiveCall/conventionCall.kt | 4 ++-- .../replaceCallWithUnaryOperator/acceptableVararg.kt | 4 ++-- .../replaceCallWithUnaryOperator/acceptableVararg.kt.after | 2 +- .../replaceCallWithUnaryOperator/complexPlus.kt | 6 +++--- .../replaceCallWithUnaryOperator/complexPlus.kt.after | 4 ++-- .../replaceCallWithUnaryOperator/defaultArgument.kt | 4 ++-- .../replaceCallWithUnaryOperator/defaultArgument.kt.after | 2 +- .../replaceCallWithUnaryOperator/extensionFunction.kt | 4 ++-- .../extensionFunction.kt.after | 2 +- .../functionLiteralArgument.kt | 4 ++-- .../replaceCallWithUnaryOperator/minusSanityTest.kt | 4 ++-- .../replaceCallWithUnaryOperator/minusSanityTest.kt.after | 2 +- .../replaceCallWithUnaryOperator/namedValueArgument.kt | 4 ++-- .../replaceCallWithUnaryOperator/plusPlus.kt | 4 ++-- .../replaceCallWithUnaryOperator/plusPlus.kt.after | 2 +- .../replaceCallWithUnaryOperator/plusSanityTest.kt | 4 ++-- .../replaceCallWithUnaryOperator/plusSanityTest.kt.after | 2 +- .../replaceCallWithUnaryOperator/qualifier.kt | 4 ++-- .../replaceCallWithUnaryOperator/qualifier.kt.after | 2 +- .../replaceCallWithUnaryOperator/super.kt | 6 +++--- .../replaceCallWithUnaryOperator/typeArguments.kt | 4 ++-- .../replaceCallWithUnaryOperator/unacceptableVararg.kt | 4 ++-- .../replaceCallWithUnaryOperator/valueArgument.kt | 4 ++-- .../intentions/convertFunctionToProperty/unaryOp.kt | 2 +- .../quickfix/autoImports/unaryMinusOperator.after.kt | 2 +- .../autoImports/unaryMinusOperator.before.Dependency.kt | 2 +- .../quickfix/autoImports/unaryPlusOperator.after.kt | 6 +++--- .../autoImports/unaryPlusOperator.before.Dependency.kt | 2 +- .../quickfix/autoImports/unaryPlusOperator.before.Main.kt | 4 ++-- .../createFunction/binaryOperations/plusExtraArgs.kt | 4 ++-- .../createFunction/binaryOperations/plusExtraArgs.kt.after | 2 +- .../createFunction/delegateAccessors/var.kt | 2 +- .../delegateAccessors/varMissingSet.kt.after | 4 ++-- .../createFunction/unaryOperations/minusMissingArgs.kt | 4 ++-- .../unaryOperations/minusMissingArgs.kt.after | 6 +++--- .../createFunction/unaryOperations/minusOnLibType.kt | 2 +- .../createFunction/unaryOperations/minusOnLibType.kt.after | 4 ++-- .../createFunction/unaryOperations/minusOnUserType.kt | 2 +- .../unaryOperations/minusOnUserType.kt.after | 4 ++-- .../unaryOperations/minusOnUserTypeWithTypeParams.kt | 2 +- .../unaryOperations/minusOnUserTypeWithTypeParams.kt.after | 4 ++-- 46 files changed, 80 insertions(+), 74 deletions(-) diff --git a/plugins/kotlin/analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/conventions.kt b/plugins/kotlin/analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/conventions.kt index 48ef09f8fd22..daf5eb95221a 100644 --- a/plugins/kotlin/analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/conventions.kt +++ b/plugins/kotlin/analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/conventions.kt @@ -60,7 +60,7 @@ public fun Name.getOperationSymbolsToSearch(): Set { if (isComponentLike(this)) return setOf(JetTokens.LPAR) - val unaryOp = UNARY_OPERATION_NAMES.inverse()[this] + val unaryOp = UNARY_OPERATION_NAMES_WITH_DEPRECATED_INVERTED[this] if (unaryOp != null) return setOf(unaryOp) val binaryOp = BINARY_OPERATION_NAMES.inverse()[this] diff --git a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinRecursiveCallLineMarkerProvider.kt b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinRecursiveCallLineMarkerProvider.kt index e6b2d7d14102..53d02b9094bb 100644 --- a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinRecursiveCallLineMarkerProvider.kt +++ b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinRecursiveCallLineMarkerProvider.kt @@ -143,7 +143,12 @@ private fun getCallNameFromPsi(element: JetElement): Name? { if (element == operationReference) { val node = operationReference.getReferencedNameElementType() return if (node is JetToken) { - OperatorConventions.getNameForOperationSymbol(node) ?: Name.identifierNoValidate(element.getText()) + val conventionName = if (elementParent is JetPrefixExpression) + OperatorConventions.getNameForOperationSymbol(node, true, false) + else + OperatorConventions.getNameForOperationSymbol(node) + + conventionName ?: Name.identifierNoValidate(element.getText()) } else { Name.identifierNoValidate(element.getText()) diff --git a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/inspections/OperatorModifierInspection.kt b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/inspections/OperatorModifierInspection.kt index 333f8498e0ed..fb90cae42b0f 100644 --- a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/inspections/OperatorModifierInspection.kt +++ b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/inspections/OperatorModifierInspection.kt @@ -69,6 +69,7 @@ public class OperatorModifierInspection : AbstractKotlinInspection() { val arity = valueParameters.size() if (arity == 0 && (name in OperatorConventions.UNARY_OPERATION_NAMES.values() || + name == OperatorNameConventions.PLUS || name == OperatorNameConventions.MINUS || // temporary name == OperatorNameConventions.ITERATOR || isComponentLike(name) || name == OperatorNameConventions.NEXT || diff --git a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateBinaryOperationActionFactory.kt b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateBinaryOperationActionFactory.kt index 05875eb472fe..4979e98da12c 100644 --- a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateBinaryOperationActionFactory.kt +++ b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateBinaryOperationActionFactory.kt @@ -35,7 +35,7 @@ public object CreateBinaryOperationActionFactory: CreateCallableMemberFromUsageF val token = element.operationToken as JetToken val operationName = when (token) { JetTokens.IDENTIFIER -> element.operationReference.getReferencedName() - else -> OperatorConventions.getNameForOperationSymbol(token)?.asString() + else -> OperatorConventions.getNameForOperationSymbol(token, false, true)?.asString() } ?: return null val inOperation = token in OperatorConventions.IN_OPERATIONS val comparisonOperation = token in OperatorConventions.COMPARISON_OPERATIONS diff --git a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateUnaryOperationActionFactory.kt b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateUnaryOperationActionFactory.kt index febe102e4e6b..201080395a39 100644 --- a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateUnaryOperationActionFactory.kt +++ b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateUnaryOperationActionFactory.kt @@ -32,7 +32,7 @@ public object CreateUnaryOperationActionFactory: CreateCallableMemberFromUsageFa override fun createCallableInfo(element: JetUnaryExpression, diagnostic: Diagnostic): CallableInfo? { val token = element.operationToken as JetToken - val operationName = OperatorConventions.getNameForOperationSymbol(token) ?: return null + val operationName = OperatorConventions.getNameForOperationSymbol(token, true, false) ?: return null val incDec = token in OperatorConventions.INCREMENT_OPERATIONS val receiverExpr = element.baseExpression ?: return null diff --git a/plugins/kotlin/idea/tests/testData/codeInsight/lineMarker/recursiveCall/conventionCall.kt b/plugins/kotlin/idea/tests/testData/codeInsight/lineMarker/recursiveCall/conventionCall.kt index 7725735db81b..e26b22b46017 100644 --- a/plugins/kotlin/idea/tests/testData/codeInsight/lineMarker/recursiveCall/conventionCall.kt +++ b/plugins/kotlin/idea/tests/testData/codeInsight/lineMarker/recursiveCall/conventionCall.kt @@ -22,11 +22,11 @@ class A { return 1 } - fun plus() { + fun unaryPlus() { +this } - fun minus() { + fun unaryMinus() { -this } diff --git a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/acceptableVararg.kt b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/acceptableVararg.kt index 12890d712c2e..3833b3dfe46a 100644 --- a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/acceptableVararg.kt +++ b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/acceptableVararg.kt @@ -1,7 +1,7 @@ fun test() { class Test { - fun plus(vararg a: Int): Test = Test() + fun unaryPlus(vararg a: Int): Test = Test() } val test = Test() - test.plus() + test.unaryPlus() } diff --git a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/acceptableVararg.kt.after b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/acceptableVararg.kt.after index ebe6c099378a..f5dcacfa3115 100644 --- a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/acceptableVararg.kt.after +++ b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/acceptableVararg.kt.after @@ -1,6 +1,6 @@ fun test() { class Test { - fun plus(vararg a: Int): Test = Test() + fun unaryPlus(vararg a: Int): Test = Test() } val test = Test() +test diff --git a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/complexPlus.kt b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/complexPlus.kt index 48cbbaadceef..90584de7521b 100644 --- a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/complexPlus.kt +++ b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/complexPlus.kt @@ -2,10 +2,10 @@ fun doSomething(a: T) {} fun test() { class Test { - fun plus(): Test = Test() + fun unaryPlus(): Test = Test() fun plus(a: Test): Test = Test() - fun minus(): Test = Test() + fun unaryMinus(): Test = Test() } val test = Test() - doSomething((-((test + test).plus())).toString()) + doSomething((-((test + test).unaryPlus())).toString()) } diff --git a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/complexPlus.kt.after b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/complexPlus.kt.after index 7aa5f3e5df1a..175daac30737 100644 --- a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/complexPlus.kt.after +++ b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/complexPlus.kt.after @@ -2,9 +2,9 @@ fun doSomething(a: T) {} fun test() { class Test { - fun plus(): Test = Test() + fun unaryPlus(): Test = Test() fun plus(a: Test): Test = Test() - fun minus(): Test = Test() + fun unaryMinus(): Test = Test() } val test = Test() doSomething((-(+(test + test))).toString()) diff --git a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/defaultArgument.kt b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/defaultArgument.kt index 77fe11625abc..4cb09621afff 100644 --- a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/defaultArgument.kt +++ b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/defaultArgument.kt @@ -1,7 +1,7 @@ fun test() { class Test { - fun plus(a: Int=1): Test = Test() + fun unaryPlus(a: Int=1): Test = Test() } val test = Test() - test.plus() + test.unaryPlus() } diff --git a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/defaultArgument.kt.after b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/defaultArgument.kt.after index ba8be21f613d..18783d6e16a3 100644 --- a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/defaultArgument.kt.after +++ b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/defaultArgument.kt.after @@ -1,6 +1,6 @@ fun test() { class Test { - fun plus(a: Int=1): Test = Test() + fun unaryPlus(a: Int=1): Test = Test() } val test = Test() +test diff --git a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/extensionFunction.kt b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/extensionFunction.kt index f30fa09115b4..8e47f5e4e556 100644 --- a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/extensionFunction.kt +++ b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/extensionFunction.kt @@ -1,8 +1,8 @@ fun test() { class Test() - fun Test.plus(): Test = Test() + fun Test.unaryPlus(): Test = Test() val test = Test() - test.plus() + test.unaryPlus() } diff --git a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/extensionFunction.kt.after b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/extensionFunction.kt.after index e351cadc88dd..b3efb2dbaf8f 100644 --- a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/extensionFunction.kt.after +++ b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/extensionFunction.kt.after @@ -1,7 +1,7 @@ fun test() { class Test() - fun Test.plus(): Test = Test() + fun Test.unaryPlus(): Test = Test() val test = Test() +test diff --git a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/functionLiteralArgument.kt b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/functionLiteralArgument.kt index 7ed78bd93981..ff206b845866 100644 --- a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/functionLiteralArgument.kt +++ b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/functionLiteralArgument.kt @@ -1,8 +1,8 @@ // IS_APPLICABLE: false fun test() { class Test { - fun plus(fn: () -> Unit): Test = Test() + fun unaryPlus(fn: () -> Unit): Test = Test() } val test = Test() - test.plus {} + test.unaryPlus {} } diff --git a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/minusSanityTest.kt b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/minusSanityTest.kt index e7c688262f84..b3083f198a12 100644 --- a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/minusSanityTest.kt +++ b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/minusSanityTest.kt @@ -1,8 +1,8 @@ // INTENTION_TEXT: Replace with '-' operator fun test() { class Test { - fun minus(): Test = Test() + fun unaryMinus(): Test = Test() } val test = Test() - test.minus() + test.unaryMinus() } diff --git a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/minusSanityTest.kt.after b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/minusSanityTest.kt.after index 65d3c74b0d91..ccc39653c566 100644 --- a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/minusSanityTest.kt.after +++ b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/minusSanityTest.kt.after @@ -1,7 +1,7 @@ // INTENTION_TEXT: Replace with '-' operator fun test() { class Test { - fun minus(): Test = Test() + fun unaryMinus(): Test = Test() } val test = Test() -test diff --git a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/namedValueArgument.kt b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/namedValueArgument.kt index dcff041a47db..4d4f39aa16a5 100644 --- a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/namedValueArgument.kt +++ b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/namedValueArgument.kt @@ -1,8 +1,8 @@ // IS_APPLICABLE: false fun test() { class Test { - fun plus(a: Int): Test = Test() + fun unaryPlus(a: Int): Test = Test() } val test = Test() - test.plus(a=1) + test.unaryPlus(a=1) } diff --git a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusPlus.kt b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusPlus.kt index 6e5de0567e6c..1b5a568f7268 100644 --- a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusPlus.kt +++ b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusPlus.kt @@ -1,7 +1,7 @@ fun test() { class Test { - fun plus(): Test = Test() + fun unaryPlus(): Test = Test() } val test = Test() - +test.plus() + +test.unaryPlus() } diff --git a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusPlus.kt.after b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusPlus.kt.after index de09519575a0..c4213b3430f9 100644 --- a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusPlus.kt.after +++ b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusPlus.kt.after @@ -1,6 +1,6 @@ fun test() { class Test { - fun plus(): Test = Test() + fun unaryPlus(): Test = Test() } val test = Test() +(+test) diff --git a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusSanityTest.kt b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusSanityTest.kt index 5d3c231b2b2f..3cc07d9d70c2 100644 --- a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusSanityTest.kt +++ b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusSanityTest.kt @@ -1,8 +1,8 @@ // INTENTION_TEXT: Replace with '+' operator fun test() { class Test { - fun plus(): Test = Test() + fun unaryPlus(): Test = Test() } val test = Test() - test.plus() + test.unaryPlus() } diff --git a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusSanityTest.kt.after b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusSanityTest.kt.after index 84088da876c9..87046c7f5e3e 100644 --- a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusSanityTest.kt.after +++ b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusSanityTest.kt.after @@ -1,7 +1,7 @@ // INTENTION_TEXT: Replace with '+' operator fun test() { class Test { - fun plus(): Test = Test() + fun unaryPlus(): Test = Test() } val test = Test() +test diff --git a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/qualifier.kt b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/qualifier.kt index 9ee010e06875..49b99081d5be 100644 --- a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/qualifier.kt +++ b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/qualifier.kt @@ -1,9 +1,9 @@ class C { companion object { - fun minus(): C = C() + fun unaryMinus(): C = C() } } fun foo() { - C.minus() + C.unaryMinus() } diff --git a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/qualifier.kt.after b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/qualifier.kt.after index 8eb489b730c5..63a45078ab66 100644 --- a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/qualifier.kt.after +++ b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/qualifier.kt.after @@ -1,6 +1,6 @@ class C { companion object { - fun minus(): C = C() + fun unaryMinus(): C = C() } } diff --git a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/super.kt b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/super.kt index 2b0476ccd541..90f14507191c 100644 --- a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/super.kt +++ b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/super.kt @@ -1,11 +1,11 @@ // IS_APPLICABLE: false open class Base { - open fun minus() = this + open fun unaryMinus() = this } class C : Base() { - override fun minus(): Base { - return super.minus() + override fun unaryMinus(): Base { + return super.unaryMinus() } } diff --git a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/typeArguments.kt b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/typeArguments.kt index 3c62355df69d..bb92785b5131 100644 --- a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/typeArguments.kt +++ b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/typeArguments.kt @@ -1,8 +1,8 @@ // IS_APPLICABLE: false fun test() { class Test { - fun plus(): T? = this as? T + fun unaryPlus(): T? = this as? T } val test = Test() - test.plus() + test.unaryPlus() } diff --git a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/unacceptableVararg.kt b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/unacceptableVararg.kt index b89a096aebec..02fc3cad0611 100644 --- a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/unacceptableVararg.kt +++ b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/unacceptableVararg.kt @@ -1,8 +1,8 @@ // IS_APPLICABLE: false fun test() { class Test { - fun plus(vararg a: Int): Test = Test() + fun unaryPlus(vararg a: Int): Test = Test() } val test = Test() - test.plus(0) + test.unaryPlus(0) } diff --git a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/valueArgument.kt b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/valueArgument.kt index 7d4336574b6b..d481d683ebe5 100644 --- a/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/valueArgument.kt +++ b/plugins/kotlin/idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/valueArgument.kt @@ -1,8 +1,8 @@ // IS_APPLICABLE: false fun test() { class Test { - fun plus(a: Int): Test = Test() + fun unaryPlus(a: Int): Test = Test() } val test = Test() - test.plus(1) + test.unaryPlus(1) } diff --git a/plugins/kotlin/idea/tests/testData/intentions/convertFunctionToProperty/unaryOp.kt b/plugins/kotlin/idea/tests/testData/intentions/convertFunctionToProperty/unaryOp.kt index 90a3c694538e..b058aaa31cb6 100644 --- a/plugins/kotlin/idea/tests/testData/intentions/convertFunctionToProperty/unaryOp.kt +++ b/plugins/kotlin/idea/tests/testData/intentions/convertFunctionToProperty/unaryOp.kt @@ -1,7 +1,7 @@ // WITH_RUNTIME // IS_APPLICABLE: false class A(val n: Int) { - fun minus(): A = A(-n) + fun unaryMinus(): A = A(-n) } fun test() { diff --git a/plugins/kotlin/idea/tests/testData/quickfix/autoImports/unaryMinusOperator.after.kt b/plugins/kotlin/idea/tests/testData/quickfix/autoImports/unaryMinusOperator.after.kt index 36ce590e8d0f..402228bd0f9c 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/autoImports/unaryMinusOperator.after.kt +++ b/plugins/kotlin/idea/tests/testData/quickfix/autoImports/unaryMinusOperator.after.kt @@ -3,7 +3,7 @@ package h -import util.minus +import util.unaryMinus interface H diff --git a/plugins/kotlin/idea/tests/testData/quickfix/autoImports/unaryMinusOperator.before.Dependency.kt b/plugins/kotlin/idea/tests/testData/quickfix/autoImports/unaryMinusOperator.before.Dependency.kt index 0a543bc5b033..5150a02746a6 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/autoImports/unaryMinusOperator.before.Dependency.kt +++ b/plugins/kotlin/idea/tests/testData/quickfix/autoImports/unaryMinusOperator.before.Dependency.kt @@ -1,3 +1,3 @@ package util -operator fun h.H?.minus() = "" \ No newline at end of file +operator fun h.H?.unaryMinus() = "" \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/autoImports/unaryPlusOperator.after.kt b/plugins/kotlin/idea/tests/testData/quickfix/autoImports/unaryPlusOperator.after.kt index ae4c44c89e1b..437fd4d0e507 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/autoImports/unaryPlusOperator.after.kt +++ b/plugins/kotlin/idea/tests/testData/quickfix/autoImports/unaryPlusOperator.after.kt @@ -1,9 +1,9 @@ // "Import" "true" -// ERROR: Unresolved reference.
None of the following candidates is applicable because of receiver type mismatch:
  • public operator fun h.A.plus(): kotlin.Int defined in h
  • public operator fun kotlin.String?.plus(other: kotlin.Any?): kotlin.String defined in kotlin
+// ERROR: Unresolved reference.
None of the following candidates is applicable because of receiver type mismatch:
  • public operator fun h.A.unaryPlus(): kotlin.Int defined in h
package h -import util.plus +import util.unaryPlus interface H @@ -13,4 +13,4 @@ fun f(h: H?) { class A() -operator fun A.plus(): Int = 3 \ No newline at end of file +operator fun A.unaryPlus(): Int = 3 \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/autoImports/unaryPlusOperator.before.Dependency.kt b/plugins/kotlin/idea/tests/testData/quickfix/autoImports/unaryPlusOperator.before.Dependency.kt index fb64b4a74d86..6ac81de3c742 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/autoImports/unaryPlusOperator.before.Dependency.kt +++ b/plugins/kotlin/idea/tests/testData/quickfix/autoImports/unaryPlusOperator.before.Dependency.kt @@ -1,3 +1,3 @@ package util -operator fun h.H.plus() = "" \ No newline at end of file +operator fun h.H.unaryPlus() = "" \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/autoImports/unaryPlusOperator.before.Main.kt b/plugins/kotlin/idea/tests/testData/quickfix/autoImports/unaryPlusOperator.before.Main.kt index 94d474eb74da..db9b7d69be2a 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/autoImports/unaryPlusOperator.before.Main.kt +++ b/plugins/kotlin/idea/tests/testData/quickfix/autoImports/unaryPlusOperator.before.Main.kt @@ -1,5 +1,5 @@ // "Import" "true" -// ERROR: Unresolved reference.
None of the following candidates is applicable because of receiver type mismatch:
  • public operator fun h.A.plus(): kotlin.Int defined in h
  • public operator fun kotlin.String?.plus(other: kotlin.Any?): kotlin.String defined in kotlin
+// ERROR: Unresolved reference.
None of the following candidates is applicable because of receiver type mismatch:
  • public operator fun h.A.unaryPlus(): kotlin.Int defined in h
package h @@ -11,4 +11,4 @@ fun f(h: H?) { class A() -operator fun A.plus(): Int = 3 \ No newline at end of file +operator fun A.unaryPlus(): Int = 3 \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/binaryOperations/plusExtraArgs.kt b/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/binaryOperations/plusExtraArgs.kt index e71b6d28e8ef..c43c5aa59dd3 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/binaryOperations/plusExtraArgs.kt +++ b/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/binaryOperations/plusExtraArgs.kt @@ -1,9 +1,9 @@ // "Create member function 'plus'" "true" class A(val n: T) { - fun plus(): A = throw Exception() + operator fun unaryPlus(): A = throw Exception() } fun test() { - val a: A = A(1) + 2 + val a: A = A(1) + 2 } \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/binaryOperations/plusExtraArgs.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/binaryOperations/plusExtraArgs.kt.after index c9c1d52a8ca1..fea4dc075350 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/binaryOperations/plusExtraArgs.kt.after +++ b/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/binaryOperations/plusExtraArgs.kt.after @@ -1,7 +1,7 @@ // "Create member function 'plus'" "true" class A(val n: T) { - fun plus(): A = throw Exception() + operator fun unaryPlus(): A = throw Exception() operator fun plus(t: T): A { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. diff --git a/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/delegateAccessors/var.kt b/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/delegateAccessors/var.kt index 964ff7116fa7..c152b01e5e6b 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/delegateAccessors/var.kt +++ b/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/delegateAccessors/var.kt @@ -1,4 +1,4 @@ -// "Create member function 'getValue', function 'set'" "true" +// "Create member function 'getValue', function 'setValue'" "true" class F { } diff --git a/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/delegateAccessors/varMissingSet.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/delegateAccessors/varMissingSet.kt.after index 7d4020e6a45b..142f0dfc9b4b 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/delegateAccessors/varMissingSet.kt.after +++ b/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/delegateAccessors/varMissingSet.kt.after @@ -1,8 +1,8 @@ // "Create member function 'setValue'" "true" class F { - fun get(x: X, propertyMetadata: PropertyMetadata): Int = 1 + fun getValue(x: X, propertyMetadata: PropertyMetadata): Int = 1 - fun set(x: X, propertyMetadata: PropertyMetadata, i: Int) { + fun setValue(x: X, propertyMetadata: PropertyMetadata, i: Int) { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } } diff --git a/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusMissingArgs.kt b/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusMissingArgs.kt index 8cfb663dc85a..614972a27cd8 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusMissingArgs.kt +++ b/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusMissingArgs.kt @@ -1,7 +1,7 @@ -// "Create member function 'minus'" "true" +// "Create member function 'unaryMinus'" "true" class A(val n: T) { - fun minus(n: Int): A = throw Exception() + operator fun minus(n: Int): A = throw Exception() } fun test() { diff --git a/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusMissingArgs.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusMissingArgs.kt.after index 56839f80ed1f..835a899f8e7e 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusMissingArgs.kt.after +++ b/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusMissingArgs.kt.after @@ -1,9 +1,9 @@ -// "Create member function 'minus'" "true" +// "Create member function 'unaryMinus'" "true" class A(val n: T) { - fun minus(n: Int): A = throw Exception() + operator fun minus(n: Int): A = throw Exception() - operator fun minus(): A { + operator fun unaryMinus(): A { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } } diff --git a/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnLibType.kt b/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnLibType.kt index 9a3bc997ba71..d5549371ec83 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnLibType.kt +++ b/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnLibType.kt @@ -1,4 +1,4 @@ -// "Create extension function 'minus'" "true" +// "Create extension function 'unaryMinus'" "true" fun test() { val a = -false diff --git a/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnLibType.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnLibType.kt.after index ef9f3ab7ea6c..473b11230e60 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnLibType.kt.after +++ b/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnLibType.kt.after @@ -1,9 +1,9 @@ -// "Create extension function 'minus'" "true" +// "Create extension function 'unaryMinus'" "true" fun test() { val a = -false } -operator fun Boolean.minus(): Any { +operator fun Boolean.unaryMinus(): Any { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } diff --git a/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnUserType.kt b/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnUserType.kt index 142735ba94c9..eb7f03fe386b 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnUserType.kt +++ b/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnUserType.kt @@ -1,4 +1,4 @@ -// "Create member function 'minus'" "true" +// "Create member function 'unaryMinus'" "true" class A(val n: T) diff --git a/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnUserType.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnUserType.kt.after index 6c45679ef952..12aaa39a31e2 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnUserType.kt.after +++ b/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnUserType.kt.after @@ -1,7 +1,7 @@ -// "Create member function 'minus'" "true" +// "Create member function 'unaryMinus'" "true" class A(val n: T) { - operator fun minus(): Any { + operator fun unaryMinus(): Any { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } } diff --git a/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnUserTypeWithTypeParams.kt b/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnUserTypeWithTypeParams.kt index 4677bf225273..fec12102f473 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnUserTypeWithTypeParams.kt +++ b/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnUserTypeWithTypeParams.kt @@ -1,4 +1,4 @@ -// "Create member function 'minus'" "true" +// "Create member function 'unaryMinus'" "true" class A(val n: T) diff --git a/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnUserTypeWithTypeParams.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnUserTypeWithTypeParams.kt.after index 7058a7c87313..1c737b4a6355 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnUserTypeWithTypeParams.kt.after +++ b/plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createFunction/unaryOperations/minusOnUserTypeWithTypeParams.kt.after @@ -1,7 +1,7 @@ -// "Create member function 'minus'" "true" +// "Create member function 'unaryMinus'" "true" class A(val n: T) { - operator fun minus(): A { + operator fun unaryMinus(): A { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } }