ReplaceJavaStaticMethodWithKotlinAnalogInspection: remove non-implemented cases

This commit is contained in:
Dmitry Gridin
2019-07-09 13:12:42 +03:00
parent 632158cd52
commit 026949a758
8 changed files with 11 additions and 76 deletions
@@ -81,9 +81,10 @@ class ReplaceJavaStaticMethodWithKotlinAnalogInspection : AbstractKotlinInspecti
Replacement("java.io.PrintStream.println", "kotlin.io.println", filter = ::isJavaSystemOut)
)
// TODO: implement Transformation for mapping
private val JAVA_SYSTEM = listOf(
Replacement("java.lang.System.exit", "kotlin.system.exitProcess"),
Replacement("java.lang.System.arraycopy", "kotlin.collections.copyInto", ToExtensionFunction) // TODO: mapping
Replacement("java.lang.System.exit", "kotlin.system.exitProcess")
// Replacement("java.lang.System.arraycopy", "kotlin.collections.copyInto", ToExtensionFunction)
)
private val JAVA_MATH = listOf(
@@ -128,16 +129,16 @@ class ReplaceJavaStaticMethodWithKotlinAnalogInspection : AbstractKotlinInspecti
it.valueArguments.size == 2
},
Replacement("java.util.Arrays.copyOfRange", "kotlin.collections.copyOfRange", ToExtensionFunction),
Replacement("java.util.Arrays.binarySearch", "kotlin.collections.binarySearch", ToExtensionFunction), // TODO: mapping
// Replacement("java.util.Arrays.binarySearch", "kotlin.collections.binarySearch", ToExtensionFunction),
Replacement("java.util.Arrays.equals", "kotlin.collections.contentEquals", ToExtensionFunction),
Replacement("java.util.Arrays.deepEquals", "kotlin.collections.contentDeepEquals", ToExtensionFunction),
Replacement("java.util.Arrays.fill", "kotlin.collections.fill", ToExtensionFunction), // TODO: mapping
Replacement("java.util.Arrays.sort", "kotlin.collections.sort", ToExtensionFunction) {
it.valueArguments.size == 3
}, //TODO: mapping?
Replacement("java.util.Arrays.sort", "kotlin.collections.sortWith", ToExtensionFunction) {
it.valueArguments.size != 3
},
// Replacement("java.util.Arrays.fill", "kotlin.collections.fill", ToExtensionFunction),
// Replacement("java.util.Arrays.sort", "kotlin.collections.sort", ToExtensionFunction) {
// it.valueArguments.size == 3
// },
// Replacement("java.util.Arrays.sort", "kotlin.collections.sortWith", ToExtensionFunction) {
// it.valueArguments.size != 3
// },
Replacement("java.util.Arrays.deepHashCode", "kotlin.collections.contentDeepHashCode", ToExtensionFunction),
Replacement("java.util.Arrays.hashCode", "kotlin.collections.contentHashCode", ToExtensionFunction),
Replacement("java.util.Arrays.deepToString", "kotlin.collections.contentDeepToString", ToExtensionFunction),
@@ -1,7 +0,0 @@
// WITH_RUNTIME
import java.util.Arrays
fun test() {
val array = arrayOf(1, 2, 3)
val result = Arrays.<caret>binarySearch(array, 3)
}
@@ -1,7 +0,0 @@
// WITH_RUNTIME
import java.util.Arrays
fun test() {
val array = arrayOf(1, 2, 3)
val result = array.binarySearch(3)
}
@@ -1,9 +0,0 @@
// WITH_RUNTIME
import java.util.Arrays
fun test() {
val array = arrayOf(1, 2, 3)
val from = 1
val to = 4
val result = Arrays.<caret>binarySearch(array, from, to, 3)
}
@@ -1,10 +0,0 @@
// WITH_RUNTIME
import java.util.Arrays
fun test() {
val array = arrayOf(1, 2, 3)
val key = 3
val from = 1
val to = 4
val result = array.binarySearch(key, from, to)
}
@@ -1,9 +0,0 @@
// WITH_RUNTIME
fun test() {
val a = arrayOf(2)
val b = arrayOf(4)
val aOffset = 1
val bOffset = 2
val len = 5
java.lang.System.<caret>arraycopy(a, aOffset, b, bOffset, len)
}
@@ -1,9 +0,0 @@
// WITH_RUNTIME
fun test() {
val a = arrayOf(2)
val b = arrayOf(4)
val aOffset = 1
val bOffset = 2
val len = 5
a.copyInto(b, bOffset, aOffset, len + aOffset)
}
@@ -9061,16 +9061,6 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/collections/asList.kt");
}
@TestMetadata("binarySearch.kt")
public void testBinarySearch() throws Exception {
runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/collections/binarySearch.kt");
}
@TestMetadata("binarySearch2.kt")
public void testBinarySearch2() throws Exception {
runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/collections/binarySearch2.kt");
}
@TestMetadata("copyOf.kt")
public void testCopyOf() throws Exception {
runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/collections/copyOf.kt");
@@ -9438,11 +9428,6 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/system"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true);
}
@TestMetadata("arraycopy.kt")
public void testArraycopy() throws Exception {
runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/system/arraycopy.kt");
}
@TestMetadata("exit.kt")
public void testExit() throws Exception {
runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/system/exit.kt");