Add some additional information to psi renderer
1) Trim unused spaces in annotations 2) Rewrote fq name rendering 3) Added annotations to for loop variable 4) Added type arguments render along to type parameters in functions
This commit is contained in:
committed by
Mikhail Glukhikh
parent
8fb2383845
commit
fe328f8c7a
@@ -1,23 +1,25 @@
|
||||
// Int Int
|
||||
// │ │
|
||||
val p = 0
|
||||
// Int
|
||||
// │
|
||||
// Int
|
||||
// │ Int
|
||||
// │ │
|
||||
fun foo() = 1
|
||||
|
||||
class Wrapper(val v: IntArray)
|
||||
|
||||
// test.a: IntArray
|
||||
// │ Int
|
||||
// │ │ fun (Int).plus(Int): Int
|
||||
// │ │ │ test.a: IntArray
|
||||
// │ │ │ │ val p: Int
|
||||
// │ │ │ │ │ fun (Int).plus(Int): Int
|
||||
// │ │ │ │ │ │ test.a: IntArray
|
||||
// │ │ │ │ │ │ │ fun foo(): Int
|
||||
// │ │ │ │ │ │ │ │ fun (Int).plus(Int): Int
|
||||
// │ │ │ │ │ │ │ │ │ test.w: Wrapper
|
||||
// │ │ │ │ │ │ │ │ │ │ val (Wrapper).v: IntArray
|
||||
// │ │ │ │ │ │ │ │ │ │ │ Int
|
||||
// │ │ │ │ │ │ │ │ │ │ │ │
|
||||
// Int
|
||||
// │ test.a: IntArray
|
||||
// │ │ Int
|
||||
// │ │ │ fun (Int).plus(Int): Int
|
||||
// │ │ │ │ test.a: IntArray
|
||||
// │ │ │ │ │ val p: Int
|
||||
// │ │ │ │ │ │ fun (Int).plus(Int): Int
|
||||
// │ │ │ │ │ │ │ test.a: IntArray
|
||||
// │ │ │ │ │ │ │ │ fun foo(): Int
|
||||
// │ │ │ │ │ │ │ │ │ fun (Int).plus(Int): Int
|
||||
// │ │ │ │ │ │ │ │ │ │ test.w: Wrapper
|
||||
// │ │ │ │ │ │ │ │ │ │ │ val (Wrapper).v: IntArray
|
||||
// │ │ │ │ │ │ │ │ │ │ │ │ Int
|
||||
// │ │ │ │ │ │ │ │ │ │ │ │ │
|
||||
fun test(a: IntArray, w: Wrapper) = a[0] + a[p] + a[foo()] + w.v[0]
|
||||
|
||||
@@ -12,8 +12,9 @@ fun test() {
|
||||
x[1] = 0
|
||||
}
|
||||
|
||||
// Int
|
||||
// │
|
||||
// Int
|
||||
// │ Int
|
||||
// │ │
|
||||
fun foo() = 1
|
||||
|
||||
fun test2() {
|
||||
|
||||
+21
-21
@@ -1,9 +1,9 @@
|
||||
// foo.a: Int
|
||||
// │ fun (Int).compareTo(Int): Int
|
||||
// │ │ foo.b: Int
|
||||
// │ │ │ foo.a: Int
|
||||
// Int │ │ │ │ foo.b: Int
|
||||
// │ │ │ │ │ │
|
||||
// Int │ │ │ foo.a: Int
|
||||
// │ Int │ │ │ │ foo.b: Int
|
||||
// │ │ │ │ │ │ │
|
||||
fun foo(a: Int, b: Int) = if (a > b) a else b
|
||||
|
||||
fun bar(a: Double, b: Double): Double {
|
||||
@@ -43,13 +43,13 @@ fun baz(a: Long, b: Long): Long {
|
||||
a > b -> {
|
||||
// fun io/println(Long): Unit
|
||||
// │ baz.a: Long
|
||||
// │ │
|
||||
// │ │
|
||||
println(a)
|
||||
// baz.a: Long
|
||||
// │
|
||||
return a
|
||||
}
|
||||
// Nothing
|
||||
// Nothing
|
||||
// │ baz.b: Long
|
||||
// │ │
|
||||
else -> return b
|
||||
@@ -57,34 +57,34 @@ fun baz(a: Long, b: Long): Long {
|
||||
}
|
||||
|
||||
fun grade(g: Int): String {
|
||||
// String
|
||||
// String
|
||||
// │ grade.g: Int
|
||||
// │ │
|
||||
// │ │
|
||||
return when (g) {
|
||||
// Int
|
||||
// │ Int String
|
||||
// │ │ │
|
||||
// Int
|
||||
// │ Int String
|
||||
// │ │ │
|
||||
6, 7 -> "Outstanding"
|
||||
// Int String
|
||||
// │ │
|
||||
// Int String
|
||||
// │ │
|
||||
5 -> "Excellent"
|
||||
// Int String
|
||||
// │ │
|
||||
// │ │
|
||||
4 -> "Good"
|
||||
// Int String
|
||||
// │ │
|
||||
// Int String
|
||||
// │ │
|
||||
3 -> "Mediocre"
|
||||
// fun (ranges/IntRange).contains(Int): Boolean
|
||||
// │ Int
|
||||
// │ Int
|
||||
// │ │fun (Int).rangeTo(Int): ranges/IntRange
|
||||
// │ ││ Int String
|
||||
// │ ││ │ │
|
||||
// │ ││ │ │
|
||||
in 1..2 -> "Fail"
|
||||
// String
|
||||
// │
|
||||
// String
|
||||
// │
|
||||
is Number -> "Number"
|
||||
// String
|
||||
// │
|
||||
// String
|
||||
// │
|
||||
else -> "Unknown"
|
||||
}
|
||||
}
|
||||
|
||||
+27
-21
@@ -1,38 +1,44 @@
|
||||
// distance.x: Int
|
||||
// │ fun (Int).plus(Int): Int
|
||||
// │ │ distance.y: Int
|
||||
// │ │ │
|
||||
// Int
|
||||
// │ distance.x: Int
|
||||
// │ │ fun (Int).plus(Int): Int
|
||||
// │ │ │ distance.y: Int
|
||||
// │ │ │ │
|
||||
infix fun distance(x: Int, y: Int) = x + y
|
||||
|
||||
// Int
|
||||
// │ [ERROR: not resolved]
|
||||
// │ │ Int
|
||||
// │ │ │
|
||||
// [ERROR: unknown type]
|
||||
// │ Int
|
||||
// │ │ [ERROR: not resolved]
|
||||
// │ │ │ Int
|
||||
// │ │ │ │
|
||||
fun test(): Int = 3 distance 4
|
||||
|
||||
// fun distance(Int, Int): Int
|
||||
// │ Int
|
||||
// │ │ Int
|
||||
// │ │ │
|
||||
// Int
|
||||
// │ fun distance(Int, Int): Int
|
||||
// │ │ Int
|
||||
// │ │ │ Int
|
||||
// │ │ │ │
|
||||
fun testRegular(): Int = distance(3, 4)
|
||||
|
||||
class My(var x: Int) {
|
||||
// var (My).x: Int
|
||||
// │
|
||||
// Int
|
||||
// │ var (My).x: Int
|
||||
// │ │
|
||||
operator fun invoke() = x
|
||||
|
||||
fun foo() {}
|
||||
|
||||
// constructor My(Int)
|
||||
// │ var (My).x: Int
|
||||
// │ │
|
||||
// My
|
||||
// │ constructor My(Int)
|
||||
// │ │ var (My).x: Int
|
||||
// │ │ │
|
||||
fun copy() = My(x)
|
||||
}
|
||||
|
||||
// constructor My(Int)
|
||||
// fun (My).invoke(): Int
|
||||
// │ Int
|
||||
// │ │
|
||||
// Int
|
||||
// │ constructor My(Int)
|
||||
// │ fun (My).invoke(): Int
|
||||
// │ │ Int
|
||||
// │ │ │
|
||||
fun testInvoke(): Int = My(13)()
|
||||
|
||||
fun testQualified(first: My, second: My?) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
fun foo() {
|
||||
// Int
|
||||
// │fun (Int).rangeTo(Int): ranges/IntRange
|
||||
// ││ Int
|
||||
// ││ │
|
||||
// Int ││ Int
|
||||
// │ ││ │
|
||||
for (i in 1..10) {
|
||||
// fun io/println(Int): Unit
|
||||
// │ val foo.i: Int
|
||||
@@ -17,8 +17,8 @@ fun bar(list: List<String>) {
|
||||
// bar.list: collections/List<String>
|
||||
// │ fun (collections/List<String>).subList(Int, Int): collections/List<String>
|
||||
// │ │ Int
|
||||
// │ │ │ Int
|
||||
// │ │ │ │
|
||||
// String │ │ │ Int
|
||||
// │ │ │ │ │
|
||||
for (element in list.subList(0, 10)) {
|
||||
// fun io/println(Any?): Unit
|
||||
// │ val bar.element: String
|
||||
@@ -28,8 +28,8 @@ fun bar(list: List<String>) {
|
||||
// bar.list: collections/List<String>
|
||||
// │ fun (collections/List<String>).subList(Int, Int): collections/List<String>
|
||||
// │ │ fun io/println(Any?): Unit
|
||||
// │ │ Int Int │ val bar.element: String
|
||||
// │ │ │ │ │ │
|
||||
// String │ │ Int Int │ val bar.element: String
|
||||
// │ │ │ │ │ │ │
|
||||
for (element in list.subList(10, 20)) println(element)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
// Nothing?
|
||||
// │
|
||||
// Nothing?
|
||||
// │ Nothing?
|
||||
// │ │
|
||||
fun <T> nullableValue(): T? = null
|
||||
|
||||
fun test() {
|
||||
// Int?
|
||||
// │ fun <T> nullableValue(): Int?
|
||||
// │ fun <T> nullableValue<Int>(): Int?
|
||||
// │ │
|
||||
val n = nullableValue<Int>()
|
||||
// Double?
|
||||
// │ fun <T> nullableValue(): Double?
|
||||
// │ fun <T> nullableValue<Double>(): Double?
|
||||
// │ │
|
||||
val x = nullableValue<Double>()
|
||||
// String?
|
||||
// │ fun <T> nullableValue(): String?
|
||||
// │ fun <T> nullableValue<String>(): String?
|
||||
// │ │
|
||||
val s = nullableValue<String>()
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// collections/Collection<Int>
|
||||
// │
|
||||
// │ Boolean
|
||||
// │ │
|
||||
fun foo(x: Int, y: Int, c: Collection<Int>) =
|
||||
// foo.x: Int
|
||||
// │ fun (collections/Collection<Int>).contains(Int): Boolean
|
||||
@@ -8,4 +9,4 @@ fun foo(x: Int, y: Int, c: Collection<Int>) =
|
||||
// │ │ │ │ fun (collections/Collection<Int>).contains(Int): Boolean
|
||||
// │ │ │ │ │ foo.c: collections/Collection<Int>
|
||||
// │ │ │ │ │ │
|
||||
x in c && y !in c
|
||||
x in c && y !in c
|
||||
|
||||
@@ -9,4 +9,4 @@ class WithInit(x: Int) {
|
||||
// │ │
|
||||
this.x = x
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+24
-23
@@ -1,15 +1,16 @@
|
||||
data class Tuple(val x: Int, val y: Int)
|
||||
|
||||
// fun ((Tuple) -> Int).invoke(Tuple): Int
|
||||
// │ constructor Tuple(Int, Int)
|
||||
// │ │ Int
|
||||
// │ │ │ Int
|
||||
// │ │ │ │
|
||||
// Int
|
||||
// │ fun ((Tuple) -> Int).invoke(Tuple): Int
|
||||
// │ │ constructor Tuple(Int, Int)
|
||||
// │ │ │ Int
|
||||
// │ │ │ │ Int
|
||||
// │ │ │ │ │
|
||||
inline fun use(f: (Tuple) -> Int) = f(Tuple(1, 2))
|
||||
|
||||
fun foo(): Int {
|
||||
// (Tuple) -> Int
|
||||
// │
|
||||
// (Tuple) -> Int
|
||||
// │
|
||||
val l1 = { t: Tuple ->
|
||||
// foo.<anonymous>.t: Tuple
|
||||
// Int │ val (Tuple).x: Int
|
||||
@@ -29,13 +30,13 @@ fun foo(): Int {
|
||||
// │ val foo.<anonymous>.x: Int
|
||||
// │ Int │ fun (Int).plus(Int): Int
|
||||
// │ │ Int │ │ val foo.<anonymous>.y: Int
|
||||
// │ │ │ │ │ │
|
||||
// │ │ │ │ │ │
|
||||
use { (x, y) -> x + y }
|
||||
|
||||
// fun use((Tuple) -> Int): Int
|
||||
// │
|
||||
// │
|
||||
return use {
|
||||
// Unit
|
||||
// Unit
|
||||
// │ foo.<anonymous>.it: Tuple
|
||||
// │ │ val (Tuple).x: Int
|
||||
// │ │ │ fun (Any).equals(Any?): Boolean
|
||||
@@ -51,9 +52,9 @@ fun foo(): Int {
|
||||
|
||||
fun bar(): Int {
|
||||
// fun use((Tuple) -> Int): Int
|
||||
// │
|
||||
// │
|
||||
return use lambda@{
|
||||
// Unit
|
||||
// Unit
|
||||
// │ bar.<anonymous>.it: Tuple
|
||||
// │ │ val (Tuple).x: Int
|
||||
// │ │ │ fun (Any).equals(Any?): Boolean
|
||||
@@ -71,24 +72,24 @@ fun bar(): Int {
|
||||
// │
|
||||
fun test(list: List<Int>) {
|
||||
// collections/MutableMap<Int, String>
|
||||
// │ fun <K, V> collections/mutableMapOf(): collections/MutableMap<Int, String>
|
||||
// │ │
|
||||
// │ fun <K, V> collections/mutableMapOf<Int, String>(): collections/MutableMap<Int, String>
|
||||
// │ │
|
||||
val map = mutableMapOf<Int, String>()
|
||||
// test.list: collections/List<Int>
|
||||
// │ fun <T> collections/Iterable<Int>.forEach((Int) -> Unit): Unit
|
||||
// │ fun <T> collections/Iterable<Int>.forEach<Int>((Int) -> Unit): Unit
|
||||
// │ │ val test.map: collections/MutableMap<Int, String>
|
||||
// │ │ │ fun <K, V> collections/MutableMap<Int, String>.getOrPut(Int, () -> String): String
|
||||
// │ │ │ fun <K, V> collections/MutableMap<Int, String>.getOrPut<Int, String>(Int, () -> String): String
|
||||
// │ │ │ │ test.<anonymous>.it: Int
|
||||
// │ │ │ │ │ fun <T> collections/mutableListOf(): collections/MutableList<???>
|
||||
// │ │ │ │ │ fun <T> collections/mutableListOf<???>(): collections/MutableList<???>
|
||||
// │ │ │ │ │ │ fun (String).plus(Any?): String
|
||||
// │ │ │ │ │ │ │
|
||||
// │ │ │ │ │ │ │
|
||||
list.forEach { map.getOrPut(it, { mutableListOf() }) += "" }
|
||||
}
|
||||
|
||||
// () -> Unit
|
||||
// │
|
||||
// () -> Unit
|
||||
// │
|
||||
val simple = { }
|
||||
|
||||
// () -> Int Int
|
||||
// │ │
|
||||
val another = { 42 }
|
||||
// () -> Int Int
|
||||
// │ │
|
||||
val another = { 42 }
|
||||
|
||||
+16
-13
@@ -1,14 +1,15 @@
|
||||
fun withLocals(p: Int): Int {
|
||||
class Local(val pp: Int) {
|
||||
// val (withLocals/Local).pp: Int
|
||||
// │ fun (Int).minus(Int): Int
|
||||
// │ │ withLocals.p: Int
|
||||
// │ │ │
|
||||
// Int
|
||||
// │ val (withLocals.Local).pp: Int
|
||||
// │ │ fun (Int).minus(Int): Int
|
||||
// │ │ │ withLocals.p: Int
|
||||
// │ │ │ │
|
||||
fun diff() = pp - p
|
||||
}
|
||||
|
||||
// constructor withLocals.Local(Int)
|
||||
// Int │ Int fun (withLocals/Local).diff(): Int
|
||||
// Int │ Int fun (withLocals.Local).diff(): Int
|
||||
// │ │ │ │
|
||||
val x = Local(42).diff()
|
||||
|
||||
@@ -26,10 +27,11 @@ fun withLocals(p: Int): Int {
|
||||
// Int constructor Any()
|
||||
// │ │
|
||||
val code = (object : Any() {
|
||||
// fun (Any).hashCode(): Int
|
||||
// │
|
||||
// Int
|
||||
// │ fun (Any).hashCode(): Int
|
||||
// │ │
|
||||
fun foo() = hashCode()
|
||||
// fun (withLocals/<no name provided>).foo(): Int
|
||||
// fun (withLocals.<no name provided>).foo(): Int
|
||||
// │
|
||||
}).foo()
|
||||
|
||||
@@ -37,10 +39,11 @@ fun withLocals(p: Int): Int {
|
||||
// │ val withLocals.code: Int
|
||||
// │ │ constructor withLocals.Local(Int)
|
||||
// │ │ │ Int
|
||||
// │ │ │ │ fun (withLocals/Local).diff(): Int
|
||||
// │ │ │ │ │ withLocals.<no name provided>.x: Int
|
||||
// │ │ │ │ │ │ fun (Int).plus(Int): Int
|
||||
// │ │ │ │ │ │ │ withLocals.<no name provided>.y: Int
|
||||
// │ │ │ │ │ │ │ │
|
||||
// │ │ │ │ fun (withLocals.Local).diff(): Int
|
||||
// │ │ │ │ │ Int
|
||||
// │ │ │ │ │ │ withLocals.<no name provided>.x: Int
|
||||
// │ │ │ │ │ │ │ fun (Int).plus(Int): Int
|
||||
// │ │ │ │ │ │ │ │ withLocals.<no name provided>.y: Int
|
||||
// │ │ │ │ │ │ │ │ │
|
||||
return sum(code, Local(1).diff(), fun(x: Int, y: Int) = x + y)
|
||||
}
|
||||
|
||||
@@ -27,18 +27,18 @@ fun simple() {
|
||||
// collections/List<String>
|
||||
// │
|
||||
fun List<String>.modify() {
|
||||
// fun <T> collections/Collection<String>.plus(String): collections/List<String>
|
||||
// fun <T> collections/Collection<String>.plus<String>(String): collections/List<String>
|
||||
// │
|
||||
this += "Alpha"
|
||||
// fun <T> collections/Collection<String>.plus(String): collections/List<String>
|
||||
// fun <T> collections/Collection<String>.plus<String>(String): collections/List<String>
|
||||
// │
|
||||
this += "Omega"
|
||||
}
|
||||
|
||||
fun Any.modify() {
|
||||
// collections/List<Int>
|
||||
// │ fun <T> collections/Collection<Int>.plus(Int): collections/List<Int>
|
||||
// │ fun <T> collections/Collection<Int>.plus<Int>(Int): collections/List<Int>
|
||||
// │ │ Int
|
||||
// │ │ │
|
||||
(this as List<Int>) += 42
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// orFourtyTwo.arg: Int?
|
||||
// │ fun ?: (Int?, Int): Int
|
||||
// │ │ Int
|
||||
// │ │ │
|
||||
// Int
|
||||
// │ orFourtyTwo.arg: Int?
|
||||
// │ │ Int
|
||||
// │ │ │
|
||||
fun orFourtyTwo(arg: Int?) = arg ?: 42
|
||||
|
||||
// bang.arg: Int?
|
||||
// │ fun !! (Int?): Int
|
||||
// │ │
|
||||
fun bang(arg: Int?) = arg!!
|
||||
// Int
|
||||
// │ bang.arg: Int?
|
||||
// │ │
|
||||
fun bang(arg: Int?) = arg!!
|
||||
|
||||
@@ -22,4 +22,4 @@ class C : A, B {
|
||||
// │
|
||||
super<B>.foo()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class Some {
|
||||
// Int
|
||||
// │
|
||||
// Int
|
||||
// │ Int
|
||||
// │ │
|
||||
fun foo(): Int = 1
|
||||
|
||||
fun bar(): Int {
|
||||
@@ -23,12 +24,12 @@ class Some {
|
||||
}
|
||||
}
|
||||
|
||||
// fun (Some).bar(): Int
|
||||
// │
|
||||
// Int fun (Some).bar(): Int
|
||||
// │ │
|
||||
fun Some.extension() = this.bar()
|
||||
|
||||
fun test(some: Some): Int {
|
||||
// fun <T, R> with(Some, Some.() -> Int): Int
|
||||
// fun <T, R> with<Some, Int>(Some, Some.() -> Int): Int
|
||||
// │ test.some: Some
|
||||
// │ │ with@0
|
||||
// │ │ │
|
||||
@@ -39,4 +40,4 @@ fun test(some: Some): Int {
|
||||
// │ │ │
|
||||
this.foo() + this@with.extension()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
interface IThing
|
||||
|
||||
// test1.x: Any
|
||||
// │
|
||||
// Boolean
|
||||
// │ test1.x: Any
|
||||
// │ │
|
||||
fun test1(x: Any) = x is IThing
|
||||
// test2.x: Any
|
||||
// │
|
||||
// Boolean
|
||||
// │ test2.x: Any
|
||||
// │ │
|
||||
fun test2(x: Any) = x !is IThing
|
||||
// test3.x: Any
|
||||
// │
|
||||
// IThing
|
||||
// │ test3.x: Any
|
||||
// │ │
|
||||
fun test3(x: Any) = x as IThing
|
||||
// test4.x: Any
|
||||
// │
|
||||
// IThing?
|
||||
// │ test4.x: Any
|
||||
// │ │
|
||||
fun test4(x: Any) = x as? IThing
|
||||
|
||||
Reference in New Issue
Block a user