Add an intention to simplify negated binary expressions
Given an expression of the form `!(a op b)`, replace it with `a !op b`.
For example:
!(a < b) -> a >= b
!(a is Int) -> a !is int
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
// INTENTION_TEXT: Simplify negated '==' expression to '!='
|
||||
fun test(n: Int) {
|
||||
!(0<caret> == 1)
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// INTENTION_TEXT: Simplify negated '==' expression to '!='
|
||||
fun test(n: Int) {
|
||||
0 != 1
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// INTENTION_TEXT: Simplify negated '>' expression to '<='
|
||||
fun test(n: Int) {
|
||||
!(0<caret> > 1)
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// INTENTION_TEXT: Simplify negated '>' expression to '<='
|
||||
fun test(n: Int) {
|
||||
0 <= 1
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// INTENTION_TEXT: Simplify negated '>=' expression to '<'
|
||||
fun test(n: Int) {
|
||||
!(0<caret> >= 1)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// INTENTION_TEXT: Simplify negated '>=' expression to '<'
|
||||
fun test(n: Int) {
|
||||
0 < 1
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// INTENTION_TEXT: Simplify negated 'in' expression to '!in'
|
||||
fun test(n: Int) {
|
||||
val arr = ArrayList<Int>(1)
|
||||
!(0<caret> in arr)
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// INTENTION_TEXT: Simplify negated 'in' expression to '!in'
|
||||
fun test(n: Int) {
|
||||
val arr = ArrayList<Int>(1)
|
||||
0 !in arr
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
fun lt(a: Int, b: Int): Boolean = a < b
|
||||
fun test(n: Int) {
|
||||
!(1<caret> lt 2)
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// INTENTION_TEXT: Simplify negated 'is' expression to '!is'
|
||||
fun test(n: Int) {
|
||||
!(0<caret> is Int)
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// INTENTION_TEXT: Simplify negated 'is' expression to '!is'
|
||||
fun test(n: Int) {
|
||||
0 !is Int
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// INTENTION_TEXT: Simplify negated '<' expression to '>='
|
||||
fun test(n: Int) {
|
||||
!(0<caret> < 1)
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// INTENTION_TEXT: Simplify negated '<' expression to '>='
|
||||
fun test(n: Int) {
|
||||
0 >= 1
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// INTENTION_TEXT: Simplify negated '<=' expression to '>'
|
||||
fun test(n: Int) {
|
||||
!(0<caret> <= 1)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// INTENTION_TEXT: Simplify negated '<=' expression to '>'
|
||||
fun test(n: Int) {
|
||||
0 > 1
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// INTENTION_TEXT: Simplify negated '!=' expression to '=='
|
||||
fun test(n: Int) {
|
||||
!(0<caret> != 1)
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// INTENTION_TEXT: Simplify negated '!=' expression to '=='
|
||||
fun test(n: Int) {
|
||||
0 == 1
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// INTENTION_TEXT: Simplify negated '!in' expression to 'in'
|
||||
fun test(n: Int) {
|
||||
val arr = ArrayList<Int>(1)
|
||||
!(0<caret> !in arr)
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// INTENTION_TEXT: Simplify negated '!in' expression to 'in'
|
||||
fun test(n: Int) {
|
||||
val arr = ArrayList<Int>(1)
|
||||
0 in arr
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// INTENTION_TEXT: Simplify negated '!is' expression to 'is'
|
||||
fun test(n: Int) {
|
||||
!(0<caret> !is Int)
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// INTENTION_TEXT: Simplify negated '!is' expression to 'is'
|
||||
fun test(n: Int) {
|
||||
0 is Int
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// IS_APPLICABLE: false
|
||||
fun test(n: Int) {
|
||||
!<caret>true
|
||||
}
|
||||
Reference in New Issue
Block a user