Find Usages: Look for as-property usages of Java methods

This commit is contained in:
Alexey Sedunov
2015-10-21 12:44:59 +03:00
committed by Alexey Sedunov
parent 7e9222f70a
commit 9c360ef05a
34 changed files with 555 additions and 108 deletions
@@ -0,0 +1,29 @@
// PSI_ELEMENT: com.intellij.psi.PsiMethod
// OPTIONS: usages
public class J extends A {
@Override
public int <caret>getP() {
return 1;
}
@Override
public void setP(int value) {
}
}
class Test {
static void test() {
new A().getP();
new A().setP(1);
new AA().getP();
new AA().setP(1);
new J().getP();
new J().setP(1);
new B().getP();
new B().setP(1);
}
}
@@ -0,0 +1,25 @@
open class A {
open var p: Int = 1
}
class AA : A() {
override var p: Int = 1
}
class B : J() {
override var p: Int = 1
}
fun test() {
val t = A().p
A().p = 1
val t = AA().p
AA().p = 1
val t = J().p
J().p = 1
val t = B().p
B().p = 1
}
@@ -0,0 +1,4 @@
[javaPropertyGetterUsagesKJ.0.java] Unclassified usage (23: 17) new J().getP();
[javaPropertyGetterUsagesKJ.0.java] Unclassified usage (26: 17) new B().getP();
[javaPropertyGetterUsagesKJ.1.kt] Value read (20: 17) val t = J().p
[javaPropertyGetterUsagesKJ.1.kt] Value read (23: 17) val t = B().p
@@ -0,0 +1,29 @@
// PSI_ELEMENT: com.intellij.psi.PsiMethod
// OPTIONS: usages
public class J extends A {
@Override
public int getP() {
return 1;
}
@Override
public void <caret>setP(int value) {
}
}
class Test {
static void test() {
new A().getP();
new A().setP(1);
new AA().getP();
new AA().setP(1);
new J().getP();
new J().setP(1);
new B().getP();
new B().setP(1);
}
}
@@ -0,0 +1,25 @@
open class A {
open var p: Int = 1
}
class AA : A() {
override var p: Int = 1
}
class B : J() {
override var p: Int = 1
}
fun test() {
val t = A().p
A().p = 1
val t = AA().p
AA().p = 1
val t = J().p
J().p = 1
val t = B().p
B().p = 1
}
@@ -0,0 +1,4 @@
[javaPropertySetterUsagesKJ.0.java] Unclassified usage (24: 17) new J().setP(1);
[javaPropertySetterUsagesKJ.0.java] Unclassified usage (27: 17) new B().setP(1);
[javaPropertySetterUsagesKJ.1.kt] Value write (21: 9) J().p = 1
[javaPropertySetterUsagesKJ.1.kt] Value write (24: 9) B().p = 1
+2 -1
View File
@@ -1,8 +1,9 @@
// PSI_ELEMENT: org.jetbrains.kotlin.psi.KtNamedFunction
// OPTIONS: usages
// FIND_BY_REF
class A(val n: Int) {
override fun <caret>equals(other: Any?): Boolean = other is A && other.n == n
override fun equals(other: Any?): Boolean = other is A && other.n <caret>== n
}
fun test() {
@@ -1,4 +1,4 @@
Function call (10: 10) A(0) != A(1)
Function call (11: 10) A(0) equals A(1)
Function call (5: 71) override fun equals(other: Any?): Boolean = other is A && other.n == n
Function call (9: 10) A(0) == A(1)
Function call (10: 10) A(0) == A(1)
Function call (11: 10) A(0) != A(1)
Function call (12: 10) A(0) equals A(1)
Function call (6: 71) override fun equals(other: Any?): Boolean = other is A && other.n == n
@@ -6,11 +6,11 @@ interface A {
}
class B: A {
override fun <caret>foo() {} // Find usages gives no results
override fun foo() {} // Find usages gives no results
}
fun main(a: A) {
a.foo()
a.<caret>foo()
}
// for KT-3769 Find usages gives no result for overrides
@@ -0,0 +1,27 @@
// PSI_ELEMENT: org.jetbrains.kotlin.psi.KtProperty
// OPTIONS: usages
open class A {
open var <caret>p: Int = 1
}
class AA : A() {
override var p: Int = 1
}
class B : J() {
override var p: Int = 1
}
fun test() {
val t = A().p
A().p = 1
val t = AA().p
AA().p = 1
val t = J().p
J().p = 1
val t = B().p
B().p = 1
}
@@ -0,0 +1,27 @@
public class J extends A {
@Override
public int getP() {
return 1;
}
@Override
public void setP(int value) {
}
}
class Test {
static void test() {
new A().getP();
new A().setP(1);
new AA().getP();
new AA().setP(1);
new J().getP();
new J().setP(1);
new B().getP();
new B().setP(1);
}
}
@@ -0,0 +1,16 @@
[javaPropertyUsagesK.0.kt] Value read (16: 17) val t = A().p
[javaPropertyUsagesK.0.kt] Value read (19: 18) val t = AA().p
[javaPropertyUsagesK.0.kt] Value read (22: 17) val t = J().p
[javaPropertyUsagesK.0.kt] Value read (25: 17) val t = B().p
[javaPropertyUsagesK.0.kt] Value write (17: 9) A().p = 1
[javaPropertyUsagesK.0.kt] Value write (20: 10) AA().p = 1
[javaPropertyUsagesK.0.kt] Value write (23: 9) J().p = 1
[javaPropertyUsagesK.0.kt] Value write (26: 9) B().p = 1
[javaPropertyUsagesK.1.java] Unclassified usage (15: 17) new A().getP();
[javaPropertyUsagesK.1.java] Unclassified usage (16: 17) new A().setP(1);
[javaPropertyUsagesK.1.java] Unclassified usage (18: 18) new AA().getP();
[javaPropertyUsagesK.1.java] Unclassified usage (19: 18) new AA().setP(1);
[javaPropertyUsagesK.1.java] Unclassified usage (21: 17) new J().getP();
[javaPropertyUsagesK.1.java] Unclassified usage (22: 17) new J().setP(1);
[javaPropertyUsagesK.1.java] Unclassified usage (24: 17) new B().getP();
[javaPropertyUsagesK.1.java] Unclassified usage (25: 17) new B().setP(1);
@@ -0,0 +1,27 @@
// PSI_ELEMENT: org.jetbrains.kotlin.psi.KtProperty
// OPTIONS: usages
open class A {
open var p: Int = 1
}
class AA : A() {
override var p: Int = 1
}
class B : J() {
override var <caret>p: Int = 1
}
fun test() {
val t = A().p
A().p = 1
val t = AA().p
AA().p = 1
val t = J().p
J().p = 1
val t = B().p
B().p = 1
}
@@ -0,0 +1,27 @@
public class J extends A {
@Override
public int getP() {
return 1;
}
@Override
public void setP(int value) {
}
}
class Test {
static void test() {
new A().getP();
new A().setP(1);
new AA().getP();
new AA().setP(1);
new J().getP();
new J().setP(1);
new B().getP();
new B().setP(1);
}
}
@@ -0,0 +1,4 @@
[javaPropertyUsagesKJK.0.kt] Value read (25: 17) val t = B().p
[javaPropertyUsagesKJK.0.kt] Value write (26: 9) B().p = 1
[javaPropertyUsagesKJK.1.java] Unclassified usage (24: 17) new B().getP();
[javaPropertyUsagesKJK.1.java] Unclassified usage (25: 17) new B().setP(1);
@@ -0,0 +1,27 @@
// PSI_ELEMENT: org.jetbrains.kotlin.psi.KtProperty
// OPTIONS: usages
open class A {
open var p: Int = 1
}
class AA : A() {
override var <caret>p: Int = 1
}
class B : J() {
override var p: Int = 1
}
fun test() {
val t = A().p
A().p = 1
val t = AA().p
AA().p = 1
val t = J().p
J().p = 1
val t = B().p
B().p = 1
}
@@ -0,0 +1,27 @@
public class J extends A {
@Override
public int getP() {
return 1;
}
@Override
public void setP(int value) {
}
}
class Test {
static void test() {
new A().getP();
new A().setP(1);
new AA().getP();
new AA().setP(1);
new J().getP();
new J().setP(1);
new B().getP();
new B().setP(1);
}
}
@@ -0,0 +1,4 @@
[javaPropertyUsagesKK.0.kt] Value read (19: 18) val t = AA().p
[javaPropertyUsagesKK.0.kt] Value write (20: 10) AA().p = 1
[javaPropertyUsagesKK.1.java] Unclassified usage (18: 18) new AA().getP();
[javaPropertyUsagesKK.1.java] Unclassified usage (19: 18) new AA().setP(1);