Navigation: Implement proper getOriginalElement() for Kotlin declarations.
Run find usages tests with library for both original and navigation elements. Drop duplicating tests. Simplify test class. TODO: Some usages are not found yet since light methods built from library files do not retain original declarations
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
package library;
|
||||
|
||||
open class A(n: Int) {
|
||||
constructor(): this(1)
|
||||
|
||||
open class T(n: Int) {
|
||||
constructor(): this(1)
|
||||
|
||||
fun bar(b: Int): Int = b
|
||||
}
|
||||
|
||||
fun foo(a: Int): Int = a
|
||||
}
|
||||
|
||||
class B: A {
|
||||
constructor(n: Int): super(n)
|
||||
|
||||
class U: A.T {
|
||||
constructor(n: Int): super(n)
|
||||
}
|
||||
}
|
||||
|
||||
class C(): A(1) {
|
||||
class V(): A.T(1)
|
||||
}
|
||||
|
||||
class BB: A {
|
||||
constructor(): super()
|
||||
|
||||
class UU: A.T {
|
||||
constructor(): super()
|
||||
}
|
||||
}
|
||||
|
||||
class CC(): A() {
|
||||
class VV(): A.T()
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
|
||||
object O {
|
||||
|
||||
}
|
||||
|
||||
fun test() {
|
||||
foo()
|
||||
val f = ::foo
|
||||
|
||||
val o = O
|
||||
|
||||
val a = A(1)
|
||||
val aa = A()
|
||||
|
||||
a.foo(2)
|
||||
val ff = A::foo
|
||||
|
||||
val t = A.T(1)
|
||||
val tt = A.T()
|
||||
t.bar(2)
|
||||
val fff = A.T::bar
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
// PSI_ELEMENT: com.intellij.psi.PsiClass
|
||||
// OPTIONS: usages
|
||||
// FIND_BY_REF
|
||||
// FIND_BY_MIRROR_ELEMENT
|
||||
fun test() {
|
||||
<caret>System.exit(0)
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
Nested class/object (6: 5) System.exit(0)
|
||||
@@ -1,9 +0,0 @@
|
||||
// PSI_ELEMENT: com.intellij.psi.PsiField
|
||||
// OPTIONS: usages
|
||||
// FIND_BY_REF
|
||||
// FIND_BY_MIRROR_ELEMENT
|
||||
import java.awt.Dimension
|
||||
|
||||
fun test() {
|
||||
Dimension().<caret>width = 1
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
Value write (8: 17) Dimension().width = 1
|
||||
@@ -1,9 +0,0 @@
|
||||
// PSI_ELEMENT: com.intellij.psi.PsiMethod
|
||||
// OPTIONS: usages
|
||||
// FIND_BY_REF
|
||||
// FIND_BY_MIRROR_ELEMENT
|
||||
import java.awt.Dimension
|
||||
|
||||
fun test() {
|
||||
Dimension().<caret>setSize(1.0, 2.0)
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
Function call (8: 17) Dimension().setSize(1.0, 2.0)
|
||||
@@ -1,7 +0,0 @@
|
||||
// PSI_ELEMENT: com.intellij.psi.PsiField
|
||||
// OPTIONS: usages
|
||||
// FIND_BY_REF
|
||||
// FIND_BY_MIRROR_ELEMENT
|
||||
fun test() {
|
||||
System.<caret>out.println()
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
Receiver (6: 12) System.out.println()
|
||||
@@ -1,7 +0,0 @@
|
||||
// PSI_ELEMENT: com.intellij.psi.PsiMethod
|
||||
// OPTIONS: usages
|
||||
// FIND_BY_REF
|
||||
// FIND_BY_MIRROR_ELEMENT
|
||||
fun test() {
|
||||
System.<caret>exit(0)
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
Function call (6: 12) System.exit(0)
|
||||
@@ -1,2 +0,0 @@
|
||||
Local variable declaration (10: 14) val foo: Foo
|
||||
Usage in import (7: 16) import library.Foo
|
||||
@@ -1 +0,0 @@
|
||||
New instance creation (10: 5) Foo(1)
|
||||
@@ -1 +0,0 @@
|
||||
Value write (10: 11) Foo().x = 1
|
||||
@@ -1 +0,0 @@
|
||||
Function call (10: 11) Foo().bar(1)
|
||||
@@ -1 +0,0 @@
|
||||
Value write (10: 9) Foo.X = 1
|
||||
@@ -1 +0,0 @@
|
||||
Function call (10: 9) Foo.baz(1)
|
||||
-1
@@ -1,7 +1,6 @@
|
||||
// PSI_ELEMENT: com.intellij.psi.PsiClass
|
||||
// OPTIONS: usages
|
||||
// FIND_BY_REF
|
||||
// FIND_BY_NAVIGATION_ELEMENT
|
||||
package usages
|
||||
|
||||
import library.Foo
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
Local variable declaration (9: 14) val foo: Foo
|
||||
Usage in import (6: 16) import library.Foo
|
||||
-1
@@ -1,7 +1,6 @@
|
||||
// PSI_ELEMENT: com.intellij.psi.PsiMethod
|
||||
// OPTIONS: usages
|
||||
// FIND_BY_REF
|
||||
// FIND_BY_NAVIGATION_ELEMENT
|
||||
package usages
|
||||
|
||||
import library.Foo
|
||||
+1
@@ -0,0 +1 @@
|
||||
New instance creation (9: 5) Foo(1)
|
||||
-1
@@ -1,7 +1,6 @@
|
||||
// PSI_ELEMENT: com.intellij.psi.PsiField
|
||||
// OPTIONS: usages
|
||||
// FIND_BY_REF
|
||||
// FIND_BY_NAVIGATION_ELEMENT
|
||||
package usages
|
||||
|
||||
import library.Foo
|
||||
+1
@@ -0,0 +1 @@
|
||||
Value write (9: 11) Foo().x = 1
|
||||
-1
@@ -1,7 +1,6 @@
|
||||
// PSI_ELEMENT: com.intellij.psi.PsiMethod
|
||||
// OPTIONS: usages
|
||||
// FIND_BY_REF
|
||||
// FIND_BY_NAVIGATION_ELEMENT
|
||||
package usages
|
||||
|
||||
import library.Foo
|
||||
+1
@@ -0,0 +1 @@
|
||||
Function call (9: 11) Foo().bar(1)
|
||||
-1
@@ -1,7 +1,6 @@
|
||||
// PSI_ELEMENT: com.intellij.psi.PsiField
|
||||
// OPTIONS: usages
|
||||
// FIND_BY_REF
|
||||
// FIND_BY_NAVIGATION_ELEMENT
|
||||
package usages
|
||||
|
||||
import library.Foo
|
||||
+1
@@ -0,0 +1 @@
|
||||
Value write (9: 9) Foo.X = 1
|
||||
-1
@@ -1,7 +1,6 @@
|
||||
// PSI_ELEMENT: com.intellij.psi.PsiMethod
|
||||
// OPTIONS: usages
|
||||
// FIND_BY_REF
|
||||
// FIND_BY_NAVIGATION_ELEMENT
|
||||
package usages
|
||||
|
||||
import library.Foo
|
||||
+1
@@ -0,0 +1 @@
|
||||
Function call (9: 9) Foo.baz(1)
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// PSI_ELEMENT: org.jetbrains.kotlin.psi.JetClass
|
||||
// OPTIONS: usages, constructorUsages
|
||||
// FIND_BY_REF
|
||||
// WITH_FILE_NAME
|
||||
package usages
|
||||
|
||||
import library.*
|
||||
|
||||
class X: A {
|
||||
constructor(n: Int): super(n)
|
||||
}
|
||||
|
||||
class Y(): A(1)
|
||||
|
||||
fun test() {
|
||||
val a: <caret>A = A()
|
||||
val aa = A(1)
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package usages
|
||||
|
||||
import library.*
|
||||
|
||||
class J extends A {
|
||||
public J(int n) {
|
||||
super(n);
|
||||
}
|
||||
|
||||
static void test() {
|
||||
A a = new A();
|
||||
A aa = new A(1);
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
[LibraryClassUsages.0.kt] Local variable declaration (16: 12) val a: A = A()
|
||||
[LibraryClassUsages.0.kt] New instance creation (16: 16) val a: A = A()
|
||||
[LibraryClassUsages.0.kt] New instance creation (17: 14) val aa = A(1)
|
||||
[LibraryClassUsages.0.kt] Supertype (13: 12) class Y(): A(1)
|
||||
[LibraryClassUsages.0.kt] Supertype (9: 10) class X: A {
|
||||
[LibraryClassUsages.1.java] Local variable declaration (11: 9) A a = new A();
|
||||
[LibraryClassUsages.1.java] Local variable declaration (12: 9) A aa = new A(1);
|
||||
[LibraryClassUsages.1.java] New instance creation (11: 19) A a = new A();
|
||||
[LibraryClassUsages.1.java] New instance creation (12: 20) A aa = new A(1);
|
||||
[LibraryClassUsages.1.java] Usage in extends/implements clause (5: 17) class J extends A {
|
||||
[library.kt] Nested class/object (59: 13) val t = A.T(1)
|
||||
[library.kt] Nested class/object (60: 14) val tt = A.T()
|
||||
[library.kt] New instance creation (53: 13) val a = A(1)
|
||||
[library.kt] New instance creation (54: 14) val aa = A()
|
||||
[library.kt] Supertype (15: 10) class B: A {
|
||||
[library.kt] Supertype (18: 14) class U: A.T {
|
||||
[library.kt] Supertype (23: 12) class C(): A(1) {
|
||||
[library.kt] Supertype (24: 16) class V(): A.T(1)
|
||||
[library.kt] Supertype (27: 11) class BB: A {
|
||||
[library.kt] Supertype (30: 15) class UU: A.T {
|
||||
[library.kt] Supertype (35: 13) class CC(): A() {
|
||||
[library.kt] Supertype (36: 17) class VV(): A.T()
|
||||
[library.kt] Unclassified usage (57: 14) val ff = A::foo
|
||||
[library.kt] Unclassified usage (62: 15) val fff = A.T::bar
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// PSI_ELEMENT: org.jetbrains.kotlin.psi.JetNamedFunction
|
||||
// OPTIONS: usages
|
||||
// FIND_BY_REF
|
||||
// WITH_FILE_NAME
|
||||
package usages
|
||||
|
||||
import library.*
|
||||
|
||||
fun test() {
|
||||
val f = ::foo
|
||||
<caret>foo()
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// PSI_ELEMENT: org.jetbrains.kotlin.psi.JetNamedFunction
|
||||
// OPTIONS: usages
|
||||
// FIND_BY_REF
|
||||
// WITH_FILE_NAME
|
||||
package usages
|
||||
|
||||
import library.*
|
||||
|
||||
class J {
|
||||
static void test() {
|
||||
LibraryPackage.foo();
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
[LibraryFunctionUsages.0.kt] Callable reference (10: 15) val f = ::foo
|
||||
[LibraryFunctionUsages.0.kt] Function call (11: 5) foo()
|
||||
[library.kt] Callable reference (49: 15) val f = ::foo
|
||||
[library.kt] Function call (48: 5) foo()
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// PSI_ELEMENT: org.jetbrains.kotlin.psi.JetNamedFunction
|
||||
// OPTIONS: usages
|
||||
// FIND_BY_REF
|
||||
// WITH_FILE_NAME
|
||||
package usages
|
||||
|
||||
import library.*
|
||||
|
||||
fun test() {
|
||||
val f = A::foo
|
||||
A().<caret>foo(1)
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// PSI_ELEMENT: org.jetbrains.kotlin.psi.JetNamedFunction
|
||||
// OPTIONS: usages
|
||||
// FIND_BY_REF
|
||||
// WITH_FILE_NAME
|
||||
package usages
|
||||
|
||||
import library.*
|
||||
|
||||
class J {
|
||||
static void test() {
|
||||
new A().foo(1);
|
||||
}
|
||||
}
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
[LibraryMemberFunctionUsages.0.kt] Callable reference (10: 16) val f = A::foo
|
||||
[LibraryMemberFunctionUsages.0.kt] Function call (11: 9) A().foo(1)
|
||||
[library.kt] Callable reference (57: 17) val ff = A::foo
|
||||
[library.kt] Function call (56: 7) a.foo(2)
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
// PSI_ELEMENT: org.jetbrains.kotlin.psi.JetNamedFunction
|
||||
// OPTIONS: usages
|
||||
// FIND_BY_REF
|
||||
// WITH_FILE_NAME
|
||||
package usages
|
||||
|
||||
import library.*
|
||||
|
||||
fun test() {
|
||||
val f = A.T::bar
|
||||
A.T().<caret>bar(1)
|
||||
}
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
// PSI_ELEMENT: org.jetbrains.kotlin.psi.JetNamedFunction
|
||||
// OPTIONS: usages
|
||||
// FIND_BY_REF
|
||||
// WITH_FILE_NAME
|
||||
package usages
|
||||
|
||||
import library.*
|
||||
|
||||
class J {
|
||||
static void test() {
|
||||
new A.T().foo(1);
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
[LibraryNestedClassMemberFunctionUsages.0.kt] Callable reference (10: 18) val f = A.T::bar
|
||||
[LibraryNestedClassMemberFunctionUsages.0.kt] Function call (11: 11) A.T().bar(1)
|
||||
[library.kt] Callable reference (62: 20) val fff = A.T::bar
|
||||
[library.kt] Function call (61: 7) t.bar(2)
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// PSI_ELEMENT: org.jetbrains.kotlin.psi.JetPrimaryConstructor
|
||||
// OPTIONS: usages
|
||||
// FIND_BY_REF
|
||||
// WITH_FILE_NAME
|
||||
package usages
|
||||
|
||||
import library.*
|
||||
|
||||
class X: A.T {
|
||||
constructor(n: Int): super(n)
|
||||
}
|
||||
|
||||
class Y(): A.T(1)
|
||||
|
||||
fun test() {
|
||||
val a: A.T = A.T()
|
||||
val aa = A.<caret>T(1)
|
||||
}
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package usages
|
||||
|
||||
import library.*
|
||||
|
||||
class J extends A.T {
|
||||
public X(int n) {
|
||||
super(n);
|
||||
}
|
||||
|
||||
static void test() {
|
||||
A.T a = new A.T();
|
||||
A.T aa = new A.T(1);
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
[LibraryNestedClassPrimaryConstructorUsages.0.kt] New instance creation (17: 16) val aa = A.T(1)
|
||||
[LibraryNestedClassPrimaryConstructorUsages.0.kt] Supertype (13: 14) class Y(): A.T(1)
|
||||
[library.kt] New instance creation (59: 15) val t = A.T(1)
|
||||
[library.kt] Supertype (24: 18) class V(): A.T(1)
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// PSI_ELEMENT: org.jetbrains.kotlin.psi.JetSecondaryConstructor
|
||||
// OPTIONS: usages
|
||||
// FIND_BY_REF
|
||||
// WITH_FILE_NAME
|
||||
package usages
|
||||
|
||||
import library.*
|
||||
|
||||
class X: A.T {
|
||||
constructor(): super()
|
||||
}
|
||||
|
||||
class Y(): A.T()
|
||||
|
||||
fun test() {
|
||||
val a: A.T = A.<caret>T()
|
||||
val aa = A.T(1)
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package usages
|
||||
|
||||
import library.*
|
||||
|
||||
class J extends A.T {
|
||||
public J() {
|
||||
}
|
||||
|
||||
public J(int n) {
|
||||
super();
|
||||
}
|
||||
|
||||
static void test() {
|
||||
A.T a = new A.T();
|
||||
A.T aa = new A.T(1);
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
[LibraryNestedClassSecondaryConstructorUsages.0.kt] New instance creation (16: 20) val a: A.T = A.T()
|
||||
[LibraryNestedClassSecondaryConstructorUsages.0.kt] Supertype (13: 14) class Y(): A.T()
|
||||
[library.kt] New instance creation (60: 16) val tt = A.T()
|
||||
[library.kt] Supertype (36: 19) class VV(): A.T()
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// PSI_ELEMENT: org.jetbrains.kotlin.psi.JetClass
|
||||
// OPTIONS: usages, constructorUsages
|
||||
// FIND_BY_REF
|
||||
// WITH_FILE_NAME
|
||||
package usages
|
||||
|
||||
import library.*
|
||||
|
||||
class X: A.T {
|
||||
constructor(n: Int): super(n)
|
||||
}
|
||||
|
||||
class Y(): A.T(1)
|
||||
|
||||
fun test() {
|
||||
val a: A.<caret>T = A.T()
|
||||
val aa = A.T(1)
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package usages
|
||||
|
||||
import library.*
|
||||
|
||||
class J extends A.T {
|
||||
public J(int n) {
|
||||
super(n);
|
||||
}
|
||||
|
||||
static void test() {
|
||||
A.T t = new A.T();
|
||||
A.T tt = new A.T(1);
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
[LibraryNestedClassUsages.0.kt] Local variable declaration (16: 14) val a: A.T = A.T()
|
||||
[LibraryNestedClassUsages.0.kt] New instance creation (16: 20) val a: A.T = A.T()
|
||||
[LibraryNestedClassUsages.0.kt] New instance creation (17: 16) val aa = A.T(1)
|
||||
[LibraryNestedClassUsages.0.kt] Supertype (13: 14) class Y(): A.T(1)
|
||||
[LibraryNestedClassUsages.0.kt] Supertype (9: 12) class X: A.T {
|
||||
[library.kt] New instance creation (59: 15) val t = A.T(1)
|
||||
[library.kt] New instance creation (60: 16) val tt = A.T()
|
||||
[library.kt] Supertype (18: 16) class U: A.T {
|
||||
[library.kt] Supertype (24: 18) class V(): A.T(1)
|
||||
[library.kt] Supertype (30: 17) class UU: A.T {
|
||||
[library.kt] Supertype (36: 19) class VV(): A.T()
|
||||
[library.kt] Unclassified usage (62: 17) val fff = A.T::bar
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// PSI_ELEMENT: org.jetbrains.kotlin.psi.JetObjectDeclaration
|
||||
// OPTIONS: usages
|
||||
// FIND_BY_REF
|
||||
// WITH_FILE_NAME
|
||||
package usages
|
||||
|
||||
import library.*
|
||||
|
||||
fun test() {
|
||||
val o = <caret>O
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package usages
|
||||
|
||||
import library.*
|
||||
|
||||
class J {
|
||||
static void test() {
|
||||
O o = O.INSTANCE$;
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
[LibraryObjectUsages.0.kt] Value read (10: 13) val o = O
|
||||
[LibraryObjectUsages.1.java] Class static member access (7: 15) O o = O.INSTANCE$;
|
||||
[LibraryObjectUsages.1.java] Local variable declaration (7: 9) O o = O.INSTANCE$;
|
||||
[library.kt] Value read (51: 13) val o = O
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// PSI_ELEMENT: org.jetbrains.kotlin.psi.JetPrimaryConstructor
|
||||
// OPTIONS: usages
|
||||
// FIND_BY_REF
|
||||
// WITH_FILE_NAME
|
||||
package usages
|
||||
|
||||
import library.*
|
||||
|
||||
class X: A {
|
||||
constructor(n: Int): super(n)
|
||||
}
|
||||
|
||||
class Y(): A(1)
|
||||
|
||||
fun test() {
|
||||
val a: A = A()
|
||||
val aa = <caret>A(1)
|
||||
}
|
||||
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
package usages
|
||||
|
||||
import library.*
|
||||
|
||||
class J extends A {
|
||||
public X(int n) {
|
||||
super(n);
|
||||
}
|
||||
|
||||
static void test() {
|
||||
A a = new A();
|
||||
A aa = new A(1);
|
||||
}
|
||||
}
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
[LibraryPrimaryConstructorUsages.0.kt] New instance creation (17: 14) val aa = A(1)
|
||||
[LibraryPrimaryConstructorUsages.0.kt] Supertype (13: 12) class Y(): A(1)
|
||||
[library.kt] New instance creation (53: 13) val a = A(1)
|
||||
[library.kt] Supertype (23: 12) class C(): A(1) {
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
// PSI_ELEMENT: org.jetbrains.kotlin.psi.JetSecondaryConstructor
|
||||
// OPTIONS: usages
|
||||
// FIND_BY_REF
|
||||
// WITH_FILE_NAME
|
||||
package usages
|
||||
|
||||
import library.*
|
||||
|
||||
class X: A {
|
||||
constructor(): super()
|
||||
}
|
||||
|
||||
class Y(): A()
|
||||
|
||||
fun test() {
|
||||
val a: A = <caret>A()
|
||||
val aa = A(1)
|
||||
}
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
package usages
|
||||
|
||||
import library.*
|
||||
|
||||
class J extends A {
|
||||
public J() {
|
||||
}
|
||||
|
||||
public J(int n) {
|
||||
super();
|
||||
}
|
||||
|
||||
static void test() {
|
||||
A a = new A();
|
||||
A aa = new A(1);
|
||||
}
|
||||
}
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
[LibrarySecondaryConstructorUsages.0.kt] New instance creation (16: 16) val a: A = A()
|
||||
[LibrarySecondaryConstructorUsages.0.kt] Supertype (13: 12) class Y(): A()
|
||||
[library.kt] New instance creation (54: 14) val aa = A()
|
||||
[library.kt] Supertype (35: 13) class CC(): A() {
|
||||
Reference in New Issue
Block a user