Find Usages and Go to declaration of element used via import alias
#KT-18619 Fixed
This commit is contained in:
+18
@@ -0,0 +1,18 @@
|
||||
// PSI_ELEMENT: com.intellij.psi.PsiClass
|
||||
// OPTIONS: usages
|
||||
public class <caret>AAA {
|
||||
public String bar = "bar";
|
||||
public static String BAR = "BAR";
|
||||
|
||||
public AAA() {
|
||||
|
||||
}
|
||||
|
||||
public void foo() {
|
||||
|
||||
}
|
||||
|
||||
public static void foos() {
|
||||
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
import AAA as A
|
||||
public class X(bar: String? = A.BAR): A() {
|
||||
var next: A? = A()
|
||||
val myBar: String? = A.BAR
|
||||
|
||||
init {
|
||||
A.BAR = ""
|
||||
AAA.foos()
|
||||
}
|
||||
|
||||
fun foo(a: A) {
|
||||
val aa: AAA = a
|
||||
aa.bar = ""
|
||||
}
|
||||
|
||||
fun getNext(): A? {
|
||||
return next
|
||||
}
|
||||
|
||||
public override fun foo() {
|
||||
super<A>.foo()
|
||||
}
|
||||
|
||||
companion object: AAA() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
object O: A() {
|
||||
|
||||
}
|
||||
|
||||
fun X.bar(a: A = A()) {
|
||||
|
||||
}
|
||||
|
||||
fun Any.toA(): A? {
|
||||
return if (this is A) this as A else null
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
Class/object property type 3 var next: A? = A()
|
||||
Function return types 16 fun getNext(): A? {
|
||||
Function return types 37 fun Any.toA(): A? {
|
||||
Nested class/object 2 public class X(bar: String? = A.BAR): A() {
|
||||
Nested class/object 4 val myBar: String? = A.BAR
|
||||
Nested class/object 7 A.BAR = ""
|
||||
Nested class/object 8 AAA.foos()
|
||||
New instance creation 3 var next: A? = A()
|
||||
New instance creation 33 fun X.bar(a: A = A()) {
|
||||
Parameter type 11 fun foo(a: A) {
|
||||
Parameter type 33 fun X.bar(a: A = A()) {
|
||||
Super type qualifier 21 super<A>.foo()
|
||||
Supertype 2 public class X(bar: String? = A.BAR): A() {
|
||||
Supertype 29 object O: A() {
|
||||
Target type of 'is' operation 38 return if (this is A) this as A else null
|
||||
Usage in cast target type 38 return if (this is A) this as A else null
|
||||
Usage in import 1 import AAA as A
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// PSI_ELEMENT: org.jetbrains.kotlin.psi.KtClass
|
||||
// OPTIONS: usages, constructorUsages
|
||||
package server
|
||||
|
||||
open class <caret>Server {
|
||||
companion object {
|
||||
val NAME = "Server"
|
||||
}
|
||||
|
||||
open fun work() {
|
||||
println("Server")
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
package client
|
||||
|
||||
import server.Server as Srv
|
||||
import server.Server
|
||||
|
||||
class Client(name: String = Server.NAME): Srv() {
|
||||
var nextServer: Server? = new Server()
|
||||
val name = Server.NAME
|
||||
|
||||
/**
|
||||
* [Srv] parameter
|
||||
*/
|
||||
fun foo(s: Srv) {
|
||||
val server: Server = s
|
||||
println("Server: $server")
|
||||
}
|
||||
|
||||
fun getNextServer(): Server? {
|
||||
return nextServer
|
||||
}
|
||||
|
||||
override fun work() {
|
||||
super<Server>.work()
|
||||
println("Client")
|
||||
}
|
||||
|
||||
companion object: Server() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
object ClientObject: Server() {
|
||||
|
||||
}
|
||||
|
||||
class Servers: Iterator<Server> {
|
||||
|
||||
}
|
||||
|
||||
fun Iterator<Server>.f(p: Iterator<Server>): Iterator<Server> = this
|
||||
|
||||
fun Client.bar(s: Server = Server.NAME) {
|
||||
foo(s)
|
||||
}
|
||||
|
||||
fun Client.hasNextServer(): Boolean {
|
||||
return getNextServer() != null
|
||||
}
|
||||
|
||||
fun Any.asServer(): Server? {
|
||||
when (this) {
|
||||
is Server -> println("Server!")
|
||||
}
|
||||
return if (this is Server) this as Server else this as? Server
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
Class/object property type 7 var nextServer: Server? = new Server()
|
||||
Companion object 42 fun Client.bar(s: Server = Server.NAME) {
|
||||
Companion object 6 class Client(name: String = Server.NAME): Srv() {
|
||||
Companion object 8 val name = Server.NAME
|
||||
Function return types 18 fun getNextServer(): Server? {
|
||||
Function return types 50 fun Any.asServer(): Server? {
|
||||
Local variable declaration 14 val server: Server = s
|
||||
Parameter type 13 fun foo(s: Srv) {
|
||||
Parameter type 42 fun Client.bar(s: Server = Server.NAME) {
|
||||
Super type qualifier 23 super<Server>.work()
|
||||
Supertype 27 companion object: Server() {
|
||||
Supertype 32 object ClientObject: Server() {
|
||||
Supertype 6 class Client(name: String = Server.NAME): Srv() {
|
||||
Target type of 'is' operation 52 is Server -> println("Server!")
|
||||
Target type of 'is' operation 54 return if (this is Server) this as Server else this as? Server
|
||||
Type parameter 36 class Servers: Iterator<Server> {
|
||||
Type parameter 40 fun Iterator<Server>.f(p: Iterator<Server>): Iterator<Server> = this
|
||||
Type parameter 40 fun Iterator<Server>.f(p: Iterator<Server>): Iterator<Server> = this
|
||||
Type parameter 40 fun Iterator<Server>.f(p: Iterator<Server>): Iterator<Server> = this
|
||||
Usage in cast target type 54 return if (this is Server) this as Server else this as? Server
|
||||
Usage in cast target type 54 return if (this is Server) this as Server else this as? Server
|
||||
Usage in comments 11 * [Srv] parameter
|
||||
Usage in import 3 import server.Server as Srv
|
||||
Usage in import 4 import server.Server
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
// PSI_ELEMENT: org.jetbrains.kotlin.psi.KtImportAlias
|
||||
// OPTIONS: usages, constructorUsages
|
||||
package client
|
||||
|
||||
import server.Server as Srv<caret>
|
||||
import server.Server
|
||||
|
||||
class Client(name: String = Server.NAME): Srv() {
|
||||
var nextServer: Server? = new Server()
|
||||
val name = Server.NAME
|
||||
|
||||
/**
|
||||
* [Srv] parameter
|
||||
*/
|
||||
fun foo(s: Srv) {
|
||||
val server: Server = s
|
||||
println("Server: $server")
|
||||
}
|
||||
|
||||
fun getNextServer(): Server? {
|
||||
return nextServer
|
||||
}
|
||||
|
||||
override fun work() {
|
||||
super<Server>.work()
|
||||
println("Client")
|
||||
}
|
||||
|
||||
companion object: Server() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
object ClientObject: Server() {
|
||||
|
||||
}
|
||||
|
||||
class Servers: Iterator<Server> {
|
||||
|
||||
}
|
||||
|
||||
fun Iterator<Server>.f(p: Iterator<Server>): Iterator<Server> = this
|
||||
|
||||
fun Client.bar(s: Server = Server.NAME) {
|
||||
foo(s)
|
||||
}
|
||||
|
||||
fun Client.hasNextServer(): Boolean {
|
||||
return getNextServer() != null
|
||||
}
|
||||
|
||||
fun Any.asServer(): Server? {
|
||||
when (this) {
|
||||
is Server -> println("Server!")
|
||||
}
|
||||
return if (this is Server) this as Server else this as? Server
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package server
|
||||
|
||||
open class Server {
|
||||
companion object {
|
||||
val NAME = "Server"
|
||||
}
|
||||
|
||||
open fun work() {
|
||||
println("Server")
|
||||
}
|
||||
}
|
||||
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
Class/object property type 9 var nextServer: Server? = new Server()
|
||||
Companion object 10 val name = Server.NAME
|
||||
Companion object 44 fun Client.bar(s: Server = Server.NAME) {
|
||||
Companion object 8 class Client(name: String = Server.NAME): Srv() {
|
||||
Function return types 20 fun getNextServer(): Server? {
|
||||
Function return types 52 fun Any.asServer(): Server? {
|
||||
Local variable declaration 16 val server: Server = s
|
||||
Parameter type 15 fun foo(s: Srv) {
|
||||
Parameter type 44 fun Client.bar(s: Server = Server.NAME) {
|
||||
Super type qualifier 25 super<Server>.work()
|
||||
Supertype 29 companion object: Server() {
|
||||
Supertype 34 object ClientObject: Server() {
|
||||
Supertype 8 class Client(name: String = Server.NAME): Srv() {
|
||||
Target type of 'is' operation 54 is Server -> println("Server!")
|
||||
Target type of 'is' operation 56 return if (this is Server) this as Server else this as? Server
|
||||
Type parameter 38 class Servers: Iterator<Server> {
|
||||
Type parameter 42 fun Iterator<Server>.f(p: Iterator<Server>): Iterator<Server> = this
|
||||
Type parameter 42 fun Iterator<Server>.f(p: Iterator<Server>): Iterator<Server> = this
|
||||
Type parameter 42 fun Iterator<Server>.f(p: Iterator<Server>): Iterator<Server> = this
|
||||
Usage in cast target type 56 return if (this is Server) this as Server else this as? Server
|
||||
Usage in cast target type 56 return if (this is Server) this as Server else this as? Server
|
||||
Usage in comments 13 * [Srv] parameter
|
||||
Usage in import 5 import server.Server as Srv
|
||||
Usage in import 6 import server.Server
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// PSI_ELEMENT: org.jetbrains.kotlin.psi.KtNamedFunction
|
||||
// OPTIONS: usages
|
||||
package server
|
||||
|
||||
fun <caret>processRequest() = "foo"
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import server.processRequest as process
|
||||
|
||||
class Client {
|
||||
public fun foo() {
|
||||
process()
|
||||
}
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
Function call 5 process()
|
||||
Usage in import 1 import server.processRequest as process
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// PSI_ELEMENT: org.jetbrains.kotlin.psi.KtImportAlias
|
||||
// OPTIONS: usages
|
||||
|
||||
import server.processRequest as process<caret>
|
||||
import server.processRequest
|
||||
|
||||
class Client {
|
||||
fun foo() {
|
||||
process()
|
||||
}
|
||||
|
||||
fun foo2() {
|
||||
processRequest()
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package server
|
||||
|
||||
fun processRequest() = "foo"
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
Function call 13 processRequest()
|
||||
Function call 9 process()
|
||||
Usage in import 4 import server.processRequest as process
|
||||
Usage in import 5 import server.processRequest
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// IGNORE: see KotlinFindUsagesHandlerFactory: it is ambiguous case: ImportAlias does not have any reference to be resolved
|
||||
// PSI_ELEMENT: org.jetbrains.kotlin.psi.KtImportAlias
|
||||
// OPTIONS: usages
|
||||
|
||||
package c
|
||||
|
||||
import c.a
|
||||
import c.a as b<caret>
|
||||
|
||||
fun a() = Unit
|
||||
fun a(i: Int) = Unit
|
||||
|
||||
fun test() {
|
||||
a()
|
||||
a(1)
|
||||
b()
|
||||
b(1)
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
Function call 13 a()
|
||||
Function call 14 a(1)
|
||||
Function call 15 b()
|
||||
Function call 16 b(1)
|
||||
Usage in import 6 import c.a
|
||||
Usage in import 6 import c.a
|
||||
Usage in import 7 import c.a as b
|
||||
Usage in import 7 import c.a as b
|
||||
@@ -0,0 +1,17 @@
|
||||
// FILE: before.kt
|
||||
package c
|
||||
|
||||
import c.I1 as I<caret>
|
||||
|
||||
interface I1
|
||||
|
||||
fun foo(i: I){}
|
||||
|
||||
// FILE: after.kt
|
||||
package c
|
||||
|
||||
import c.I1 as I
|
||||
|
||||
interface <caret>I1
|
||||
|
||||
fun foo(i: I){}
|
||||
@@ -0,0 +1,27 @@
|
||||
// FILE: before.kt
|
||||
package c
|
||||
|
||||
import c.a
|
||||
import c.a as b<caret> // caret stays here as it results into multiple results
|
||||
|
||||
fun a() = Unit
|
||||
fun a(i: Int) = Unit
|
||||
|
||||
fun test() {
|
||||
a()
|
||||
b()
|
||||
}
|
||||
|
||||
// FILE: after.kt
|
||||
package c
|
||||
|
||||
import c.a
|
||||
import c.a as b<caret> // caret stays here as it results into multiple results
|
||||
|
||||
fun a() = Unit
|
||||
fun a(i: Int) = Unit
|
||||
|
||||
fun test() {
|
||||
a()
|
||||
b()
|
||||
}
|
||||
+1
-3
@@ -1,7 +1,5 @@
|
||||
package a
|
||||
|
||||
import b.X as XX
|
||||
|
||||
fun bar() {
|
||||
val t: XX = XX()
|
||||
val t: b.X = b.X()
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package a
|
||||
|
||||
import b.X as XX
|
||||
|
||||
fun bar() {
|
||||
val t: XX = XX()
|
||||
}
|
||||
+1
-3
@@ -1,7 +1,5 @@
|
||||
package b
|
||||
|
||||
import b.X as XX
|
||||
|
||||
fun bar() {
|
||||
val t: XX = XX()
|
||||
val t: b.X = b.X()
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package b
|
||||
|
||||
import b.X as XX
|
||||
|
||||
fun bar() {
|
||||
val t: XX = XX()
|
||||
}
|
||||
+1
-3
@@ -1,7 +1,5 @@
|
||||
package a
|
||||
|
||||
import a.X as XX
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: XX = XX()
|
||||
val t: a.X = a.X()
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package a
|
||||
|
||||
import a.X as XX
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: XX = XX()
|
||||
}
|
||||
+1
-3
@@ -1,7 +1,5 @@
|
||||
package a
|
||||
|
||||
import a.Y as XX
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: XX = XX()
|
||||
val t: a.Y = a.Y()
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package a
|
||||
|
||||
import a.Y as XX
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: XX = XX()
|
||||
}
|
||||
Reference in New Issue
Block a user