diff --git a/idea/resources/META-INF/plugin-common.xml b/idea/resources/META-INF/plugin-common.xml index 71e5c29111c..eda01da96b6 100644 --- a/idea/resources/META-INF/plugin-common.xml +++ b/idea/resources/META-INF/plugin-common.xml @@ -1408,16 +1408,6 @@ Kotlin - - org.jetbrains.kotlin.idea.intentions.ReplaceMathMaxWithCoerceAtLeastIntention - Kotlin - - - - org.jetbrains.kotlin.idea.intentions.ReplaceMathMinWithCoerceAtMostIntention - Kotlin - - org.jetbrains.kotlin.idea.intentions.RemoveConstructorKeywordIntention Kotlin diff --git a/idea/resources/intentionDescriptions/ReplaceMathMaxWithCoerceAtLeastIntention/after.kt.template b/idea/resources/intentionDescriptions/ReplaceMathMaxWithCoerceAtLeastIntention/after.kt.template deleted file mode 100644 index 517ba05ebe5..00000000000 --- a/idea/resources/intentionDescriptions/ReplaceMathMaxWithCoerceAtLeastIntention/after.kt.template +++ /dev/null @@ -1 +0,0 @@ -1.coerceAtLeast(2) \ No newline at end of file diff --git a/idea/resources/intentionDescriptions/ReplaceMathMaxWithCoerceAtLeastIntention/before.kt.template b/idea/resources/intentionDescriptions/ReplaceMathMaxWithCoerceAtLeastIntention/before.kt.template deleted file mode 100644 index 12524d65bb3..00000000000 --- a/idea/resources/intentionDescriptions/ReplaceMathMaxWithCoerceAtLeastIntention/before.kt.template +++ /dev/null @@ -1 +0,0 @@ -Math.max(1, 2) diff --git a/idea/resources/intentionDescriptions/ReplaceMathMaxWithCoerceAtLeastIntention/description.html b/idea/resources/intentionDescriptions/ReplaceMathMaxWithCoerceAtLeastIntention/description.html deleted file mode 100644 index abbe1b733bd..00000000000 --- a/idea/resources/intentionDescriptions/ReplaceMathMaxWithCoerceAtLeastIntention/description.html +++ /dev/null @@ -1,5 +0,0 @@ - - - This intention replaces Math.max calls with coerceAtLeast calls. - - diff --git a/idea/resources/intentionDescriptions/ReplaceMathMinWithCoerceAtMostIntention/after.kt.template b/idea/resources/intentionDescriptions/ReplaceMathMinWithCoerceAtMostIntention/after.kt.template deleted file mode 100644 index f8fde5d7fc0..00000000000 --- a/idea/resources/intentionDescriptions/ReplaceMathMinWithCoerceAtMostIntention/after.kt.template +++ /dev/null @@ -1 +0,0 @@ -1.coerceAtMost(2) \ No newline at end of file diff --git a/idea/resources/intentionDescriptions/ReplaceMathMinWithCoerceAtMostIntention/before.kt.template b/idea/resources/intentionDescriptions/ReplaceMathMinWithCoerceAtMostIntention/before.kt.template deleted file mode 100644 index cdc5686ecf9..00000000000 --- a/idea/resources/intentionDescriptions/ReplaceMathMinWithCoerceAtMostIntention/before.kt.template +++ /dev/null @@ -1 +0,0 @@ -Math.min(1, 2) diff --git a/idea/resources/intentionDescriptions/ReplaceMathMinWithCoerceAtMostIntention/description.html b/idea/resources/intentionDescriptions/ReplaceMathMinWithCoerceAtMostIntention/description.html deleted file mode 100644 index bc77cb8bea2..00000000000 --- a/idea/resources/intentionDescriptions/ReplaceMathMinWithCoerceAtMostIntention/description.html +++ /dev/null @@ -1,5 +0,0 @@ - - - This intention replaces Math.min calls with coerceAtMost calls. - - diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/ReplaceJavaStaticMethodWithKotlinAnalogInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/ReplaceJavaStaticMethodWithKotlinAnalogInspection.kt index f2b07171b32..476205b2a00 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/ReplaceJavaStaticMethodWithKotlinAnalogInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/ReplaceJavaStaticMethodWithKotlinAnalogInspection.kt @@ -148,7 +148,9 @@ class ReplaceJavaStaticMethodWithKotlinAnalogInspection : AbstractKotlinInspecti Replacement("java.lang.Math.log1p", "kotlin.math.ln1p"), Replacement("java.lang.Math.log10", "kotlin.math.log10"), Replacement("java.lang.Math.max", "kotlin.math.max"), + Replacement("java.lang.Math.max", "kotlin.ranges.coerceAtLeast", toExtensionFunction = true), Replacement("java.lang.Math.min", "kotlin.math.min"), + Replacement("java.lang.Math.min", "kotlin.ranges.coerceAtMost", toExtensionFunction = true), Replacement("java.lang.Math.nextDown", "kotlin.math.nextDown", toExtensionFunction = true), Replacement("java.lang.Math.nextAfter", "kotlin.math.nextTowards", toExtensionFunction = true), Replacement("java.lang.Math.nextUp", "kotlin.math.nextUp", toExtensionFunction = true), diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceMathMaxWithCoerceAtLeastIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceMathMaxWithCoerceAtLeastIntention.kt deleted file mode 100644 index 3d2126ab7ac..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceMathMaxWithCoerceAtLeastIntention.kt +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2010-2016 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.kotlin.idea.intentions - -class ReplaceMathMaxWithCoerceAtLeastIntention : - ReplaceMathMethodsWithKotlinNativeMethodsIntention("Replace Math.max with coerceAtLeast", "coerceAtLeast", "max") \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceMathMethodsWithKotlinNativeMethodsIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceMathMethodsWithKotlinNativeMethodsIntention.kt deleted file mode 100644 index deb94f9b827..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceMathMethodsWithKotlinNativeMethodsIntention.kt +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2010-2016 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.kotlin.idea.intentions - -import com.intellij.openapi.editor.Editor -import org.jetbrains.kotlin.idea.core.replaced -import org.jetbrains.kotlin.psi.KtCallExpression -import org.jetbrains.kotlin.psi.KtPsiFactory -import org.jetbrains.kotlin.psi.createExpressionByPattern -import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForSelectorOrThis - -abstract class ReplaceMathMethodsWithKotlinNativeMethodsIntention( - text: String, private val replacedMethodName: String, private val mathMethodName: String -) : SelfTargetingOffsetIndependentIntention(KtCallExpression::class.java, text) { - - override fun applyTo(element: KtCallExpression, editor: Editor?) { - val target = element.getQualifiedExpressionForSelectorOrThis() - val valueArguments = element.valueArguments - val methodName = replacedMethodName - val newExpression = KtPsiFactory(element).createExpressionByPattern("$0.$methodName($1)", - valueArguments[0].text, valueArguments[1].text) - target.replaced(newExpression) - } - - override fun isApplicableTo(element: KtCallExpression) = - element.calleeExpression?.text == mathMethodName && - element.valueArguments.size == 2 && - element.isMethodCall("java.lang.Math.$mathMethodName") -} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceMathMinWithCoerceAtMostIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceMathMinWithCoerceAtMostIntention.kt deleted file mode 100644 index 5f466e71e71..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceMathMinWithCoerceAtMostIntention.kt +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2010-2016 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.kotlin.idea.intentions - -class ReplaceMathMinWithCoerceAtMostIntention : - ReplaceMathMethodsWithKotlinNativeMethodsIntention("Replace Math.min with coerceAtMost", "coerceAtMost", "min") \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/math/coerceAtLeast.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/math/coerceAtLeast.kt new file mode 100644 index 00000000000..f442f397aaa --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/math/coerceAtLeast.kt @@ -0,0 +1,5 @@ +// FIX: Replace with `coerceAtLeast` function +// WITH_RUNTIME +fun test(x: Double, y: Double) { + Math.max(x, y) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/math/coerceAtLeast.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/math/coerceAtLeast.kt.after new file mode 100644 index 00000000000..dec98374693 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/math/coerceAtLeast.kt.after @@ -0,0 +1,5 @@ +// FIX: Replace with `coerceAtLeast` function +// WITH_RUNTIME +fun test(x: Double, y: Double) { + x.coerceAtLeast(y) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/math/coerceAtMost.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/math/coerceAtMost.kt new file mode 100644 index 00000000000..af456cd0a9d --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/math/coerceAtMost.kt @@ -0,0 +1,5 @@ +// FIX: Replace with `coerceAtMost` function +// WITH_RUNTIME +fun test(x: Double, y: Double) { + Math.min(x, y) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/math/coerceAtMost.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/math/coerceAtMost.kt.after new file mode 100644 index 00000000000..0521d0abf9c --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/math/coerceAtMost.kt.after @@ -0,0 +1,5 @@ +// FIX: Replace with `coerceAtMost` function +// WITH_RUNTIME +fun test(x: Double, y: Double) { + x.coerceAtMost(y) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/math/max.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/math/max.kt index 8ee1116b6de..8a4ce4f6559 100644 --- a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/math/max.kt +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/math/max.kt @@ -1,3 +1,4 @@ +// FIX: Replace with `max` function // WITH_RUNTIME fun test(x: Double, y: Double) { Math.max(x, y) diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/math/max.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/math/max.kt.after index 3771d2011d7..b8113d996b6 100644 --- a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/math/max.kt.after +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/math/max.kt.after @@ -1,5 +1,6 @@ import kotlin.math.max +// FIX: Replace with `max` function // WITH_RUNTIME fun test(x: Double, y: Double) { max(x, y) diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/math/min.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/math/min.kt index cb25d1fb608..6aec4c3fc30 100644 --- a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/math/min.kt +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/math/min.kt @@ -1,3 +1,4 @@ +// FIX: Replace with `min` function // WITH_RUNTIME fun test(x: Double, y: Double) { Math.min(x, y) diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/math/min.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/math/min.kt.after index 71bc65a94ff..736015ebf56 100644 --- a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/math/min.kt.after +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/math/min.kt.after @@ -1,5 +1,6 @@ import kotlin.math.min +// FIX: Replace with `min` function // WITH_RUNTIME fun test(x: Double, y: Double) { min(x, y) diff --git a/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/.intention b/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/.intention deleted file mode 100644 index 122ef763e5d..00000000000 --- a/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/.intention +++ /dev/null @@ -1 +0,0 @@ -org.jetbrains.kotlin.idea.intentions.ReplaceMathMaxWithCoerceAtLeastIntention \ No newline at end of file diff --git a/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/KT-19232-1.kt b/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/KT-19232-1.kt deleted file mode 100644 index 4ceaf89d9b0..00000000000 --- a/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/KT-19232-1.kt +++ /dev/null @@ -1,7 +0,0 @@ -// WITH_RUNTIME - -import java.lang.Math.max - -fun foo() { - Pair(max(1, 3), max(2, 4)).let { println(it) } -} \ No newline at end of file diff --git a/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/KT-19232-1.kt.after b/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/KT-19232-1.kt.after deleted file mode 100644 index 8b7c22210f0..00000000000 --- a/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/KT-19232-1.kt.after +++ /dev/null @@ -1,7 +0,0 @@ -// WITH_RUNTIME - -import java.lang.Math.max - -fun foo() { - Pair(1.coerceAtLeast(3), max(2, 4)).let { println(it) } -} \ No newline at end of file diff --git a/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/KT-19232-2.kt b/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/KT-19232-2.kt deleted file mode 100644 index 0e68703dda0..00000000000 --- a/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/KT-19232-2.kt +++ /dev/null @@ -1,5 +0,0 @@ -// WITH_RUNTIME - -fun foo() { - Pair(Math.max(1, 3), Math.max(2, 4)).let { println(it) } -} \ No newline at end of file diff --git a/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/KT-19232-2.kt.after b/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/KT-19232-2.kt.after deleted file mode 100644 index 27db48db8a6..00000000000 --- a/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/KT-19232-2.kt.after +++ /dev/null @@ -1,5 +0,0 @@ -// WITH_RUNTIME - -fun foo() { - Pair(1.coerceAtLeast(3), Math.max(2, 4)).let { println(it) } -} \ No newline at end of file diff --git a/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/customMaxMethod.kt b/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/customMaxMethod.kt deleted file mode 100644 index 5a5b42c9e8b..00000000000 --- a/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/customMaxMethod.kt +++ /dev/null @@ -1,10 +0,0 @@ -// WITH_RUNTIME -// IS_APPLICABLE: false - -fun foo() { - Math.max(1, 2) -} - -object Math { - fun max(a: Int, b: Int) = 0 -} diff --git a/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/doubles.kt b/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/doubles.kt deleted file mode 100644 index 988be24442e..00000000000 --- a/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/doubles.kt +++ /dev/null @@ -1,7 +0,0 @@ -// WITH_RUNTIME - -import java.lang.Math.max - -fun foo() { - max(1.1, 1.2) -} \ No newline at end of file diff --git a/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/doubles.kt.after b/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/doubles.kt.after deleted file mode 100644 index f5df5c26201..00000000000 --- a/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/doubles.kt.after +++ /dev/null @@ -1,7 +0,0 @@ -// WITH_RUNTIME - -import java.lang.Math.max - -fun foo() { - 1.1.coerceAtLeast(1.2) -} \ No newline at end of file diff --git a/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/maxInMax.kt b/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/maxInMax.kt deleted file mode 100644 index 1fa5b85bb6a..00000000000 --- a/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/maxInMax.kt +++ /dev/null @@ -1,6 +0,0 @@ -// WITH_RUNTIME -import java.lang.Math.max - -fun foo() { - Math.max(max(1, 3), max(2, 4)) -} \ No newline at end of file diff --git a/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/maxInMax.kt.after b/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/maxInMax.kt.after deleted file mode 100644 index 3892aa9b404..00000000000 --- a/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/maxInMax.kt.after +++ /dev/null @@ -1,6 +0,0 @@ -// WITH_RUNTIME -import java.lang.Math.max - -fun foo() { - Math.max(1.coerceAtLeast(3), max(2, 4)) -} \ No newline at end of file diff --git a/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/moreThan2ValueArg.kt b/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/moreThan2ValueArg.kt deleted file mode 100644 index 9092a2fc068..00000000000 --- a/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/moreThan2ValueArg.kt +++ /dev/null @@ -1,9 +0,0 @@ -// WITH_RUNTIME -// IS_APPLICABLE: false -// ERROR: None of the following functions can be called with the arguments supplied:
public open fun max(a: Double, b: Double): Double defined in java.lang.Math
public open fun max(a: Float, b: Float): Float defined in java.lang.Math
public open fun max(a: Int, b: Int): Int defined in java.lang.Math
public open fun max(a: Long, b: Long): Long defined in java.lang.Math - -import java.lang.Math.max - -fun foo() { - max(1.1, 1.2, 1.3) -} diff --git a/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/noImport.kt b/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/noImport.kt deleted file mode 100644 index 68a05d49418..00000000000 --- a/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/noImport.kt +++ /dev/null @@ -1,5 +0,0 @@ -// WITH_RUNTIME - -fun foo() { - Math.max(2, 1) -} \ No newline at end of file diff --git a/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/noImport.kt.after b/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/noImport.kt.after deleted file mode 100644 index 55c5baa66b1..00000000000 --- a/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/noImport.kt.after +++ /dev/null @@ -1,5 +0,0 @@ -// WITH_RUNTIME - -fun foo() { - 2.coerceAtLeast(1) -} \ No newline at end of file diff --git a/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/oneValueArg.kt b/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/oneValueArg.kt deleted file mode 100644 index c88f7d72544..00000000000 --- a/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/oneValueArg.kt +++ /dev/null @@ -1,9 +0,0 @@ -// WITH_RUNTIME -// IS_APPLICABLE: false -// ERROR: None of the following functions can be called with the arguments supplied:
public open fun max(a: Double, b: Double): Double defined in java.lang.Math
public open fun max(a: Float, b: Float): Float defined in java.lang.Math
public open fun max(a: Int, b: Int): Int defined in java.lang.Math
public open fun max(a: Long, b: Long): Long defined in java.lang.Math - -import java.lang.Math.max - -fun foo() { - max(1.1) -} diff --git a/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/simple.kt b/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/simple.kt deleted file mode 100644 index 86540ae647f..00000000000 --- a/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/simple.kt +++ /dev/null @@ -1,7 +0,0 @@ -// WITH_RUNTIME - -import java.lang.Math.max - -fun foo() { - max(1, 2) -} \ No newline at end of file diff --git a/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/simple.kt.after b/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/simple.kt.after deleted file mode 100644 index f8631458189..00000000000 --- a/idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/simple.kt.after +++ /dev/null @@ -1,7 +0,0 @@ -// WITH_RUNTIME - -import java.lang.Math.max - -fun foo() { - 1.coerceAtLeast(2) -} \ No newline at end of file diff --git a/idea/testData/intentions/replaceMathMinWithCoerceAtMost/.intention b/idea/testData/intentions/replaceMathMinWithCoerceAtMost/.intention deleted file mode 100644 index fcc06d057f4..00000000000 --- a/idea/testData/intentions/replaceMathMinWithCoerceAtMost/.intention +++ /dev/null @@ -1 +0,0 @@ -org.jetbrains.kotlin.idea.intentions.ReplaceMathMinWithCoerceAtMostIntention \ No newline at end of file diff --git a/idea/testData/intentions/replaceMathMinWithCoerceAtMost/KT-19232-1.kt b/idea/testData/intentions/replaceMathMinWithCoerceAtMost/KT-19232-1.kt deleted file mode 100644 index 48de805348a..00000000000 --- a/idea/testData/intentions/replaceMathMinWithCoerceAtMost/KT-19232-1.kt +++ /dev/null @@ -1,7 +0,0 @@ -// WITH_RUNTIME - -import java.lang.Math.min - -fun foo() { - Pair(min(1, 3), min(2, 4)).let { println(it) } -} \ No newline at end of file diff --git a/idea/testData/intentions/replaceMathMinWithCoerceAtMost/KT-19232-1.kt.after b/idea/testData/intentions/replaceMathMinWithCoerceAtMost/KT-19232-1.kt.after deleted file mode 100644 index fbd5356a253..00000000000 --- a/idea/testData/intentions/replaceMathMinWithCoerceAtMost/KT-19232-1.kt.after +++ /dev/null @@ -1,7 +0,0 @@ -// WITH_RUNTIME - -import java.lang.Math.min - -fun foo() { - Pair(1.coerceAtMost(3), min(2, 4)).let { println(it) } -} \ No newline at end of file diff --git a/idea/testData/intentions/replaceMathMinWithCoerceAtMost/KT-19232-2.kt b/idea/testData/intentions/replaceMathMinWithCoerceAtMost/KT-19232-2.kt deleted file mode 100644 index 33548d645a6..00000000000 --- a/idea/testData/intentions/replaceMathMinWithCoerceAtMost/KT-19232-2.kt +++ /dev/null @@ -1,5 +0,0 @@ -// WITH_RUNTIME - -fun foo() { - Pair(Math.min(1, 3), Math.min(2, 4)).let { println(it) } -} \ No newline at end of file diff --git a/idea/testData/intentions/replaceMathMinWithCoerceAtMost/KT-19232-2.kt.after b/idea/testData/intentions/replaceMathMinWithCoerceAtMost/KT-19232-2.kt.after deleted file mode 100644 index 462b4d5d5f0..00000000000 --- a/idea/testData/intentions/replaceMathMinWithCoerceAtMost/KT-19232-2.kt.after +++ /dev/null @@ -1,5 +0,0 @@ -// WITH_RUNTIME - -fun foo() { - Pair(1.coerceAtMost(3), Math.min(2, 4)).let { println(it) } -} \ No newline at end of file diff --git a/idea/testData/intentions/replaceMathMinWithCoerceAtMost/customMinMethod.kt b/idea/testData/intentions/replaceMathMinWithCoerceAtMost/customMinMethod.kt deleted file mode 100644 index fe831ae9cb6..00000000000 --- a/idea/testData/intentions/replaceMathMinWithCoerceAtMost/customMinMethod.kt +++ /dev/null @@ -1,10 +0,0 @@ -// WITH_RUNTIME -// IS_APPLICABLE: false - -fun foo() { - Math.min(1, 2) -} - -object Math { - fun min(a: Int, b: Int) = 0 -} diff --git a/idea/testData/intentions/replaceMathMinWithCoerceAtMost/doubles.kt b/idea/testData/intentions/replaceMathMinWithCoerceAtMost/doubles.kt deleted file mode 100644 index 45f308c0b4e..00000000000 --- a/idea/testData/intentions/replaceMathMinWithCoerceAtMost/doubles.kt +++ /dev/null @@ -1,7 +0,0 @@ -// WITH_RUNTIME - -import java.lang.Math.min - -fun foo() { - min(1.1, 1.2) -} \ No newline at end of file diff --git a/idea/testData/intentions/replaceMathMinWithCoerceAtMost/doubles.kt.after b/idea/testData/intentions/replaceMathMinWithCoerceAtMost/doubles.kt.after deleted file mode 100644 index 279c32e840e..00000000000 --- a/idea/testData/intentions/replaceMathMinWithCoerceAtMost/doubles.kt.after +++ /dev/null @@ -1,7 +0,0 @@ -// WITH_RUNTIME - -import java.lang.Math.min - -fun foo() { - 1.1.coerceAtMost(1.2) -} \ No newline at end of file diff --git a/idea/testData/intentions/replaceMathMinWithCoerceAtMost/moreThan2ValueArg.kt b/idea/testData/intentions/replaceMathMinWithCoerceAtMost/moreThan2ValueArg.kt deleted file mode 100644 index 3d8aea4f85c..00000000000 --- a/idea/testData/intentions/replaceMathMinWithCoerceAtMost/moreThan2ValueArg.kt +++ /dev/null @@ -1,9 +0,0 @@ -// WITH_RUNTIME -// IS_APPLICABLE: false -// ERROR: None of the following functions can be called with the arguments supplied:
public open fun min(a: Double, b: Double): Double defined in java.lang.Math
public open fun min(a: Float, b: Float): Float defined in java.lang.Math
public open fun min(a: Int, b: Int): Int defined in java.lang.Math
public open fun min(a: Long, b: Long): Long defined in java.lang.Math - -import java.lang.Math.min - -fun foo() { - min(1.1, 1.2, 1.3) -} diff --git a/idea/testData/intentions/replaceMathMinWithCoerceAtMost/noImport.kt b/idea/testData/intentions/replaceMathMinWithCoerceAtMost/noImport.kt deleted file mode 100644 index 5f520414b7b..00000000000 --- a/idea/testData/intentions/replaceMathMinWithCoerceAtMost/noImport.kt +++ /dev/null @@ -1,5 +0,0 @@ -// WITH_RUNTIME - -fun foo() { - Math.min(2, 1) -} \ No newline at end of file diff --git a/idea/testData/intentions/replaceMathMinWithCoerceAtMost/noImport.kt.after b/idea/testData/intentions/replaceMathMinWithCoerceAtMost/noImport.kt.after deleted file mode 100644 index 10f915aadec..00000000000 --- a/idea/testData/intentions/replaceMathMinWithCoerceAtMost/noImport.kt.after +++ /dev/null @@ -1,5 +0,0 @@ -// WITH_RUNTIME - -fun foo() { - 2.coerceAtMost(1) -} \ No newline at end of file diff --git a/idea/testData/intentions/replaceMathMinWithCoerceAtMost/oneValueArg.kt b/idea/testData/intentions/replaceMathMinWithCoerceAtMost/oneValueArg.kt deleted file mode 100644 index a0f4bbd9aed..00000000000 --- a/idea/testData/intentions/replaceMathMinWithCoerceAtMost/oneValueArg.kt +++ /dev/null @@ -1,9 +0,0 @@ -// WITH_RUNTIME -// IS_APPLICABLE: false -// ERROR: None of the following functions can be called with the arguments supplied:
public open fun min(a: Double, b: Double): Double defined in java.lang.Math
public open fun min(a: Float, b: Float): Float defined in java.lang.Math
public open fun min(a: Int, b: Int): Int defined in java.lang.Math
public open fun min(a: Long, b: Long): Long defined in java.lang.Math - -import java.lang.Math.min - -fun foo() { - min(1.1) -} diff --git a/idea/testData/intentions/replaceMathMinWithCoerceAtMost/simple.kt b/idea/testData/intentions/replaceMathMinWithCoerceAtMost/simple.kt deleted file mode 100644 index b4a3649f7fb..00000000000 --- a/idea/testData/intentions/replaceMathMinWithCoerceAtMost/simple.kt +++ /dev/null @@ -1,7 +0,0 @@ -// WITH_RUNTIME - -import java.lang.Math.min - -fun foo() { - min(1, 2) -} \ No newline at end of file diff --git a/idea/testData/intentions/replaceMathMinWithCoerceAtMost/simple.kt.after b/idea/testData/intentions/replaceMathMinWithCoerceAtMost/simple.kt.after deleted file mode 100644 index 79ee55d839a..00000000000 --- a/idea/testData/intentions/replaceMathMinWithCoerceAtMost/simple.kt.after +++ /dev/null @@ -1,7 +0,0 @@ -// WITH_RUNTIME - -import java.lang.Math.min - -fun foo() { - 1.coerceAtMost(2) -} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java index d4fde38c4db..10c91fd22c1 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java @@ -7529,6 +7529,16 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest { runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/math/ceil.kt"); } + @TestMetadata("coerceAtLeast.kt") + public void testCoerceAtLeast() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/math/coerceAtLeast.kt"); + } + + @TestMetadata("coerceAtMost.kt") + public void testCoerceAtMost() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/math/coerceAtMost.kt"); + } + @TestMetadata("copySign.kt") public void testCopySign() throws Exception { runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/math/copySign.kt"); diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java index e33faa6f97b..4485d647129 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java @@ -15000,117 +15000,6 @@ public class IntentionTestGenerated extends AbstractIntentionTest { } } - @TestMetadata("idea/testData/intentions/replaceMathMaxWithCoerceAtLeast") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class ReplaceMathMaxWithCoerceAtLeast extends AbstractIntentionTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath); - } - - public void testAllFilesPresentInReplaceMathMaxWithCoerceAtLeast() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/replaceMathMaxWithCoerceAtLeast"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true); - } - - @TestMetadata("customMaxMethod.kt") - public void testCustomMaxMethod() throws Exception { - runTest("idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/customMaxMethod.kt"); - } - - @TestMetadata("doubles.kt") - public void testDoubles() throws Exception { - runTest("idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/doubles.kt"); - } - - @TestMetadata("KT-19232-1.kt") - public void testKT_19232_1() throws Exception { - runTest("idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/KT-19232-1.kt"); - } - - @TestMetadata("KT-19232-2.kt") - public void testKT_19232_2() throws Exception { - runTest("idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/KT-19232-2.kt"); - } - - @TestMetadata("maxInMax.kt") - public void testMaxInMax() throws Exception { - runTest("idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/maxInMax.kt"); - } - - @TestMetadata("moreThan2ValueArg.kt") - public void testMoreThan2ValueArg() throws Exception { - runTest("idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/moreThan2ValueArg.kt"); - } - - @TestMetadata("noImport.kt") - public void testNoImport() throws Exception { - runTest("idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/noImport.kt"); - } - - @TestMetadata("oneValueArg.kt") - public void testOneValueArg() throws Exception { - runTest("idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/oneValueArg.kt"); - } - - @TestMetadata("simple.kt") - public void testSimple() throws Exception { - runTest("idea/testData/intentions/replaceMathMaxWithCoerceAtLeast/simple.kt"); - } - } - - @TestMetadata("idea/testData/intentions/replaceMathMinWithCoerceAtMost") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class ReplaceMathMinWithCoerceAtMost extends AbstractIntentionTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath); - } - - public void testAllFilesPresentInReplaceMathMinWithCoerceAtMost() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/replaceMathMinWithCoerceAtMost"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true); - } - - @TestMetadata("customMinMethod.kt") - public void testCustomMinMethod() throws Exception { - runTest("idea/testData/intentions/replaceMathMinWithCoerceAtMost/customMinMethod.kt"); - } - - @TestMetadata("doubles.kt") - public void testDoubles() throws Exception { - runTest("idea/testData/intentions/replaceMathMinWithCoerceAtMost/doubles.kt"); - } - - @TestMetadata("KT-19232-1.kt") - public void testKT_19232_1() throws Exception { - runTest("idea/testData/intentions/replaceMathMinWithCoerceAtMost/KT-19232-1.kt"); - } - - @TestMetadata("KT-19232-2.kt") - public void testKT_19232_2() throws Exception { - runTest("idea/testData/intentions/replaceMathMinWithCoerceAtMost/KT-19232-2.kt"); - } - - @TestMetadata("moreThan2ValueArg.kt") - public void testMoreThan2ValueArg() throws Exception { - runTest("idea/testData/intentions/replaceMathMinWithCoerceAtMost/moreThan2ValueArg.kt"); - } - - @TestMetadata("noImport.kt") - public void testNoImport() throws Exception { - runTest("idea/testData/intentions/replaceMathMinWithCoerceAtMost/noImport.kt"); - } - - @TestMetadata("oneValueArg.kt") - public void testOneValueArg() throws Exception { - runTest("idea/testData/intentions/replaceMathMinWithCoerceAtMost/oneValueArg.kt"); - } - - @TestMetadata("simple.kt") - public void testSimple() throws Exception { - runTest("idea/testData/intentions/replaceMathMinWithCoerceAtMost/simple.kt"); - } - } - @TestMetadata("idea/testData/intentions/replaceSingleLineLetIntention") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)