Implemented Operator To Function intention action.
Converts +a, --a, a * b, a..b, a %= b, a in b, etc. to their function call counterparts.
This commit is contained in:
committed by
Alexey Sedunov
parent
5550924dc5
commit
b3842285e8
@@ -0,0 +1,7 @@
|
||||
class Bar {
|
||||
fun get(vararg args: Int) {}
|
||||
}
|
||||
|
||||
fun foo(a: Bar, i: Int) {
|
||||
a<caret>[i, 1]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class Bar {
|
||||
fun get(vararg args: Int) {}
|
||||
}
|
||||
|
||||
fun foo(a: Bar, i: Int) {
|
||||
a.get(i, 1)
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun foo(a: Array<Int>, i: Int) {
|
||||
a<caret>[i]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun foo(a: Array<Int>, i: Int) {
|
||||
a.get(i)
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// ERROR: Unresolved reference: array
|
||||
fun foo(b: Int) {
|
||||
var a = array(1, 2, 3, 4, 5)
|
||||
a<caret>[2, 3] = b
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// ERROR: Unresolved reference: array
|
||||
fun foo(b: Int) {
|
||||
var a = array(1, 2, 3, 4, 5)
|
||||
a.set(2, 3, b)
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun foo(a: String?, b: String?) {
|
||||
a <caret>== b
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun foo(a: String?, b: String?) {
|
||||
a?.equals(b) ?: b.identityEquals(null)
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun foo(a: Int, b: Int) {
|
||||
a !<caret>= b
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun foo(a: Int, b: Int) {
|
||||
!a.equals(b)
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo(a: Int, b: Array<Int>) {
|
||||
a <caret>!in b
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo(a: Int, b: Array<Int>) {
|
||||
!b.contains(a)
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun foo(a: Int, b: Int) {
|
||||
a <caret>+ b
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun foo(a: Int, b: Int) {
|
||||
a.plus(b)
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
class Bar {
|
||||
fun plusAssign(arg: Bar) {}
|
||||
}
|
||||
|
||||
fun foo(b: Bar) {
|
||||
var a = Bar()
|
||||
a <caret>+= b
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
class Bar {
|
||||
fun plusAssign(arg: Bar) {}
|
||||
}
|
||||
|
||||
fun foo(b: Bar) {
|
||||
var a = Bar()
|
||||
a.plusAssign(b)
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
fun foo(b: Int) {
|
||||
var a = 0
|
||||
a <caret>+= b
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
fun foo(b: Int) {
|
||||
var a = 0
|
||||
a = a.plus(b)
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun foo(a: Int, b: Int) {
|
||||
a<caret>..b
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun foo(a: Int, b: Int) {
|
||||
a.rangeTo(b)
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class bar() {
|
||||
fun invoke(i: Any?, j: Any?) : Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
fun foo(i: Any?, j: Any?) {
|
||||
val test = bar()<caret>(i, j)
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class bar() {
|
||||
fun invoke(i: Any?, j: Any?) : Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
fun foo(i: Any?, j: Any?) {
|
||||
val test = bar().invoke(i, j)
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class Mocha() {
|
||||
fun invoke(x: Int, y: String, f: (Int) -> String) {
|
||||
}
|
||||
}
|
||||
fun main() {
|
||||
val mocha = Mocha()
|
||||
val testing = mocha<caret>(1, "fire"){ (x: Int) -> "hello world" }
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class Mocha() {
|
||||
fun invoke(x: Int, y: String, f: (Int) -> String) {
|
||||
}
|
||||
}
|
||||
fun main() {
|
||||
val mocha = Mocha()
|
||||
val testing = mocha.invoke(1, "fire"){ (x: Int) -> "hello world" }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class Mocha() {
|
||||
fun invoke(f: (Int) -> String) {}
|
||||
}
|
||||
fun main() {
|
||||
val mocha = Mocha()
|
||||
val testing = mocha<caret>{ (x: Int) -> "hello world" }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class Mocha() {
|
||||
fun invoke(f: (Int) -> String) {}
|
||||
}
|
||||
fun main() {
|
||||
val mocha = Mocha()
|
||||
val testing = mocha.invoke{ (x: Int) -> "hello world" }
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
fun foo(b: Any) {
|
||||
var a: Any
|
||||
a =<caret> b
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// IS_APPLICABLE: false
|
||||
class coffee() {
|
||||
fun invoke() {
|
||||
}
|
||||
}
|
||||
fun main() {
|
||||
val f = coffee().<caret>invoke()
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
fun foo() {
|
||||
val bar = { (x: Int) -> x + 1 }
|
||||
val incremented = listOf(1, 2, 3).<caret>map(bar)
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
class bar() {}
|
||||
fun main() {
|
||||
val x = bar<caret>()
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
fun foo() {
|
||||
var a = 5
|
||||
<caret>a--
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
fun foo() {
|
||||
var a = 5
|
||||
a.dec()
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun foo(a: Int) {
|
||||
+<caret>a
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun foo(a: Int) {
|
||||
a.plus()
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
fun foo() {
|
||||
var a = 0
|
||||
++<caret>a
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
fun foo() {
|
||||
var a = 0
|
||||
a.inc()
|
||||
}
|
||||
Reference in New Issue
Block a user