Refactoring: make "replace call with binary operator" an inspection
This commit is contained in:
-1
@@ -1 +0,0 @@
|
||||
org.jetbrains.kotlin.idea.intentions.conventionNameCalls.ReplaceCallWithBinaryOperatorIntention
|
||||
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
// INTENTION_TEXT: Replace with '/' operator
|
||||
fun test() {
|
||||
class Test {
|
||||
operator fun div(a: Int): Test = Test()
|
||||
}
|
||||
val test = Test()
|
||||
test.div<caret>(1)
|
||||
}
|
||||
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
// INTENTION_TEXT: Replace with '/' operator
|
||||
fun test() {
|
||||
class Test {
|
||||
operator fun div(a: Int): Test = Test()
|
||||
}
|
||||
val test = Test()
|
||||
test / 1
|
||||
}
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
// INTENTION_TEXT: Replace with '==' operator
|
||||
|
||||
val x = 2.equals<caret>(2)
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
// INTENTION_TEXT: Replace with '==' operator
|
||||
|
||||
val x = 2 == 2
|
||||
Vendored
-3
@@ -1,3 +0,0 @@
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
val x = 2.compareTo<caret>(2) == 0
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
class Foo
|
||||
|
||||
fun Foo?.equals(other: Foo?) = true
|
||||
|
||||
fun bar(f1: Foo?, f2: Foo?) {
|
||||
if (f1.equals<caret>(f2)) {
|
||||
|
||||
}
|
||||
}
|
||||
Vendored
-6
@@ -1,6 +0,0 @@
|
||||
fun test() {
|
||||
class Test()
|
||||
operator fun Test.div(a: Int): Test = Test()
|
||||
val test = Test()
|
||||
test.div<caret>(1)
|
||||
}
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
fun test() {
|
||||
class Test()
|
||||
operator fun Test.div(a: Int): Test = Test()
|
||||
val test = Test()
|
||||
test / 1
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
fun test() {
|
||||
class Test {
|
||||
operator fun plus(fn: () -> Test): Test = fn()
|
||||
}
|
||||
val test = Test()
|
||||
test.pl<caret>us {
|
||||
Test()
|
||||
}
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
fun test() {
|
||||
class Test {
|
||||
operator fun plus(fn: () -> Test): Test = fn()
|
||||
}
|
||||
val test = Test()
|
||||
test + {
|
||||
Test()
|
||||
}
|
||||
}
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
// INTENTION_TEXT: Replace with '>' operator
|
||||
|
||||
val x = 3.compareTo<caret>(2) > 0
|
||||
Vendored
-3
@@ -1,3 +0,0 @@
|
||||
// INTENTION_TEXT: Replace with '>' operator
|
||||
|
||||
val x = 3 > 2
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
// INTENTION_TEXT: Replace with '<=' operator
|
||||
|
||||
val x = 0 >= 4.compareTo<caret>(5)
|
||||
Vendored
-3
@@ -1,3 +0,0 @@
|
||||
// INTENTION_TEXT: Replace with '<=' operator
|
||||
|
||||
val x = 4 <= 5
|
||||
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
// INTENTION_TEXT: Replace with '-' operator
|
||||
fun test() {
|
||||
class Test {
|
||||
operator fun minus(a: Int): Test = Test()
|
||||
}
|
||||
val test = Test()
|
||||
test.min<caret>us(1)
|
||||
}
|
||||
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
// INTENTION_TEXT: Replace with '-' operator
|
||||
fun test() {
|
||||
class Test {
|
||||
operator fun minus(a: Int): Test = Test()
|
||||
}
|
||||
val test = Test()
|
||||
test - 1
|
||||
}
|
||||
idea/testData/intentions/conventionNameCalls/replaceCallWithBinaryOperator/missingDefaultArgument.kt
Vendored
-9
@@ -1,9 +0,0 @@
|
||||
// IS_APPLICABLE: false
|
||||
// ERROR: 'operator' modifier is inapplicable on this function: must have a single value parameter
|
||||
fun test() {
|
||||
class Test{
|
||||
operator fun plus(a: Int=1, b: Int=2) : Int = 0
|
||||
}
|
||||
val test = Test()
|
||||
test.p<caret>lus(b=3)
|
||||
}
|
||||
Vendored
-10
@@ -1,10 +0,0 @@
|
||||
// INTENTION_TEXT: Replace call with binary operator
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
fun test() {
|
||||
class Test {
|
||||
operator fun mod(a: Int): Test = Test()
|
||||
}
|
||||
val test = Test()
|
||||
test.mod<caret>(1)
|
||||
}
|
||||
Vendored
-10
@@ -1,10 +0,0 @@
|
||||
// INTENTION_TEXT: Replace with '%' operator
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
fun test() {
|
||||
class Test {
|
||||
operator fun mod(a: Int): Test = Test()
|
||||
}
|
||||
val test = Test()
|
||||
test % 1
|
||||
}
|
||||
Vendored
-9
@@ -1,9 +0,0 @@
|
||||
// IS_APPLICABLE: false
|
||||
// ERROR: 'operator' modifier is inapplicable on this function: must have a single value parameter
|
||||
fun test() {
|
||||
class Test {
|
||||
operator fun plus(a: Int, b: Int): Test = Test()
|
||||
}
|
||||
val test = Test()
|
||||
test.pl<caret>us(1, 2)
|
||||
}
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
// INTENTION_TEXT: Replace with '!=' operator
|
||||
|
||||
val x = !2.equals<caret>(3)
|
||||
Vendored
-3
@@ -1,3 +0,0 @@
|
||||
// INTENTION_TEXT: Replace with '!=' operator
|
||||
|
||||
val x = 2 != 3
|
||||
Vendored
-3
@@ -1,3 +0,0 @@
|
||||
// INTENTION_TEXT: Replace with '!=' operator
|
||||
|
||||
val x = !(2.equals<caret>(3))
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
// INTENTION_TEXT: Replace with '!=' operator
|
||||
|
||||
val x = 2 != 3
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
// INTENTION_TEXT: Replace with '==' operator
|
||||
|
||||
val x = !(2.equals<caret>(3) && 4.equals(5))
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
// INTENTION_TEXT: Replace with '==' operator
|
||||
|
||||
val x = !(2 == 3 && 4.equals(5))
|
||||
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
// INTENTION_TEXT: Replace with '+' operator
|
||||
fun test() {
|
||||
class Test {
|
||||
operator fun plus(a: Int): Test = Test()
|
||||
}
|
||||
val test = Test()
|
||||
test.pl<caret>us(1)
|
||||
}
|
||||
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
// INTENTION_TEXT: Replace with '+' operator
|
||||
fun test() {
|
||||
class Test {
|
||||
operator fun plus(a: Int): Test = Test()
|
||||
}
|
||||
val test = Test()
|
||||
test + 1
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
class C {
|
||||
companion object {
|
||||
operator fun plus(s: String): C = C()
|
||||
}
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
C.<caret>plus("x")
|
||||
}
|
||||
Vendored
-9
@@ -1,9 +0,0 @@
|
||||
class C {
|
||||
companion object {
|
||||
operator fun plus(s: String): C = C()
|
||||
}
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
C + "x"
|
||||
}
|
||||
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
// INTENTION_TEXT: Replace with '..' operator
|
||||
fun test() {
|
||||
class Test {
|
||||
operator fun rangeTo(a: Int): Test = Test()
|
||||
}
|
||||
val test = Test()
|
||||
test.rangeTo<caret>(1)
|
||||
}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
// INTENTION_TEXT: Replace with '..' operator
|
||||
fun test() {
|
||||
class Test {
|
||||
operator fun rangeTo(a: Int): Test = Test()
|
||||
}
|
||||
val test = Test()
|
||||
test..1
|
||||
}
|
||||
Vendored
-9
@@ -1,9 +0,0 @@
|
||||
// INTENTION_TEXT: Replace with '%' operator
|
||||
|
||||
fun test() {
|
||||
class Test {
|
||||
operator fun rem(a: Int): Test = Test()
|
||||
}
|
||||
val test = Test()
|
||||
test.rem<caret>(1)
|
||||
}
|
||||
Vendored
-9
@@ -1,9 +0,0 @@
|
||||
// INTENTION_TEXT: Replace with '%' operator
|
||||
|
||||
fun test() {
|
||||
class Test {
|
||||
operator fun rem(a: Int): Test = Test()
|
||||
}
|
||||
val test = Test()
|
||||
test % 1
|
||||
}
|
||||
Vendored
-5
@@ -1,5 +0,0 @@
|
||||
// IS_APPLICABLE: false
|
||||
// ERROR: Operator call corresponds to a dot-qualified call 'nullable?.compareTo(1).compareTo(0)' which is not allowed on a nullable receiver 'nullable?.compareTo(1)'.
|
||||
|
||||
val nullable: Int? = null
|
||||
val x = nullable?.compareTo<caret>(1) >= 0
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
open class Base {
|
||||
open operator fun plus(s: String) = ""
|
||||
}
|
||||
|
||||
class C : Base() {
|
||||
override fun plus(s: String): String {
|
||||
return super.<caret>plus(s)
|
||||
}
|
||||
}
|
||||
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
// INTENTION_TEXT: Replace with '*' operator
|
||||
fun test() {
|
||||
class Test {
|
||||
operator fun times(a: Int): Test = Test()
|
||||
}
|
||||
val test = Test()
|
||||
test.time<caret>s(1)
|
||||
}
|
||||
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
// INTENTION_TEXT: Replace with '*' operator
|
||||
fun test() {
|
||||
class Test {
|
||||
operator fun times(a: Int): Test = Test()
|
||||
}
|
||||
val test = Test()
|
||||
test * 1
|
||||
}
|
||||
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
// IS_APPLICABLE: false
|
||||
fun test() {
|
||||
class Test {
|
||||
operator fun <T> div(a: Test): T? = a as? T
|
||||
}
|
||||
val test = Test()
|
||||
test.div<caret><Int>(Test())
|
||||
}
|
||||
Vendored
-9
@@ -1,9 +0,0 @@
|
||||
// IS_APPLICABLE: false
|
||||
// ERROR: 'operator' modifier is inapplicable on this function: must have a single value parameter
|
||||
fun test() {
|
||||
class Test{
|
||||
operator fun plus(vararg b: Int, c: Int = 0): Int = 0
|
||||
}
|
||||
val test = Test()
|
||||
test.plus<caret>(c=5)
|
||||
}
|
||||
Vendored
-9
@@ -1,9 +0,0 @@
|
||||
// IS_APPLICABLE: false
|
||||
// ERROR: 'operator' modifier is inapplicable on this function: must have a single value parameter
|
||||
fun test() {
|
||||
class Test{
|
||||
operator fun plus(vararg b: Int, c: Int = 0): Int = 0
|
||||
}
|
||||
val test = Test()
|
||||
test.plus<caret>(0, 1)
|
||||
}
|
||||
Vendored
-7
@@ -1,7 +0,0 @@
|
||||
fun test() {
|
||||
class Test {
|
||||
operator fun plus(a: Int): Test = Test()
|
||||
}
|
||||
val test = Test()
|
||||
test.pl<caret>us(a=1)
|
||||
}
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
fun test() {
|
||||
class Test {
|
||||
operator fun plus(a: Int): Test = Test()
|
||||
}
|
||||
val test = Test()
|
||||
test + 1
|
||||
}
|
||||
Reference in New Issue
Block a user