Add "Replace Java static method with Kotlin top-level function" inspection
#KT-27411 Fixed
This commit is contained in:
committed by
Dmitry Gridin
parent
6bef27e1e8
commit
faa6eacb25
@@ -3396,6 +3396,15 @@
|
||||
language="kotlin"
|
||||
/>
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.ReplaceJavaStaticMethodWithTopLevelFunctionInspection"
|
||||
displayName="Replace Java static method with Kotlin top-level function"
|
||||
groupPath="Kotlin"
|
||||
groupName="Style issues"
|
||||
enabledByDefault="true"
|
||||
level="WEAK WARNING"
|
||||
language="kotlin"
|
||||
/>
|
||||
|
||||
<referenceImporter implementation="org.jetbrains.kotlin.idea.quickfix.KotlinReferenceImporter"/>
|
||||
|
||||
<fileType.fileViewProviderFactory filetype="KJSM" implementationClass="com.intellij.psi.ClassFileViewProviderFactory"/>
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<html>
|
||||
<body>
|
||||
This inspection reports a Java static method call replaceable by a Kotlin top-level function, e.g. <b>System.out.println()</b>.
|
||||
</body>
|
||||
</html>
|
||||
+120
@@ -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<KtDotQualifiedExpression>() ?: 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 }
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
org.jetbrains.kotlin.idea.inspections.ReplaceJavaStaticMethodWithTopLevelFunctionInspection
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double, y: Double) {
|
||||
<caret>Math.IEEEremainder(x, y)
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import kotlin.math.IEEErem
|
||||
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double, y: Double) {
|
||||
x.IEEErem(y)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
<caret>Math.abs(x)
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import kotlin.math.abs
|
||||
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
abs(x)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
<caret>Math.acos(x)
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import kotlin.math.acos
|
||||
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
acos(x)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
<caret>Math.asin(x)
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import kotlin.math.asin
|
||||
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
asin(x)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
<caret>Math.atan(x)
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import kotlin.math.atan
|
||||
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
atan(x)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double, y: Double) {
|
||||
<caret>Math.atan2(x, y)
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import kotlin.math.atan2
|
||||
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double, y: Double) {
|
||||
atan2(x, y)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
<caret>Math.ceil(x)
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import kotlin.math.ceil
|
||||
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
ceil(x)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
<caret>Math.cos(x)
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import kotlin.math.cos
|
||||
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
cos(x)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
<caret>Math.cosh(x)
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import kotlin.math.cosh
|
||||
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
cosh(x)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
<caret>Math.exp(x)
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import kotlin.math.exp
|
||||
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
exp(x)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
<caret>Math.expm1(x)
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import kotlin.math.expm1
|
||||
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
expm1(x)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
<caret>Math.floor(x)
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import kotlin.math.floor
|
||||
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
floor(x)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double, y: Double) {
|
||||
<caret>Math.hypot(x, y)
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import kotlin.math.hypot
|
||||
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double, y: Double) {
|
||||
hypot(x, y)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
<caret>Math.log10(x)
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import kotlin.math.log10
|
||||
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
log10(x)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double, y: Double) {
|
||||
<caret>Math.max(x, y)
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import kotlin.math.max
|
||||
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double, y: Double) {
|
||||
max(x, y)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double, y: Double) {
|
||||
<caret>Math.min(x, y)
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import kotlin.math.min
|
||||
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double, y: Double) {
|
||||
min(x, y)
|
||||
}
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double, y: Double) {
|
||||
<caret>Math.nextAfter(x, y)
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import kotlin.math.nextTowards
|
||||
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double, y: Double) {
|
||||
x.nextTowards(y)
|
||||
}
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
// RUNTIME_WITH_FULL_JDK
|
||||
fun test(x: Double) {
|
||||
<caret>Math.nextDown(x)
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import kotlin.math.nextDown
|
||||
|
||||
// RUNTIME_WITH_FULL_JDK
|
||||
fun test(x: Double) {
|
||||
x.nextDown()
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
<caret>Math.nextUp(x)
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import kotlin.math.nextUp
|
||||
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
x.nextUp()
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double, y: Double) {
|
||||
<caret>Math.pow(x, y)
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import kotlin.math.pow
|
||||
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double, y: Double) {
|
||||
x.pow(y)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
<caret>Math.rint(x)
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import kotlin.math.round
|
||||
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
round(x)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
<caret>Math.round(x)
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import kotlin.math.roundToLong
|
||||
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
x.roundToLong()
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
<caret>Math.signum(x)
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import kotlin.math.sign
|
||||
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
sign(x)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
<caret>Math.sin(x)
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import kotlin.math.sin
|
||||
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
sin(x)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
<caret>Math.sinh(x)
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import kotlin.math.sinh
|
||||
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
sinh(x)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
<caret>Math.sqrt(x)
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import kotlin.math.sqrt
|
||||
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
sqrt(x)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
<caret>Math.tan(x)
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import kotlin.math.tan
|
||||
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
tan(x)
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
<caret>Math.tanh(x)
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
import kotlin.math.tanh
|
||||
|
||||
// WITH_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
fun test(x: Double) {
|
||||
tanh(x)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test() {
|
||||
<caret>System.exit(0)
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
// WITH_RUNTIME
|
||||
fun test() {
|
||||
exitProcess(0)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test() {
|
||||
<caret>System.out.print("foo")
|
||||
}
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test() {
|
||||
print("foo")
|
||||
}
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test() {
|
||||
<caret>System.out.println()
|
||||
}
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test() {
|
||||
println()
|
||||
}
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test() {
|
||||
System.out.println<caret>("foo")
|
||||
}
|
||||
idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/println_2.kt.after
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test() {
|
||||
println("foo")
|
||||
}
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test() {
|
||||
System.out.println<caret>("foo").let { it }
|
||||
}
|
||||
idea/testData/inspectionsLocal/replaceJavaStaticMethodWithTopLevelFunction/system/println_3.kt.after
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test() {
|
||||
println("foo").let { it }
|
||||
}
|
||||
+204
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user