From faa6eacb256e36b0c7f345e47c68d4dcbae2e719 Mon Sep 17 00:00:00 2001 From: Toshiaki Kameyama Date: Fri, 29 Mar 2019 18:56:38 +0900 Subject: [PATCH] Add "Replace Java static method with Kotlin top-level function" inspection #KT-27411 Fixed --- idea/resources/META-INF/plugin-common.xml | 9 + ...eJavaStaticMethodWithTopLevelFunction.html | 5 + ...ticMethodWithTopLevelFunctionInspection.kt | 120 +++++++++++ .../.inspection | 1 + .../math/IEEEremainder.kt | 4 + .../math/IEEEremainder.kt.after | 6 + .../math/abs.kt | 4 + .../math/abs.kt.after | 6 + .../math/acos.kt | 4 + .../math/acos.kt.after | 6 + .../math/asin.kt | 4 + .../math/asin.kt.after | 6 + .../math/atan.kt | 4 + .../math/atan.kt.after | 6 + .../math/atan2.kt | 4 + .../math/atan2.kt.after | 6 + .../math/ceil.kt | 4 + .../math/ceil.kt.after | 6 + .../math/cos.kt | 4 + .../math/cos.kt.after | 6 + .../math/cosh.kt | 4 + .../math/cosh.kt.after | 6 + .../math/exp.kt | 4 + .../math/exp.kt.after | 6 + .../math/expm1.kt | 4 + .../math/expm1.kt.after | 6 + .../math/floor.kt | 4 + .../math/floor.kt.after | 6 + .../math/hypot.kt | 4 + .../math/hypot.kt.after | 6 + .../math/log10.kt | 4 + .../math/log10.kt.after | 6 + .../math/max.kt | 4 + .../math/max.kt.after | 6 + .../math/min.kt | 4 + .../math/min.kt.after | 6 + .../math/nextAfter.kt | 4 + .../math/nextAfter.kt.after | 6 + .../math/nextDown.kt | 4 + .../math/nextDown.kt.after | 6 + .../math/nextUp.kt | 4 + .../math/nextUp.kt.after | 6 + .../math/pow.kt | 4 + .../math/pow.kt.after | 6 + .../math/rint.kt | 4 + .../math/rint.kt.after | 6 + .../math/round.kt | 4 + .../math/round.kt.after | 6 + .../math/signum.kt | 4 + .../math/signum.kt.after | 6 + .../math/sin.kt | 4 + .../math/sin.kt.after | 6 + .../math/sinh.kt | 4 + .../math/sinh.kt.after | 6 + .../math/sqrt.kt | 4 + .../math/sqrt.kt.after | 6 + .../math/tan.kt | 4 + .../math/tan.kt.after | 6 + .../math/tanh.kt | 5 + .../math/tanh.kt.after | 7 + .../system/exit.kt | 4 + .../system/exit.kt.after | 6 + .../system/print.kt | 4 + .../system/print.kt.after | 4 + .../system/println.kt | 4 + .../system/println.kt.after | 4 + .../system/println_2.kt | 4 + .../system/println_2.kt.after | 4 + .../system/println_3.kt | 4 + .../system/println_3.kt.after | 4 + .../LocalInspectionTestGenerated.java | 204 ++++++++++++++++++ 71 files changed, 663 insertions(+) create mode 100644 idea/resources/inspectionDescriptions/ReplaceJavaStaticMethodWithTopLevelFunction.html create mode 100644 idea/src/org/jetbrains/kotlin/idea/inspections/ReplaceJavaStaticMethodWithTopLevelFunctionInspection.kt create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/.inspection create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/IEEEremainder.kt create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/IEEEremainder.kt.after create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/abs.kt create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/abs.kt.after create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/acos.kt create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/acos.kt.after create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/asin.kt create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/asin.kt.after create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/atan.kt create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/atan.kt.after create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/atan2.kt create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/atan2.kt.after create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/ceil.kt create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/ceil.kt.after create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/cos.kt create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/cos.kt.after create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/cosh.kt create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/cosh.kt.after create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/exp.kt create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/exp.kt.after create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/expm1.kt create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/expm1.kt.after create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/floor.kt create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/floor.kt.after create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/hypot.kt create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/hypot.kt.after create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/log10.kt create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/log10.kt.after create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/max.kt create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/max.kt.after create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/min.kt create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/min.kt.after create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/nextAfter.kt create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/nextAfter.kt.after create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/nextDown.kt create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/nextDown.kt.after create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/nextUp.kt create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/nextUp.kt.after create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/pow.kt create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/pow.kt.after create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/rint.kt create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/rint.kt.after create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/round.kt create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/round.kt.after create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/signum.kt create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/signum.kt.after create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/sin.kt create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/sin.kt.after create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/sinh.kt create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/sinh.kt.after create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/sqrt.kt create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/sqrt.kt.after create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/tan.kt create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/tan.kt.after create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/tanh.kt create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/tanh.kt.after create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/exit.kt create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/exit.kt.after create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/print.kt create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/print.kt.after create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/println.kt create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/println.kt.after create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/println_2.kt create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/println_2.kt.after create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/println_3.kt create mode 100644 idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/println_3.kt.after diff --git a/idea/resources/META-INF/plugin-common.xml b/idea/resources/META-INF/plugin-common.xml index 10729271af9..92f28573d37 100644 --- a/idea/resources/META-INF/plugin-common.xml +++ b/idea/resources/META-INF/plugin-common.xml @@ -3396,6 +3396,15 @@ language="kotlin" /> + + diff --git a/idea/resources/inspectionDescriptions/ReplaceJavaStaticMethodWithTopLevelFunction.html b/idea/resources/inspectionDescriptions/ReplaceJavaStaticMethodWithTopLevelFunction.html new file mode 100644 index 00000000000..79fbaecaf66 --- /dev/null +++ b/idea/resources/inspectionDescriptions/ReplaceJavaStaticMethodWithTopLevelFunction.html @@ -0,0 +1,5 @@ + + +This inspection reports a Java static method call replaceable by a Kotlin top-level function, e.g. System.out.println(). + + diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/ReplaceJavaStaticMethodWithTopLevelFunctionInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/ReplaceJavaStaticMethodWithTopLevelFunctionInspection.kt new file mode 100644 index 00000000000..1fdbde6195b --- /dev/null +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/ReplaceJavaStaticMethodWithTopLevelFunctionInspection.kt @@ -0,0 +1,120 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.idea.inspections + +import com.intellij.codeInspection.LocalQuickFix +import com.intellij.codeInspection.ProblemDescriptor +import com.intellij.codeInspection.ProblemsHolder +import com.intellij.openapi.project.Project +import com.intellij.openapi.util.TextRange +import org.jetbrains.kotlin.idea.caches.resolve.analyze +import org.jetbrains.kotlin.idea.caches.resolve.resolveImportReference +import org.jetbrains.kotlin.idea.core.ShortenReferences +import org.jetbrains.kotlin.idea.core.replaced +import org.jetbrains.kotlin.idea.inspections.collections.isCalling +import org.jetbrains.kotlin.idea.intentions.callExpression +import org.jetbrains.kotlin.idea.util.ImportInsertHelper +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.psi.KtDotQualifiedExpression +import org.jetbrains.kotlin.psi.KtPsiFactory +import org.jetbrains.kotlin.psi.callExpressionVisitor +import org.jetbrains.kotlin.psi.psiUtil.endOffset +import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType +import org.jetbrains.kotlin.psi.psiUtil.startOffset +import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall +import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode + +class ReplaceJavaStaticMethodWithTopLevelFunctionInspection : AbstractKotlinInspection() { + override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean) = callExpressionVisitor(fun(call) { + val callee = call.calleeExpression ?: return + val dotQualified = call.getStrictParentOfType() ?: return + val calleeText = callee.text + val replacement = replacements[calleeText] + ?.takeIf { call.getResolvedCall(call.analyze(BodyResolveMode.PARTIAL))?.isCalling(FqName(it.javaMethodFqName)) == true } + ?: return + if (replacement.toExtensionFunction && call.valueArguments.isEmpty()) return + holder.registerProblem( + dotQualified, + TextRange(0, callee.endOffset - dotQualified.startOffset), + "Should be replaced with '${replacement.kotlinFunctionShortName}()'", + ReplaceWithTopLevelFunction(replacement) + ) + }) + + private class ReplaceWithTopLevelFunction(private val replacement: Replacement) : LocalQuickFix { + override fun getName() = "Replace with '${replacement.kotlinFunctionShortName}()'" + + override fun getFamilyName() = name + + override fun applyFix(project: Project, descriptor: ProblemDescriptor) { + val dotQualified = descriptor.psiElement as? KtDotQualifiedExpression ?: return + val call = dotQualified.callExpression ?: return + val file = dotQualified.containingKtFile + val psiFactory = KtPsiFactory(call) + val valueArguments = call.valueArguments + if (replacement.toExtensionFunction) { + val receiverText = valueArguments.first().text + val argumentsText = valueArguments.drop(1).joinToString(separator = ", ") { it.text } + dotQualified.replaced(psiFactory.createExpression("$receiverText.${replacement.kotlinFunctionShortName}($argumentsText)")) + file.resolveImportReference(FqName(replacement.kotlinFunctionFqName)).firstOrNull()?.let { + ImportInsertHelper.getInstance(project).importDescriptor(file, it) + } + } else { + val argumentsText = valueArguments.joinToString(separator = ", ") { it.text } + val replaced = dotQualified.replaced(psiFactory.createExpression("${replacement.kotlinFunctionFqName}($argumentsText)")) + ShortenReferences.DEFAULT.process(replaced) + } + } + } + + private data class Replacement( + val javaMethodFqName: String, + val kotlinFunctionFqName: String, + val toExtensionFunction: Boolean = false + ) { + private fun String.shortName() = takeLastWhile { it != '.' } + + val javaMethodShortName = javaMethodFqName.shortName() + + val kotlinFunctionShortName = kotlinFunctionFqName.shortName() + } + + companion object { + private val replacements = listOf( + Replacement("java.io.PrintStream.print", "kotlin.io.print"), + Replacement("java.io.PrintStream.println", "kotlin.io.println"), + Replacement("java.lang.System.exit", "kotlin.system.exitProcess"), + Replacement("java.lang.Math.abs", "kotlin.math.abs"), + Replacement("java.lang.Math.acos", "kotlin.math.acos"), + Replacement("java.lang.Math.asin", "kotlin.math.asin"), + Replacement("java.lang.Math.atan", "kotlin.math.atan"), + Replacement("java.lang.Math.atan2", "kotlin.math.atan2"), + Replacement("java.lang.Math.ceil", "kotlin.math.ceil"), + Replacement("java.lang.Math.cos", "kotlin.math.cos"), + Replacement("java.lang.Math.cosh", "kotlin.math.cosh"), + Replacement("java.lang.Math.exp", "kotlin.math.exp"), + Replacement("java.lang.Math.expm1", "kotlin.math.expm1"), + Replacement("java.lang.Math.floor", "kotlin.math.floor"), + Replacement("java.lang.Math.hypot", "kotlin.math.hypot"), + Replacement("java.lang.Math.IEEEremainder", "kotlin.math.IEEErem", toExtensionFunction = true), + Replacement("java.lang.Math.log10", "kotlin.math.log10"), + Replacement("java.lang.Math.max", "kotlin.math.max"), + Replacement("java.lang.Math.min", "kotlin.math.min"), + 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), + Replacement("java.lang.Math.pow", "kotlin.math.pow", toExtensionFunction = true), + Replacement("java.lang.Math.rint", "kotlin.math.round"), + Replacement("java.lang.Math.round", "kotlin.math.roundToLong", toExtensionFunction = true), + Replacement("java.lang.Math.signum", "kotlin.math.sign"), + Replacement("java.lang.Math.sin", "kotlin.math.sin"), + Replacement("java.lang.Math.sinh", "kotlin.math.sinh"), + Replacement("java.lang.Math.sqrt", "kotlin.math.sqrt"), + Replacement("java.lang.Math.tan", "kotlin.math.tan"), + Replacement("java.lang.Math.tanh", "kotlin.math.tanh") + ).associateBy { it.javaMethodShortName } + } +} diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/.inspection b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/.inspection new file mode 100644 index 00000000000..8597064b170 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/.inspection @@ -0,0 +1 @@ +org.jetbrains.kotlin.idea.inspections.ReplaceJavaStaticMethodWithTopLevelFunctionInspection \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/IEEEremainder.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/IEEEremainder.kt new file mode 100644 index 00000000000..9c12b6034a1 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/IEEEremainder.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun test(x: Double, y: Double) { + Math.IEEEremainder(x, y) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/IEEEremainder.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/IEEEremainder.kt.after new file mode 100644 index 00000000000..a9d2da12989 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/IEEEremainder.kt.after @@ -0,0 +1,6 @@ +import kotlin.math.IEEErem + +// WITH_RUNTIME +fun test(x: Double, y: Double) { + x.IEEErem(y) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/abs.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/abs.kt new file mode 100644 index 00000000000..55645f3cd56 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/abs.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun test(x: Double) { + Math.abs(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/abs.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/abs.kt.after new file mode 100644 index 00000000000..9322573b9be --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/abs.kt.after @@ -0,0 +1,6 @@ +import kotlin.math.abs + +// WITH_RUNTIME +fun test(x: Double) { + abs(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/acos.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/acos.kt new file mode 100644 index 00000000000..a4253a348d0 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/acos.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun test(x: Double) { + Math.acos(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/acos.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/acos.kt.after new file mode 100644 index 00000000000..f01886cbd48 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/acos.kt.after @@ -0,0 +1,6 @@ +import kotlin.math.acos + +// WITH_RUNTIME +fun test(x: Double) { + acos(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/asin.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/asin.kt new file mode 100644 index 00000000000..0583ead42f4 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/asin.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun test(x: Double) { + Math.asin(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/asin.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/asin.kt.after new file mode 100644 index 00000000000..926b9be91a9 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/asin.kt.after @@ -0,0 +1,6 @@ +import kotlin.math.asin + +// WITH_RUNTIME +fun test(x: Double) { + asin(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/atan.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/atan.kt new file mode 100644 index 00000000000..f8b3a624344 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/atan.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun test(x: Double) { + Math.atan(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/atan.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/atan.kt.after new file mode 100644 index 00000000000..a44221198f0 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/atan.kt.after @@ -0,0 +1,6 @@ +import kotlin.math.atan + +// WITH_RUNTIME +fun test(x: Double) { + atan(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/atan2.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/atan2.kt new file mode 100644 index 00000000000..fd025ed8c33 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/atan2.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun test(x: Double, y: Double) { + Math.atan2(x, y) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/atan2.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/atan2.kt.after new file mode 100644 index 00000000000..d1420430d40 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/atan2.kt.after @@ -0,0 +1,6 @@ +import kotlin.math.atan2 + +// WITH_RUNTIME +fun test(x: Double, y: Double) { + atan2(x, y) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/ceil.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/ceil.kt new file mode 100644 index 00000000000..ea3b066f631 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/ceil.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun test(x: Double) { + Math.ceil(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/ceil.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/ceil.kt.after new file mode 100644 index 00000000000..d3feb34518d --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/ceil.kt.after @@ -0,0 +1,6 @@ +import kotlin.math.ceil + +// WITH_RUNTIME +fun test(x: Double) { + ceil(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/cos.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/cos.kt new file mode 100644 index 00000000000..6d7cc1742f5 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/cos.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun test(x: Double) { + Math.cos(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/cos.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/cos.kt.after new file mode 100644 index 00000000000..126868c4d6d --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/cos.kt.after @@ -0,0 +1,6 @@ +import kotlin.math.cos + +// WITH_RUNTIME +fun test(x: Double) { + cos(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/cosh.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/cosh.kt new file mode 100644 index 00000000000..9a46ce2f2ec --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/cosh.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun test(x: Double) { + Math.cosh(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/cosh.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/cosh.kt.after new file mode 100644 index 00000000000..e427b388a41 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/cosh.kt.after @@ -0,0 +1,6 @@ +import kotlin.math.cosh + +// WITH_RUNTIME +fun test(x: Double) { + cosh(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/exp.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/exp.kt new file mode 100644 index 00000000000..584a359c9fb --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/exp.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun test(x: Double) { + Math.exp(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/exp.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/exp.kt.after new file mode 100644 index 00000000000..53c7f474221 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/exp.kt.after @@ -0,0 +1,6 @@ +import kotlin.math.exp + +// WITH_RUNTIME +fun test(x: Double) { + exp(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/expm1.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/expm1.kt new file mode 100644 index 00000000000..a5ed2d50cf0 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/expm1.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun test(x: Double) { + Math.expm1(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/expm1.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/expm1.kt.after new file mode 100644 index 00000000000..d7365b45da7 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/expm1.kt.after @@ -0,0 +1,6 @@ +import kotlin.math.expm1 + +// WITH_RUNTIME +fun test(x: Double) { + expm1(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/floor.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/floor.kt new file mode 100644 index 00000000000..039fabc6705 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/floor.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun test(x: Double) { + Math.floor(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/floor.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/floor.kt.after new file mode 100644 index 00000000000..9d8b37f254a --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/floor.kt.after @@ -0,0 +1,6 @@ +import kotlin.math.floor + +// WITH_RUNTIME +fun test(x: Double) { + floor(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/hypot.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/hypot.kt new file mode 100644 index 00000000000..7621bfaa842 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/hypot.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun test(x: Double, y: Double) { + Math.hypot(x, y) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/hypot.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/hypot.kt.after new file mode 100644 index 00000000000..1af001a6248 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/hypot.kt.after @@ -0,0 +1,6 @@ +import kotlin.math.hypot + +// WITH_RUNTIME +fun test(x: Double, y: Double) { + hypot(x, y) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/log10.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/log10.kt new file mode 100644 index 00000000000..9f956d07764 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/log10.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun test(x: Double) { + Math.log10(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/log10.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/log10.kt.after new file mode 100644 index 00000000000..1470cdd5d80 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/log10.kt.after @@ -0,0 +1,6 @@ +import kotlin.math.log10 + +// WITH_RUNTIME +fun test(x: Double) { + log10(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/max.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/max.kt new file mode 100644 index 00000000000..8ee1116b6de --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/max.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun test(x: Double, y: Double) { + Math.max(x, y) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/max.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/max.kt.after new file mode 100644 index 00000000000..3771d2011d7 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/max.kt.after @@ -0,0 +1,6 @@ +import kotlin.math.max + +// WITH_RUNTIME +fun test(x: Double, y: Double) { + max(x, y) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/min.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/min.kt new file mode 100644 index 00000000000..cb25d1fb608 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/min.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun test(x: Double, y: Double) { + Math.min(x, y) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/min.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/min.kt.after new file mode 100644 index 00000000000..71bc65a94ff --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/min.kt.after @@ -0,0 +1,6 @@ +import kotlin.math.min + +// WITH_RUNTIME +fun test(x: Double, y: Double) { + min(x, y) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/nextAfter.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/nextAfter.kt new file mode 100644 index 00000000000..fe2e53bce61 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/nextAfter.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun test(x: Double, y: Double) { + Math.nextAfter(x, y) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/nextAfter.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/nextAfter.kt.after new file mode 100644 index 00000000000..46953c20b8a --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/nextAfter.kt.after @@ -0,0 +1,6 @@ +import kotlin.math.nextTowards + +// WITH_RUNTIME +fun test(x: Double, y: Double) { + x.nextTowards(y) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/nextDown.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/nextDown.kt new file mode 100644 index 00000000000..791793577a3 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/nextDown.kt @@ -0,0 +1,4 @@ +// RUNTIME_WITH_FULL_JDK +fun test(x: Double) { + Math.nextDown(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/nextDown.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/nextDown.kt.after new file mode 100644 index 00000000000..88f0eb6f495 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/nextDown.kt.after @@ -0,0 +1,6 @@ +import kotlin.math.nextDown + +// RUNTIME_WITH_FULL_JDK +fun test(x: Double) { + x.nextDown() +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/nextUp.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/nextUp.kt new file mode 100644 index 00000000000..fe4e65db986 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/nextUp.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun test(x: Double) { + Math.nextUp(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/nextUp.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/nextUp.kt.after new file mode 100644 index 00000000000..40fb5f6a91c --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/nextUp.kt.after @@ -0,0 +1,6 @@ +import kotlin.math.nextUp + +// WITH_RUNTIME +fun test(x: Double) { + x.nextUp() +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/pow.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/pow.kt new file mode 100644 index 00000000000..849516a014d --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/pow.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun test(x: Double, y: Double) { + Math.pow(x, y) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/pow.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/pow.kt.after new file mode 100644 index 00000000000..0287fb0e169 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/pow.kt.after @@ -0,0 +1,6 @@ +import kotlin.math.pow + +// WITH_RUNTIME +fun test(x: Double, y: Double) { + x.pow(y) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/rint.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/rint.kt new file mode 100644 index 00000000000..9e5de42cc33 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/rint.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun test(x: Double) { + Math.rint(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/rint.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/rint.kt.after new file mode 100644 index 00000000000..b6cc7dc7880 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/rint.kt.after @@ -0,0 +1,6 @@ +import kotlin.math.round + +// WITH_RUNTIME +fun test(x: Double) { + round(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/round.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/round.kt new file mode 100644 index 00000000000..c488a3267bc --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/round.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun test(x: Double) { + Math.round(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/round.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/round.kt.after new file mode 100644 index 00000000000..863c44182d4 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/round.kt.after @@ -0,0 +1,6 @@ +import kotlin.math.roundToLong + +// WITH_RUNTIME +fun test(x: Double) { + x.roundToLong() +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/signum.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/signum.kt new file mode 100644 index 00000000000..f58587609d0 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/signum.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun test(x: Double) { + Math.signum(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/signum.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/signum.kt.after new file mode 100644 index 00000000000..0193a8ce6fa --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/signum.kt.after @@ -0,0 +1,6 @@ +import kotlin.math.sign + +// WITH_RUNTIME +fun test(x: Double) { + sign(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/sin.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/sin.kt new file mode 100644 index 00000000000..6a1a8e7f217 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/sin.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun test(x: Double) { + Math.sin(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/sin.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/sin.kt.after new file mode 100644 index 00000000000..4b2230bd0c2 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/sin.kt.after @@ -0,0 +1,6 @@ +import kotlin.math.sin + +// WITH_RUNTIME +fun test(x: Double) { + sin(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/sinh.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/sinh.kt new file mode 100644 index 00000000000..55c416ac774 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/sinh.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun test(x: Double) { + Math.sinh(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/sinh.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/sinh.kt.after new file mode 100644 index 00000000000..9e8f57a0593 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/sinh.kt.after @@ -0,0 +1,6 @@ +import kotlin.math.sinh + +// WITH_RUNTIME +fun test(x: Double) { + sinh(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/sqrt.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/sqrt.kt new file mode 100644 index 00000000000..8729529e5e4 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/sqrt.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun test(x: Double) { + Math.sqrt(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/sqrt.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/sqrt.kt.after new file mode 100644 index 00000000000..acea97d6be9 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/sqrt.kt.after @@ -0,0 +1,6 @@ +import kotlin.math.sqrt + +// WITH_RUNTIME +fun test(x: Double) { + sqrt(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/tan.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/tan.kt new file mode 100644 index 00000000000..dd3697320a5 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/tan.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun test(x: Double) { + Math.tan(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/tan.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/tan.kt.after new file mode 100644 index 00000000000..ffc1073b318 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/tan.kt.after @@ -0,0 +1,6 @@ +import kotlin.math.tan + +// WITH_RUNTIME +fun test(x: Double) { + tan(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/tanh.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/tanh.kt new file mode 100644 index 00000000000..780362c522a --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/tanh.kt @@ -0,0 +1,5 @@ +// WITH_RUNTIME +// WITH_RUNTIME +fun test(x: Double) { + Math.tanh(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/tanh.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/tanh.kt.after new file mode 100644 index 00000000000..d3e0acb628e --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/tanh.kt.after @@ -0,0 +1,7 @@ +import kotlin.math.tanh + +// WITH_RUNTIME +// WITH_RUNTIME +fun test(x: Double) { + tanh(x) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/exit.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/exit.kt new file mode 100644 index 00000000000..f2b734a6e6b --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/exit.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun test() { + System.exit(0) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/exit.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/exit.kt.after new file mode 100644 index 00000000000..6a809ba760d --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/exit.kt.after @@ -0,0 +1,6 @@ +import kotlin.system.exitProcess + +// WITH_RUNTIME +fun test() { + exitProcess(0) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/print.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/print.kt new file mode 100644 index 00000000000..366d3435460 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/print.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun test() { + System.out.print("foo") +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/print.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/print.kt.after new file mode 100644 index 00000000000..05083cc5784 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/print.kt.after @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun test() { + print("foo") +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/println.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/println.kt new file mode 100644 index 00000000000..9829c10c951 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/println.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun test() { + System.out.println() +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/println.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/println.kt.after new file mode 100644 index 00000000000..16e28e65662 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/println.kt.after @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun test() { + println() +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/println_2.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/println_2.kt new file mode 100644 index 00000000000..f1368725520 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/println_2.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun test() { + System.out.println("foo") +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/println_2.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/println_2.kt.after new file mode 100644 index 00000000000..8e2e10d0275 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/println_2.kt.after @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun test() { + println("foo") +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/println_3.kt b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/println_3.kt new file mode 100644 index 00000000000..5e0809cbf15 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/println_3.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun test() { + System.out.println("foo").let { it } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/println_3.kt.after b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/println_3.kt.after new file mode 100644 index 00000000000..ce6010bd2f9 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/println_3.kt.after @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun test() { + println("foo").let { it } +} \ 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 080f9ec0d08..57e26ab4456 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java @@ -7204,6 +7204,210 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest { } } + @TestMetadata("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ReplaceJavaStaticMethodWithTopLevelFunction extends AbstractLocalInspectionTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath); + } + + public void testAllFilesPresentInReplaceJavaStaticMethodWithTopLevelFunction() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true); + } + + @TestMetadata("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Math extends AbstractLocalInspectionTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath); + } + + @TestMetadata("abs.kt") + public void testAbs() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/abs.kt"); + } + + @TestMetadata("acos.kt") + public void testAcos() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/acos.kt"); + } + + public void testAllFilesPresentInMath() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true); + } + + @TestMetadata("asin.kt") + public void testAsin() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/asin.kt"); + } + + @TestMetadata("atan.kt") + public void testAtan() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/atan.kt"); + } + + @TestMetadata("atan2.kt") + public void testAtan2() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/atan2.kt"); + } + + @TestMetadata("ceil.kt") + public void testCeil() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/ceil.kt"); + } + + @TestMetadata("cos.kt") + public void testCos() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/cos.kt"); + } + + @TestMetadata("cosh.kt") + public void testCosh() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/cosh.kt"); + } + + @TestMetadata("exp.kt") + public void testExp() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/exp.kt"); + } + + @TestMetadata("expm1.kt") + public void testExpm1() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/expm1.kt"); + } + + @TestMetadata("floor.kt") + public void testFloor() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/floor.kt"); + } + + @TestMetadata("hypot.kt") + public void testHypot() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/hypot.kt"); + } + + @TestMetadata("IEEEremainder.kt") + public void testIEEEremainder() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/IEEEremainder.kt"); + } + + @TestMetadata("log10.kt") + public void testLog10() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/log10.kt"); + } + + @TestMetadata("max.kt") + public void testMax() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/max.kt"); + } + + @TestMetadata("min.kt") + public void testMin() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/min.kt"); + } + + @TestMetadata("nextAfter.kt") + public void testNextAfter() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/nextAfter.kt"); + } + + @TestMetadata("nextDown.kt") + public void testNextDown() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/nextDown.kt"); + } + + @TestMetadata("nextUp.kt") + public void testNextUp() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/nextUp.kt"); + } + + @TestMetadata("pow.kt") + public void testPow() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/pow.kt"); + } + + @TestMetadata("rint.kt") + public void testRint() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/rint.kt"); + } + + @TestMetadata("round.kt") + public void testRound() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/round.kt"); + } + + @TestMetadata("signum.kt") + public void testSignum() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/signum.kt"); + } + + @TestMetadata("sin.kt") + public void testSin() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/sin.kt"); + } + + @TestMetadata("sinh.kt") + public void testSinh() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/sinh.kt"); + } + + @TestMetadata("sqrt.kt") + public void testSqrt() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/sqrt.kt"); + } + + @TestMetadata("tan.kt") + public void testTan() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/tan.kt"); + } + + @TestMetadata("tanh.kt") + public void testTanh() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/math/tanh.kt"); + } + } + + @TestMetadata("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class System extends AbstractLocalInspectionTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath); + } + + public void testAllFilesPresentInSystem() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true); + } + + @TestMetadata("exit.kt") + public void testExit() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/exit.kt"); + } + + @TestMetadata("print.kt") + public void testPrint() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/print.kt"); + } + + @TestMetadata("println.kt") + public void testPrintln() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/println.kt"); + } + + @TestMetadata("println_2.kt") + public void testPrintln_2() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/println_2.kt"); + } + + @TestMetadata("println_3.kt") + public void testPrintln_3() throws Exception { + runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/println_3.kt"); + } + } + } + @TestMetadata("idea/testData/inspectionsLocal/replaceNegatedIsEmptyWithIsNotEmpty") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)