Ignore sub-queries for other operators with the same receiver (KT-18566)

ExpressionsOfTypeProcessor searches for all occurence of expression
with given type. It start from usages of the class, searches for sub-classes,
declarations that return those classes, usages of these declarations,
and so on.

During this search, find usages for all operators that return the
subject type is executed as sub-queries. Full search for such queries
can't give addition types. And it also shouldn't give additional scopes
for search, because same scopes should be located by operands. In other
words, if sub-query can spot the scope of usage starting from the same
type, the original query should also process same scope.

 #KT-18566 Fixed
This commit is contained in:
Nikolay Krasko
2017-06-15 16:38:21 +03:00
parent 0f3dff44ac
commit 44d3b8fb1a
12 changed files with 168 additions and 54 deletions
@@ -1,5 +1,6 @@
Checked type of u1
Checked type of u2
ExpressionOfTypeProcessor is already started for UnaryNot. Exit for operator UnaryNot.not().
Resolved !u1
Searched references to UnaryNot
Searched references to UnaryNot.not() in non-Java files
@@ -4,6 +4,7 @@ Checked type of a2
Checked type of n1
Checked type of n2
Checked type of n2
ExpressionOfTypeProcessor is already started for A. Exit for operator parameter a of A(val a: A?, val n: Int).
Resolved (a1, n1)
Resolved (a2, n2)
Resolved (a2, n2)
@@ -2,6 +2,7 @@ Checked type of a1
Checked type of b
Checked type of n
Checked type of s
ExpressionOfTypeProcessor is already started for A. Exit for operator parameter b of A(val b: B, val n: Int).
Resolved (a1, s)
Resolved (b, n)
Searched references to A
+1
View File
@@ -1,4 +1,5 @@
Checked type of a
ExpressionOfTypeProcessor is already started for A. Exit for operator A.inc().
Resolved ++a
Resolved a++
Searched references to A
+2 -20
View File
@@ -1,39 +1,21 @@
Checked type of a
Checked type of a
Checked type of a1
Checked type of a1
Checked type of a2
Checked type of a2
Resolved A(0) + A(1)
ExpressionOfTypeProcessor is already started for A. Exit for operator A.plus(a: A).
ExpressionOfTypeProcessor is already started for A. Exit for operator A.plus(m: Int).
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 += 1
Resolved a += 1
Resolved a += A(1)
Resolved a += A(1)
Resolved a1 + 1
Resolved a1 + 1
Searched references to A
Searched references to A
Searched references to A.plus(a: A) in non-Java files
Searched references to A.plus(a: A) in non-Java files
Searched references to A.plus(m: Int) in non-Java files
Searched references to A.plus(m: Int) in non-Java files
Searched references to a in non-Java files
Searched references to a in non-Java files
Searched references to a1 in non-Java files
Searched references to a1 in non-Java files
Searched references to a2 in non-Java files
Searched references to a2 in non-Java files
Searched references to parameter a of A.plus(a: A) in non-Java files
Searched references to parameter a of A.plus(a: A) in non-Java files
Searched references to parameter array of test(array: Array<A>) in non-Java files
Searched references to parameter array of test(array: Array<A>) in non-Java files
Used plain search of A.plus(a: A) in LocalSearchScope:
CLASS:A
Used plain search of A.plus(m: Int) in LocalSearchScope:
CLASS:A
@@ -0,0 +1,39 @@
// PSI_ELEMENT: org.jetbrains.kotlin.psi.KtNamedFunction
// OPTIONS: usages
open class Diction {
operator fun <caret>minus(other: Diction): Diction { return Diction() }
operator fun plus(other: Diction): Diction { return Diction() }
}
operator fun Diction.times(other: Diction) = Diction()
class A
operator fun A.div(other: A) = Diction()
fun indirectDiction() = A() / A()
fun indirectPlusDiction() = indirectDiction() + indirectDiction()
val t = { d: Diction -> d + d }
val tt = { t(indirectDiction()) }
fun test1(d1: Diction, d2: Diction) {
val a = d1 + d2
val b = d1 - d2
val c = d1 * d2
val d = b - c
}
fun test2() {
val dInT2 = indirectDiction()
dInT2 - dInT2
}
fun test3() {
val dInT3 = indirectPlusDiction()
dInT3 - dInT3
}
fun test4() {
tt() - tt()
}
@@ -0,0 +1,61 @@
Checked type of a
Checked type of a
Checked type of b
Checked type of b
Checked type of c
Checked type of c
Checked type of d
Checked type of d
Checked type of dInT2
Checked type of dInT3
Checked type of div(other: A)
Checked type of indirectDiction()
Checked type of indirectDiction()
Checked type of indirectDiction()
Checked type of indirectPlusDiction()
Checked type of indirectPlusDiction()
Checked type of t
Checked type of t
Checked type of times(other: Diction)
Checked type of tt
Checked type of tt
ExpressionOfTypeProcessor is already started for Diction. Exit for operator Diction.minus(other: Diction).
ExpressionOfTypeProcessor is already started for Diction. Exit for operator Diction.plus(other: Diction).
ExpressionOfTypeProcessor is already started for Diction. Exit for operator times(other: Diction).
Resolved A() / A()
Resolved b - c
Resolved d1 - d2
Resolved dInT2 - dInT2
Resolved dInT3 - dInT3
Resolved tt() - tt()
Searched references to A
Searched references to Diction
Searched references to Diction.minus(other: Diction) in non-Java files
Searched references to Diction.plus(other: Diction) in non-Java files
Searched references to a in non-Java files
Searched references to b in non-Java files
Searched references to c in non-Java files
Searched references to d in non-Java files
Searched references to dInT2 in non-Java files
Searched references to dInT3 in non-Java files
Searched references to div(other: A) in non-Java files
Searched references to indirectDiction() in non-Java files
Searched references to indirectPlusDiction() in non-Java files
Searched references to parameter d of <anonymous>d: Diction in non-Java files
Searched references to parameter d1 of test1(d1: Diction, d2: Diction) in non-Java files
Searched references to parameter d2 of test1(d1: Diction, d2: Diction) in non-Java files
Searched references to parameter other of Diction.minus(other: Diction) in non-Java files
Searched references to parameter other of Diction.plus(other: Diction) in non-Java files
Searched references to parameter other of div(other: A) in non-Java files
Searched references to parameter other of times(other: Diction) in non-Java files
Searched references to t in non-Java files
Searched references to times(other: Diction) in non-Java files
Searched references to tt in non-Java files
Used plain search of Diction.minus(other: Diction) in LocalSearchScope:
CLASS:Diction
FUN:times
{ d: Diction -> d + d }
{ t(indirectDiction()) }
Used plain search of div(other: A) in LocalSearchScope:
CLASS:A
FUN:div
@@ -0,0 +1,5 @@
Function call 22 val b = d1 - d2
Function call 24 val d = b - c
Function call 29 dInT2 - dInT2
Function call 34 dInT3 - dInT3
Function call 38 tt() - tt()
@@ -1,3 +1,4 @@
ExpressionOfTypeProcessor is already started for A. Exit for operator A.unaryMinus().
Resolved -A(1)
Searched references to A
Searched references to A.unaryMinus() in non-Java files