Implemented fast search for binary operators

This commit is contained in:
Valentin Kipyatkov
2016-09-02 14:07:21 +03:00
parent f2c0d131e4
commit 1ca698cfc4
27 changed files with 225 additions and 93 deletions
+2 -2
View File
@@ -2,8 +2,8 @@
// OPTIONS: usages
class A(val n: Int) {
fun <caret>compareTo(other: A): Int = compareTo(other.n)
fun compareTo(m: Int): Int = n.compareTo(m)
infix operator fun <caret>compareTo(other: A): Int = compareTo(other.n)
infix operator fun compareTo(m: Int): Int = n.compareTo(m)
}
fun test() {
@@ -1,4 +1,13 @@
Resolved (x, y)
Resolved b1 + b2
Searched references to A
Searched references to B
Searched references to parameter b1 in f() in Kotlin files
Searched references to parameter b2 in f() in Kotlin files
Searched references to parameter other in plus() in Kotlin files
Searched references to plus() in Kotlin files
Used plain search in LocalSearchScope:
CLASS:A
Used plain search in whole search scope
Used plain search in LocalSearchScope:
CLASS:B
FUN:plus
+1 -1
View File
@@ -2,7 +2,7 @@
// OPTIONS: usages
class A(val n: Int) {
fun <caret>contains(k: Int): Boolean = k <= n
infix operator fun <caret>contains(k: Int): Boolean = k <= n
}
fun test() {
+1 -1
View File
@@ -3,7 +3,7 @@
// FIND_BY_REF
class A(val n: Int) {
override fun equals(other: Any?): Boolean = other is A && other.n <caret>== n
infix override fun equals(other: Any?): Boolean = other is A && other.n <caret>== n
}
fun test() {
@@ -1,4 +1,4 @@
Function call 10 A(0) == A(1)
Function call 11 A(0) != A(1)
Function call 12 A(0) equals A(1)
Function call 6 override fun equals(other: Any?): Boolean = other is A && other.n == n
Function call 6 infix override fun equals(other: Any?): Boolean = other is A && other.n == n
@@ -2,11 +2,11 @@
// OPTIONS: usages
class A<T: Any> {
public fun <caret>iterator(): Iterator<T> = throw IllegalStateException("")
operator fun <caret>iterator(): Iterator<T> = throw IllegalStateException("")
}
class B<T: Any> {
public fun iterator(): Iterator<T> = throw IllegalStateException("")
operator fun iterator(): Iterator<T> = throw IllegalStateException("")
}
fun test() {
+1 -1
View File
@@ -2,7 +2,7 @@
// OPTIONS: usages
class B(val n: Int) {
fun <caret>get(i: Int): B = B(i)
operator fun <caret>get(i: Int): B = B(i)
}
fun test() {
@@ -4,7 +4,7 @@
import kotlin.reflect.KProperty
class Delegate() {
fun <caret>getValue(thisRef: Any?, property: KProperty<*>): String = ":)"
operator fun <caret>getValue(thisRef: Any?, property: KProperty<*>): String = ":)"
}
val p: String by Delegate()
+1 -1
View File
@@ -2,7 +2,7 @@
// OPTIONS: usages
class A(val n: Int) {
fun <caret>inc(): A = A(n + 1)
operator fun <caret>inc(): A = A(n + 1)
}
fun test() {
+2 -2
View File
@@ -2,8 +2,8 @@
// OPTIONS: usages
class A(val n: Int) {
fun <caret>plus(m: Int): A = A(n + m)
fun plus(a: A): A = this + a.n
operator fun <caret>plus(m: Int): A = A(n + m)
operator fun plus(a: A): A = this + a.n
}
fun test() {
+28
View File
@@ -0,0 +1,28 @@
Checked type of a
Checked type of a
Resolved A(0) + A(1)
Resolved A(0) + A(1)
Resolved A(0) + A(1) + 2
Resolved A(0) + A(1) + 2
Resolved A(0) + A(1) + 2
Resolved A(0) + A(1) + 2
Resolved A(0) + A(1) + 2
Resolved A(0) + A(1) + 2
Resolved a += 1
Resolved a += 1
Resolved a += A(1)
Resolved a += A(1)
Searched references to A
Searched references to A
Searched references to A.plus() in Kotlin files
Searched references to A.plus() in Kotlin files
Searched references to A.plus() in Kotlin files
Searched references to A.plus() in Kotlin files
Searched references to a in Kotlin files
Searched references to a in Kotlin files
Searched references to parameter a in A.plus() in Kotlin files
Searched references to parameter a in A.plus() in Kotlin files
Used plain search in LocalSearchScope:
CLASS:A
Used plain search in LocalSearchScope:
CLASS:A
@@ -2,4 +2,4 @@ Function call 10 A(0) + A(1) + 2
Function call 11 A(0) plus A(1) plus 2
Function call 12 A(0).plus(A(1).plus(2))
Function call 15 a += 1
Function call 6 fun plus(a: A): A = this + a.n
Function call 6 operator fun plus(a: A): A = this + a.n
@@ -2,11 +2,11 @@
// OPTIONS: usages
class A(var n: Int) {
fun <caret>plusAssign(m: Int) {
operator fun <caret>plusAssign(m: Int) {
n += m
}
fun plusAssign(a: A) {
operator fun plusAssign(a: A) {
this += a.n
}
}
@@ -4,8 +4,9 @@
import kotlin.reflect.KProperty
class Delegate() {
fun getValue(thisRef: Any?, property: KProperty<*>): String = ":)"
fun setValue(thisRef: Any?, property: KProperty<*>, value: String) {
operator fun getValue(thisRef: Any?, property: KProperty<*>): String = ":)"
operator fun setValue(thisRef: Any?, property: KProperty<*>, value: String) {
}
fun <caret>propertyDelegated(property: KProperty<*>) {
@@ -1 +1 @@
Property delegation 15 var p: String by Delegate()
Property delegation 16 var p: String by Delegate()
+1 -1
View File
@@ -2,7 +2,7 @@
// OPTIONS: usages
class B(val n: Int) {
fun <caret>set(i: Int, a: B) {}
operator fun <caret>set(i: Int, a: B) {}
}
fun test() {
@@ -4,8 +4,9 @@
import kotlin.reflect.KProperty
class Delegate() {
fun getValue(thisRef: Any?, property: KProperty<*>): String = ":)"
fun <caret>setValue(thisRef: Any?, property: KProperty<*>, value: String) {
operator fun getValue(thisRef: Any?, property: KProperty<*>): String = ":)"
operator fun <caret>setValue(thisRef: Any?, property: KProperty<*>, value: String) {
}
}
@@ -1 +1 @@
Property delegation 13 var p: String by Delegate()
Property delegation 14 var p: String by Delegate()