mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[kotlin] ReplaceJavaStaticMethodWithKotlinAnalogInspection: allow some nullable arguments
Kotlin stdlib 1.4+ now supports such code. ^KTIJ-25310 Fixed GitOrigin-RevId: 8caf0e783e4566abeba66b1f837bd9a37624afee
This commit is contained in:
committed by
intellij-monorepo-bot
parent
fd6512651c
commit
22c1138be5
+6
-6
@@ -158,22 +158,22 @@ class ReplaceJavaStaticMethodWithKotlinAnalogInspection : AbstractKotlinInspecti
|
||||
it.valueArguments.size == 2
|
||||
},
|
||||
Replacement("java.util.Arrays.copyOfRange", "kotlin.collections.copyOfRange", ToExtensionFunctionWithNonNullableReceiver),
|
||||
Replacement("java.util.Arrays.equals", "kotlin.collections.contentEquals", ToExtensionFunctionWithNonNullableArguments) {
|
||||
Replacement("java.util.Arrays.equals", "kotlin.collections.contentEquals", ToExtensionFunctionWithNullableReceiver) {
|
||||
it.valueArguments.size == 2
|
||||
},
|
||||
Replacement("java.util.Arrays.deepEquals", "kotlin.collections.contentDeepEquals", ToExtensionFunctionWithNonNullableArguments),
|
||||
Replacement("java.util.Arrays.deepEquals", "kotlin.collections.contentDeepEquals", ToExtensionFunctionWithNullableReceiver),
|
||||
Replacement(
|
||||
"java.util.Arrays.deepHashCode",
|
||||
"kotlin.collections.contentDeepHashCode",
|
||||
ToExtensionFunctionWithNonNullableReceiver
|
||||
ToExtensionFunctionWithNullableReceiver
|
||||
),
|
||||
Replacement("java.util.Arrays.hashCode", "kotlin.collections.contentHashCode", ToExtensionFunctionWithNonNullableReceiver),
|
||||
Replacement("java.util.Arrays.hashCode", "kotlin.collections.contentHashCode", ToExtensionFunctionWithNullableReceiver),
|
||||
Replacement(
|
||||
"java.util.Arrays.deepToString",
|
||||
"kotlin.collections.contentDeepToString",
|
||||
ToExtensionFunctionWithNonNullableReceiver
|
||||
ToExtensionFunctionWithNullableReceiver
|
||||
),
|
||||
Replacement("java.util.Arrays.toString", "kotlin.collections.contentToString", ToExtensionFunctionWithNonNullableReceiver),
|
||||
Replacement("java.util.Arrays.toString", "kotlin.collections.contentToString", ToExtensionFunctionWithNullableReceiver),
|
||||
Replacement("java.util.Arrays.asList", "kotlin.collections.listOf"),
|
||||
Replacement("java.util.Arrays.asList", "kotlin.collections.mutableListOf"),
|
||||
Replacement("java.util.Set.of", "kotlin.collections.setOf"),
|
||||
|
||||
@@ -68,19 +68,6 @@ object ToExtensionFunctionWithNonNullableReceiver : Transformation {
|
||||
?.isNullable() == false
|
||||
}
|
||||
|
||||
object ToExtensionFunctionWithNonNullableArguments : Transformation {
|
||||
override fun invoke(callExpression: KtCallExpression, replacement: Replacement) =
|
||||
ToExtensionFunctionWithNonNullableReceiver(callExpression, replacement)
|
||||
|
||||
override fun isApplicable(callExpression: KtCallExpression): Boolean =
|
||||
ToExtensionFunctionWithNonNullableReceiver.isApplicable(callExpression)
|
||||
|
||||
override fun isApplicableInContext(callExpression: KtCallExpression, context: BindingContext): Boolean =
|
||||
callExpression.valueArguments.all {
|
||||
it.getArgumentExpression()?.getType(context)?.isNullable() == false
|
||||
}
|
||||
}
|
||||
|
||||
object ToExtensionFunctionWithNullableReceiver : Transformation {
|
||||
override fun invoke(callExpression: KtCallExpression, replacement: Replacement) =
|
||||
ToExtensionFunctionWithNonNullableReceiver(callExpression, replacement)
|
||||
|
||||
-1
@@ -1,5 +1,4 @@
|
||||
// WITH_STDLIB
|
||||
// PROBLEM: none
|
||||
import java.util.Arrays
|
||||
|
||||
fun test() {
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// WITH_STDLIB
|
||||
import java.util.Arrays
|
||||
|
||||
fun test() {
|
||||
val a = arrayOf(1, 2, 3)
|
||||
val b: Array<*>? = null
|
||||
val result = a.contentDeepEquals(b)
|
||||
}
|
||||
-1
@@ -1,5 +1,4 @@
|
||||
// WITH_STDLIB
|
||||
// PROBLEM: none
|
||||
import java.util.Arrays
|
||||
|
||||
fun test() {
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// WITH_STDLIB
|
||||
import java.util.Arrays
|
||||
|
||||
fun test() {
|
||||
val a = arrayOf(1, 2, 3)
|
||||
val b: Array<*>? = null
|
||||
val result = a.contentEquals(b)
|
||||
}
|
||||
-1
@@ -1,5 +1,4 @@
|
||||
// WITH_STDLIB
|
||||
// PROBLEM: none
|
||||
import java.util.Arrays
|
||||
|
||||
fun test() {
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// WITH_STDLIB
|
||||
import java.util.Arrays
|
||||
|
||||
fun test() {
|
||||
val a: Array<*>? = arrayOf(1)
|
||||
val str = a.contentToString()
|
||||
}
|
||||
Reference in New Issue
Block a user