Use DescriptorRenderer to render annotations everywhere

This commit is contained in:
Andrey Breslav
2014-01-14 15:40:38 +04:00
parent 9fa29535b4
commit 65d90e18a2
60 changed files with 272 additions and 102 deletions
@@ -2,15 +2,15 @@ package test
public trait AnnotationInParam : java.lang.Object {
test.AnnotationInParam.MyAnnotationWithParam(value = MyAnnotation[value = "test"]: test.AnnotationInParam.MyAnnotation) public open class A : java.lang.Object {
test.AnnotationInParam.MyAnnotationWithParam(value = test.AnnotationInParam.MyAnnotation(value = "test": jet.String): test.AnnotationInParam.MyAnnotation) public open class A : java.lang.Object {
public constructor A()
}
test.AnnotationInParam.MyAnnotationWithParam2(value = MyAnnotation2[value = ["test", "test2"]]: test.AnnotationInParam.MyAnnotation2) public open class B : java.lang.Object {
test.AnnotationInParam.MyAnnotationWithParam2(value = test.AnnotationInParam.MyAnnotation2(value = {"test", "test2"}: jet.Array<jet.String>?): test.AnnotationInParam.MyAnnotation2) public open class B : java.lang.Object {
public constructor B()
}
test.AnnotationInParam.MyAnnotationWithParam3(value = MyAnnotation3[first = "f", second = "s"]: test.AnnotationInParam.MyAnnotation3) public open class C : java.lang.Object {
test.AnnotationInParam.MyAnnotationWithParam3(value = test.AnnotationInParam.MyAnnotation3(first = "f": jet.String, second = "s": jet.String): test.AnnotationInParam.MyAnnotation3) public open class C : java.lang.Object {
public constructor C()
}
@@ -2,7 +2,7 @@ package test
public trait ArrayOfEnumInParam : java.lang.Object {
java.lang.annotation.Target(value = [ElementType.FIELD, ElementType.CONSTRUCTOR]: jet.Array<java.lang.annotation.ElementType>?) public final annotation class targetAnnotation : jet.Annotation {
java.lang.annotation.Target(value = {ElementType.FIELD, ElementType.CONSTRUCTOR}: jet.Array<java.lang.annotation.ElementType>?) public final annotation class targetAnnotation : jet.Annotation {
public constructor targetAnnotation(/*0*/ value: jet.String?)
public abstract fun value(): jet.String?
}
@@ -2,7 +2,7 @@ package test
public trait ArrayOfStringInParam : java.lang.Object {
test.ArrayOfStringInParam.MyAnnotation(value = ["a", "b", "c"]: jet.Array<jet.String>?) public open class A : java.lang.Object {
test.ArrayOfStringInParam.MyAnnotation(value = {"a", "b", "c"}: jet.Array<jet.String>?) public open class A : java.lang.Object {
public constructor A()
}
@@ -8,7 +8,7 @@ public open class ClassObjectArrayInParam : java.lang.Object {
public abstract fun value(): jet.Array<java.lang.Class<out jet.Any?>>?
}
test.ClassObjectArrayInParam.Anno(value = [ClassObjectArrayInParam?.class, Nested?.class, String?.class]: jet.Array<java.lang.Class<out jet.Any?>>?) public open class Nested : java.lang.Object {
test.ClassObjectArrayInParam.Anno(value = {test.ClassObjectArrayInParam?.class, test.ClassObjectArrayInParam.Nested?.class, jet.String?.class}: jet.Array<java.lang.Class<out jet.Any?>>?) public open class Nested : java.lang.Object {
public constructor Nested()
}
}
@@ -8,7 +8,7 @@ public open class ClassObjectInParam : java.lang.Object {
public abstract fun value(): java.lang.Class<out jet.Any?>?
}
test.ClassObjectInParam.Anno(value = ClassObjectInParam?.class: java.lang.Class<test.ClassObjectInParam?>) public open class Nested : java.lang.Object {
test.ClassObjectInParam.Anno(value = test.ClassObjectInParam?.class: java.lang.Class<test.ClassObjectInParam?>) public open class Nested : java.lang.Object {
public constructor Nested()
}
}
@@ -2,7 +2,7 @@ package test
public trait EmptyArrayInParam : java.lang.Object {
test.EmptyArrayInParam.MyAnnotation(value = []: jet.Array<jet.String>?) public open class A : java.lang.Object {
test.EmptyArrayInParam.MyAnnotation(value = {}: jet.Array<jet.String>?) public open class A : java.lang.Object {
public constructor A()
}
@@ -2,12 +2,12 @@ package test
public trait RecursiveAnnotation : java.lang.Object {
test.RecursiveAnnotation.B(value = A[value = "test"]: test.RecursiveAnnotation.A) public final annotation class A : jet.Annotation {
test.RecursiveAnnotation.B(value = test.RecursiveAnnotation.A(value = "test": jet.String): test.RecursiveAnnotation.A) public final annotation class A : jet.Annotation {
public constructor A(/*0*/ value: jet.String?)
public abstract fun value(): jet.String?
}
test.RecursiveAnnotation.B(value = A[value = "test"]: test.RecursiveAnnotation.A) public final annotation class B : jet.Annotation {
test.RecursiveAnnotation.B(value = test.RecursiveAnnotation.A(value = "test": jet.String): test.RecursiveAnnotation.A) public final annotation class B : jet.Annotation {
public constructor B(/*0*/ value: test.RecursiveAnnotation.A?)
public abstract fun value(): test.RecursiveAnnotation.A?
}
@@ -7,7 +7,7 @@ public trait RecursiveAnnotation2 : java.lang.Object {
public abstract fun value(): test.RecursiveAnnotation2.B?
}
test.RecursiveAnnotation2.A(value = B[value = "test"]: test.RecursiveAnnotation2.B) public final annotation class B : jet.Annotation {
test.RecursiveAnnotation2.A(value = test.RecursiveAnnotation2.B(value = "test": jet.String): test.RecursiveAnnotation2.B) public final annotation class B : jet.Annotation {
public constructor B(/*0*/ value: jet.String?)
public abstract fun value(): jet.String?
}
@@ -9,4 +9,4 @@ annotation class Ann(
Ann(1, 1.toByte(), 128.toByte(), 128) class MyClass
// EXPECTED: Ann[b1 = IntegerValueType(1): IntegerValueType(1), b2 = 1.toByte(): jet.Byte, b3 = -128.toByte(): jet.Byte, b4 = IntegerValueType(128): IntegerValueType(128)]
// EXPECTED: Ann(b1 = IntegerValueType(1): IntegerValueType(1), b2 = 1.toByte(): Byte, b3 = -128.toByte(): Byte, b4 = IntegerValueType(128): IntegerValueType(128))
@@ -13,4 +13,4 @@ annotation class Ann(
Ann('c', 99.toChar(), 'c'.toInt(), 'c'.toLong(), 'c'.toByte(), 'c'.toShort(), 'c'.toDouble(), 'c'.toFloat()) class MyClass
// EXPECTED: Ann[b1 = #99(c): jet.Char, b2 = #99(c): jet.Char, b3 = 99.toInt(): jet.Int, b4 = 99.toLong(): jet.Long, b5 = 99.toByte(): jet.Byte, b6 = 99.toShort(): jet.Short, b7 = 99.0.toDouble(): jet.Double, b8 = 99.0.toFloat(): jet.Float]
// EXPECTED: Ann(b1 = #99(c): Char, b2 = #99(c): Char, b3 = 99.toInt(): Int, b4 = 99.toLong(): Long, b5 = 99.toByte(): Byte, b6 = 99.toShort(): Short, b7 = 99.0.toDouble(): Double, b8 = 99.0.toFloat(): Float)
@@ -9,4 +9,4 @@ annotation class Ann(
Ann(1.0, 1.toDouble(), 1.7976931348623157E309.toDouble(), 1.7976931348623157E309) class MyClass
// EXPECTED: Ann[b1 = 1.0.toDouble(): jet.Double, b2 = 1.0.toDouble(): jet.Double, b3 = Infinity.toDouble(): jet.Double, b4 = Infinity.toDouble(): jet.Double]
// EXPECTED: Ann(b1 = 1.0.toDouble(): Double, b2 = 1.0.toDouble(): Double, b3 = Infinity.toDouble(): Double, b4 = Infinity.toDouble(): Double)
@@ -7,4 +7,4 @@ annotation class Ann(
Ann(true && false, true && true) class MyClass
// EXPECTED: Ann[b1 = false: jet.Boolean, b2 = true: jet.Boolean]
// EXPECTED: Ann(b1 = false: Boolean, b2 = true: Boolean)
@@ -8,4 +8,4 @@ annotation class Ann(
Ann(true and false, false or true, true xor false) class MyClass
// EXPECTED: Ann[b1 = false: jet.Boolean, b2 = true: jet.Boolean, b3 = true: jet.Boolean]
// EXPECTED: Ann(b1 = false: Boolean, b2 = true: Boolean, b3 = true: Boolean)
@@ -4,4 +4,4 @@ annotation class Ann(val c1: Char)
Ann('a' - 'a') class MyClass
// EXPECTED: Ann[c1 = IntegerValueType(0): IntegerValueType(0)]
// EXPECTED: Ann(c1 = IntegerValueType(0): IntegerValueType(0))
@@ -8,4 +8,4 @@ annotation class Ann(
Ann(1.toInt().plus(1), 1.minus(1.toInt()), 1.toInt().times(1.toInt())) class MyClass
// EXPECTED: Ann[p1 = 2.toInt(): jet.Int, p2 = 0.toInt(): jet.Int, p3 = 1.toInt(): jet.Int]
// EXPECTED: Ann(p1 = 2.toInt(): Int, p2 = 0.toInt(): Int, p3 = 1.toInt(): Int)
@@ -9,4 +9,4 @@ annotation class Ann(
Ann(1 / 1, 1 / 1, 1 / 1, 1 / 1) class MyClass
// EXPECTED: Ann[b = IntegerValueType(1): IntegerValueType(1), i = IntegerValueType(1): IntegerValueType(1), l = IntegerValueType(1): IntegerValueType(1), s = IntegerValueType(1): IntegerValueType(1)]
// EXPECTED: Ann(b = IntegerValueType(1): IntegerValueType(1), i = IntegerValueType(1): IntegerValueType(1), l = IntegerValueType(1): IntegerValueType(1), s = IntegerValueType(1): IntegerValueType(1))
@@ -8,4 +8,4 @@ annotation class Ann(
Ann(1.0 + 1.0, 1.0 + 1, 1 + 1.0) class MyClass
// EXPECTED: Ann[d1 = 2.0.toDouble(): jet.Double, d2 = 2.0.toDouble(): jet.Double, d3 = 2.0.toDouble(): jet.Double]
// EXPECTED: Ann(d1 = 2.0.toDouble(): Double, d2 = 2.0.toDouble(): Double, d3 = 2.0.toDouble(): Double)
@@ -10,4 +10,4 @@ annotation class Ann(
Ann(1 == 2, 1.0 == 2.0, 'b' == 'a', "a" == "b", "a" == "a") class MyClass
// EXPECTED: Ann[b1 = false: jet.Boolean, b2 = false: jet.Boolean, b3 = false: jet.Boolean, b4 = false: jet.Boolean, b5 = true: jet.Boolean]
// EXPECTED: Ann(b1 = false: Boolean, b2 = false: Boolean, b3 = false: Boolean, b4 = false: Boolean, b5 = true: Boolean)
@@ -4,4 +4,4 @@ annotation class Ann(val s1: String)
Ann(s1 = "\$ab") class MyClass
// EXPECTED: Ann[s1 = "$ab": jet.String]
// EXPECTED: Ann(s1 = "$ab": String)
@@ -9,4 +9,4 @@ annotation class Ann(
Ann(1.toFloat() + 1.toFloat(), 1.toFloat() + 1, 1.toFloat() + 1.0) class MyClass
// EXPECTED: Ann[d1 = 2.0.toFloat(): jet.Float, d2 = 2.0.toFloat(): jet.Float, d3 = 2.0.toDouble(): jet.Double]
// EXPECTED: Ann(d1 = 2.0.toFloat(): Float, d2 = 2.0.toFloat(): Float, d3 = 2.0.toDouble(): Double)
@@ -14,4 +14,4 @@ val b = 2
Ann(1 > 2, 1.0 > 2.0, 2 > a, b > a, 'b' > 'a', "a" > "b") class MyClass
// EXPECTED: Ann[b1 = false: jet.Boolean, b2 = false: jet.Boolean, b3 = true: jet.Boolean, b4 = true: jet.Boolean, b5 = true: jet.Boolean, b6 = false: jet.Boolean]
// EXPECTED: Ann(b1 = false: Boolean, b2 = false: Boolean, b3 = true: Boolean, b4 = true: Boolean, b5 = true: Boolean, b6 = false: Boolean)
@@ -9,4 +9,4 @@ annotation class Ann(
Ann(1 >= 2, 1.0 >= 2.0, 1 >= 1, 1.0 >= 1.0) class MyClass
// EXPECTED: Ann[b1 = false: jet.Boolean, b2 = false: jet.Boolean, b3 = true: jet.Boolean, b4 = true: jet.Boolean]
// EXPECTED: Ann(b1 = false: Boolean, b2 = false: Boolean, b3 = true: Boolean, b4 = true: Boolean)
@@ -10,4 +10,4 @@ annotation class Ann(
Ann(1 plus 1, 1 minus 1, 1 times 1, 1 div 1, 1 mod 1) class MyClass
// EXPECTED: Ann[p1 = IntegerValueType(2): IntegerValueType(2), p2 = IntegerValueType(0): IntegerValueType(0), p3 = IntegerValueType(1): IntegerValueType(1), p4 = IntegerValueType(1): IntegerValueType(1), p5 = IntegerValueType(0): IntegerValueType(0)]
// EXPECTED: Ann(p1 = IntegerValueType(2): IntegerValueType(2), p2 = IntegerValueType(0): IntegerValueType(0), p3 = IntegerValueType(1): IntegerValueType(1), p4 = IntegerValueType(1): IntegerValueType(1), p5 = IntegerValueType(0): IntegerValueType(0))
@@ -10,4 +10,4 @@ annotation class Ann(p1: Int,
Ann(1 or 1, 1 and 1, 1 xor 1, 1 shl 1, 1 shr 1, 1 ushr 1) class MyClass
// EXPECTED: Ann[p1 = IntegerValueType(1): IntegerValueType(1), p2 = IntegerValueType(1): IntegerValueType(1), p3 = IntegerValueType(0): IntegerValueType(0), p4 = IntegerValueType(2): IntegerValueType(2), p5 = IntegerValueType(0): IntegerValueType(0), p6 = IntegerValueType(0): IntegerValueType(0)]
// EXPECTED: Ann(p1 = IntegerValueType(1): IntegerValueType(1), p2 = IntegerValueType(1): IntegerValueType(1), p3 = IntegerValueType(0): IntegerValueType(0), p4 = IntegerValueType(2): IntegerValueType(2), p5 = IntegerValueType(0): IntegerValueType(0), p6 = IntegerValueType(0): IntegerValueType(0))
@@ -4,4 +4,4 @@ annotation class Ann(i: Double)
Ann(@A 1.0) class MyClass
// EXPECTED: Ann[i = 1.0.toDouble(): jet.Double]
// EXPECTED: Ann(i = 1.0.toDouble(): Double)
@@ -8,4 +8,4 @@ annotation class Ann(
Ann(1 + 1, java.lang.Long.MAX_VALUE + 1 - 1, java.lang.Long.MAX_VALUE - 1) class MyClass
// EXPECTED: Ann[l1 = IntegerValueType(2): IntegerValueType(2), l2 = 9223372036854775807.toLong(): jet.Long, l3 = 9223372036854775806.toLong(): jet.Long]
// EXPECTED: Ann(l1 = IntegerValueType(2): IntegerValueType(2), l2 = 9223372036854775807.toLong(): Long, l3 = 9223372036854775806.toLong(): Long)
@@ -14,4 +14,4 @@ val b = 2
Ann(1 < 2, 1.0 < 2.0, 2 < a, b < a, 'b' < 'a', "a" < "b") class MyClass
// EXPECTED: Ann[b1 = true: jet.Boolean, b2 = true: jet.Boolean, b3 = false: jet.Boolean, b4 = false: jet.Boolean, b5 = false: jet.Boolean, b6 = true: jet.Boolean]
// EXPECTED: Ann(b1 = true: Boolean, b2 = true: Boolean, b3 = false: Boolean, b4 = false: Boolean, b5 = false: Boolean, b6 = true: Boolean)
@@ -9,4 +9,4 @@ annotation class Ann(
Ann(1 <= 2, 1.0 <= 2.0, 1 <= 1, 1.0 <= 1.0) class MyClass
// EXPECTED: Ann[b1 = true: jet.Boolean, b2 = true: jet.Boolean, b3 = true: jet.Boolean, b4 = true: jet.Boolean]
// EXPECTED: Ann(b1 = true: Boolean, b2 = true: Boolean, b3 = true: Boolean, b4 = true: Boolean)
@@ -18,4 +18,4 @@ Ann(
p6 = java.lang.Long.MAX_VALUE + 1
) class MyClass
// EXPECTED: Ann[p1 = 128.toInt(): jet.Int, p2 = 32768.toInt(): jet.Int, p3 = -2147483648.toInt(): jet.Int, p4 = -2147483648.toInt(): jet.Int, p5 = 2147483648.toLong(): jet.Long, p6 = -9223372036854775808.toLong(): jet.Long]
// EXPECTED: Ann(p1 = 128.toInt(): Int, p2 = 32768.toInt(): Int, p3 = -2147483648.toInt(): Int, p4 = -2147483648.toInt(): Int, p5 = 2147483648.toLong(): Long, p6 = -9223372036854775808.toLong(): Long)
@@ -16,4 +16,4 @@ Ann(
p5 = 1.toByte() + 1.toByte()
) class MyClass
// EXPECTED: Ann[p1 = 128.toInt(): jet.Int, p2 = IntegerValueType(2): IntegerValueType(2), p3 = 128.toInt(): jet.Int, p4 = 2.toInt(): jet.Int, p5 = 2.toInt(): jet.Int]
// EXPECTED: Ann(p1 = 128.toInt(): Int, p2 = IntegerValueType(2): IntegerValueType(2), p3 = 128.toInt(): Int, p4 = 2.toInt(): Int, p5 = 2.toInt(): Int)
@@ -16,4 +16,4 @@ Ann(
p5 = 1.toInt() + 1.toInt()
) class MyClass
// EXPECTED: Ann[p1 = -2147483648.toInt(): jet.Int, p2 = IntegerValueType(2): IntegerValueType(2), p3 = -2147483648.toInt(): jet.Int, p4 = 2.toInt(): jet.Int, p5 = 2.toInt(): jet.Int]
// EXPECTED: Ann(p1 = -2147483648.toInt(): Int, p2 = IntegerValueType(2): IntegerValueType(2), p3 = -2147483648.toInt(): Int, p4 = 2.toInt(): Int, p5 = 2.toInt(): Int)
@@ -9,4 +9,4 @@ annotation class Ann(
Ann(1 * 1, 1 * 1, 1 * 1, 1 * 1) class MyClass
// EXPECTED: Ann[b = IntegerValueType(1): IntegerValueType(1), i = IntegerValueType(1): IntegerValueType(1), l = IntegerValueType(1): IntegerValueType(1), s = IntegerValueType(1): IntegerValueType(1)]
// EXPECTED: Ann(b = IntegerValueType(1): IntegerValueType(1), i = IntegerValueType(1): IntegerValueType(1), l = IntegerValueType(1): IntegerValueType(1), s = IntegerValueType(1): IntegerValueType(1))
@@ -9,4 +9,4 @@ annotation class Ann(
Ann(1 - 1, 1 - 1, 1 - 1, 1 - 1) class MyClass
// EXPECTED: Ann[b = IntegerValueType(0): IntegerValueType(0), i = IntegerValueType(0): IntegerValueType(0), l = IntegerValueType(0): IntegerValueType(0), s = IntegerValueType(0): IntegerValueType(0)]
// EXPECTED: Ann(b = IntegerValueType(0): IntegerValueType(0), i = IntegerValueType(0): IntegerValueType(0), l = IntegerValueType(0): IntegerValueType(0), s = IntegerValueType(0): IntegerValueType(0))
@@ -9,4 +9,4 @@ annotation class Ann(
Ann(1 % 1, 1 % 1, 1 % 1, 1 % 1) class MyClass
// EXPECTED: Ann[b = IntegerValueType(0): IntegerValueType(0), i = IntegerValueType(0): IntegerValueType(0), l = IntegerValueType(0): IntegerValueType(0), s = IntegerValueType(0): IntegerValueType(0)]
// EXPECTED: Ann(b = IntegerValueType(0): IntegerValueType(0), i = IntegerValueType(0): IntegerValueType(0), l = IntegerValueType(0): IntegerValueType(0), s = IntegerValueType(0): IntegerValueType(0))
@@ -4,4 +4,4 @@ annotation class Ann(val s1: String)
Ann(s1 = """a""" + "b") class MyClass
// EXPECTED: Ann[s1 = "ab": jet.String]
// EXPECTED: Ann(s1 = "ab": String)
@@ -8,4 +8,4 @@ annotation class Ann(
Ann(!true, !false) class MyClass
// EXPECTED: Ann[b1 = false: jet.Boolean, b2 = true: jet.Boolean]
// EXPECTED: Ann(b1 = false: Boolean, b2 = true: Boolean)
@@ -10,4 +10,4 @@ annotation class Ann(
Ann(1 != 2, 1.0 != 2.0, 'b' != 'a', "a" != "b", "a" != "a") class MyClass
// EXPECTED: Ann[b1 = true: jet.Boolean, b2 = true: jet.Boolean, b3 = true: jet.Boolean, b4 = true: jet.Boolean, b5 = false: jet.Boolean]
// EXPECTED: Ann(b1 = true: Boolean, b2 = true: Boolean, b3 = true: Boolean, b4 = true: Boolean, b5 = false: Boolean)
@@ -7,4 +7,4 @@ annotation class Ann(
Ann(true || false, true || true) class MyClass
// EXPECTED: Ann[b1 = true: jet.Boolean, b2 = true: jet.Boolean]
// EXPECTED: Ann(b1 = true: Boolean, b2 = true: Boolean)
@@ -4,4 +4,4 @@ annotation class Ann(i: Int)
Ann((1 + 2) * 2) class MyClass
// EXPECTED: Ann[i = IntegerValueType(6): IntegerValueType(6)]
// EXPECTED: Ann(i = IntegerValueType(6): IntegerValueType(6))
@@ -9,4 +9,4 @@ annotation class Ann(
Ann(1 + 1, 1 + 1, 1 + 1, 1 + 1) class MyClass
// EXPECTED: Ann[b = IntegerValueType(2): IntegerValueType(2), i = IntegerValueType(2): IntegerValueType(2), l = IntegerValueType(2): IntegerValueType(2), s = IntegerValueType(2): IntegerValueType(2)]
// EXPECTED: Ann(b = IntegerValueType(2): IntegerValueType(2), i = IntegerValueType(2): IntegerValueType(2), l = IntegerValueType(2): IntegerValueType(2), s = IntegerValueType(2): IntegerValueType(2))
@@ -10,4 +10,4 @@ annotation class Ann(
Ann(1.plus(1), 1.minus(1), 1.times(1), 1.div(1), 1.mod(1)) class MyClass
// EXPECTED: Ann[p1 = IntegerValueType(2): IntegerValueType(2), p2 = IntegerValueType(0): IntegerValueType(0), p3 = IntegerValueType(1): IntegerValueType(1), p4 = IntegerValueType(1): IntegerValueType(1), p5 = IntegerValueType(0): IntegerValueType(0)]
// EXPECTED: Ann(p1 = IntegerValueType(2): IntegerValueType(2), p2 = IntegerValueType(0): IntegerValueType(0), p3 = IntegerValueType(1): IntegerValueType(1), p4 = IntegerValueType(1): IntegerValueType(1), p5 = IntegerValueType(0): IntegerValueType(0))
@@ -4,4 +4,4 @@ annotation class Ann(val s1: String)
Ann(s1 = "a" + 1) class MyClass
// EXPECTED: Ann[s1 = "a1": jet.String]
// EXPECTED: Ann(s1 = "a1": String)
@@ -16,4 +16,4 @@ Ann(
s4 = "a${i}a$i"
) class MyClass
// EXPECTED: Ann[s1 = "a1": jet.String, s2 = "a1 b": jet.String, s3 = "1": jet.String, s4 = "a1a1": jet.String]
// EXPECTED: Ann(s1 = "a1": String, s2 = "a1 b": String, s3 = "1": String, s4 = "a1a1": String)
@@ -6,4 +6,4 @@ val i = 1
Ann(s1 = "a" + "b", s2 = "a" + "a$i") class MyClass
// EXPECTED: Ann[s1 = "ab": jet.String, s2 = "aa1": jet.String]
// EXPECTED: Ann(s1 = "ab": String, s2 = "aa1": String)
@@ -12,4 +12,4 @@ annotation class Ann(
Ann(-1, -1, -1, -1, -1.0, -1.0.toFloat(), -'c') class MyClass
// EXPECTED: Ann[b1 = IntegerValueType(-1): IntegerValueType(-1), b2 = IntegerValueType(-1): IntegerValueType(-1), b3 = IntegerValueType(-1): IntegerValueType(-1), b4 = IntegerValueType(-1): IntegerValueType(-1), b5 = -1.0.toDouble(): jet.Double, b6 = -1.0.toFloat(): jet.Float, b7 = IntegerValueType(-99): IntegerValueType(-99)]
// EXPECTED: Ann(b1 = IntegerValueType(-1): IntegerValueType(-1), b2 = IntegerValueType(-1): IntegerValueType(-1), b3 = IntegerValueType(-1): IntegerValueType(-1), b4 = IntegerValueType(-1): IntegerValueType(-1), b5 = -1.0.toDouble(): Double, b6 = -1.0.toFloat(): Float, b7 = IntegerValueType(-99): IntegerValueType(-99))
@@ -12,4 +12,4 @@ annotation class Ann(
Ann(+1, +1, +1, +1, +1.0, +1.0.toFloat(), +'c') class MyClass
// EXPECTED: Ann[b1 = IntegerValueType(1): IntegerValueType(1), b2 = IntegerValueType(1): IntegerValueType(1), b3 = IntegerValueType(1): IntegerValueType(1), b4 = IntegerValueType(1): IntegerValueType(1), b5 = 1.0.toDouble(): jet.Double, b6 = 1.0.toFloat(): jet.Float, b7 = IntegerValueType(99): IntegerValueType(99)]
// EXPECTED: Ann(b1 = IntegerValueType(1): IntegerValueType(1), b2 = IntegerValueType(1): IntegerValueType(1), b3 = IntegerValueType(1): IntegerValueType(1), b4 = IntegerValueType(1): IntegerValueType(1), b5 = 1.0.toDouble(): Double, b6 = 1.0.toFloat(): Float, b7 = IntegerValueType(99): IntegerValueType(99))
@@ -7,4 +7,4 @@ annotation class Ann(
Ann(1.toFloat(), 1.0.toFloat()) class MyClass
// EXPECTED: Ann[b1 = 1.0.toFloat(): jet.Float, b2 = 1.0.toFloat(): jet.Float]
// EXPECTED: Ann(b1 = 1.0.toFloat(): Float, b2 = 1.0.toFloat(): Float)
@@ -9,4 +9,4 @@ annotation class Ann(
Ann(1, 1.toInt(), 2147483648.toInt(), 2147483648) class MyClass
// EXPECTED: Ann[b1 = IntegerValueType(1): IntegerValueType(1), b2 = 1.toInt(): jet.Int, b3 = -2147483648.toInt(): jet.Int, b4 = IntegerValueType(2147483648): IntegerValueType(2147483648)]
// EXPECTED: Ann(b1 = IntegerValueType(1): IntegerValueType(1), b2 = 1.toInt(): Int, b3 = -2147483648.toInt(): Int, b4 = IntegerValueType(2147483648): IntegerValueType(2147483648))
@@ -7,4 +7,4 @@ annotation class Ann(
Ann(1, 1.toLong()) class MyClass
// EXPECTED: Ann[b1 = IntegerValueType(1): IntegerValueType(1), b2 = 1.toLong(): jet.Long]
// EXPECTED: Ann(b1 = IntegerValueType(1): IntegerValueType(1), b2 = 1.toLong(): Long)
@@ -9,4 +9,4 @@ annotation class Ann(
Ann(1, 1.toShort(), 32768.toShort(), 32768) class MyClass
// EXPECTED: Ann[b1 = IntegerValueType(1): IntegerValueType(1), b2 = 1.toShort(): jet.Short, b3 = -32768.toShort(): jet.Short, b4 = IntegerValueType(32768): IntegerValueType(32768)]
// EXPECTED: Ann(b1 = IntegerValueType(1): IntegerValueType(1), b2 = 1.toShort(): Short, b3 = -32768.toShort(): Short, b4 = IntegerValueType(32768): IntegerValueType(32768))
@@ -29,12 +29,12 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
import org.jetbrains.jet.lang.descriptors.impl.AnonymousFunctionDescriptor;
import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import org.jetbrains.jet.lang.resolve.name.FqName;
import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.lang.types.TypeProjection;
import org.jetbrains.jet.renderer.DescriptorRenderer;
import org.jetbrains.jet.renderer.DescriptorRendererBuilder;
import java.io.File;
import java.io.IOException;
@@ -43,6 +43,11 @@ import java.util.Collections;
import java.util.List;
public abstract class AbstractAnnotationDescriptorResolveTest extends JetLiteFixture {
private static final DescriptorRenderer WITH_ANNOTATION_ARGUMENT_TYPES = new DescriptorRendererBuilder()
.setVerbose(true)
.setShortNames(true)
.build();
private static final String PATH = "compiler/testData/resolveAnnotations/testFile.kt";
private static final FqName PACKAGE = new FqName("test");
@@ -277,7 +282,7 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends JetLiteFix
String actual = StringUtil.join(member.getAnnotations(), new Function<AnnotationDescriptor, String>() {
@Override
public String fun(AnnotationDescriptor annotationDescriptor) {
return annotationDescriptor.getType().toString() + DescriptorUtils.getSortedValueArguments(annotationDescriptor, DescriptorRenderer.TEXT);
return WITH_ANNOTATION_ARGUMENT_TYPES.renderAnnotation(annotationDescriptor);
}
}, " ");
assertEquals("Failed to resolve annotation descriptor for " + member.toString(), expectedAnnotation, actual);
@@ -288,7 +293,7 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends JetLiteFix
return StringUtil.join(member.getAnnotations(), new Function<AnnotationDescriptor, String>() {
@Override
public String fun(AnnotationDescriptor annotationDescriptor) {
return annotationDescriptor.getType().toString() + DescriptorUtils.getSortedValueArguments(annotationDescriptor, DescriptorRenderer.TEXT);
return WITH_ANNOTATION_ARGUMENT_TYPES.renderAnnotation(annotationDescriptor);
}
}, " ");
}
@@ -21,73 +21,73 @@ import java.io.IOException;
public class AnnotationDescriptorResolveTest extends AbstractAnnotationDescriptorResolveTest {
public void testIntAnnotation() throws IOException {
String content = getContent("AnnInt(1)");
String expectedAnnotation = "AnnInt[a = IntegerValueType(1): IntegerValueType(1)]";
String expectedAnnotation = "AnnInt(a = IntegerValueType(1): IntegerValueType(1))";
doTest(content, expectedAnnotation);
}
public void testStringAnnotation() throws IOException {
String content = getContent("AnnString(\"test\")");
String expectedAnnotation = "AnnString[a = \"test\": jet.String]";
String expectedAnnotation = "AnnString(a = \"test\": String)";
doTest(content, expectedAnnotation);
}
public void testEnumAnnotation() throws IOException {
String content = getContent("AnnEnum(MyEnum.A)");
String expectedAnnotation = "AnnEnum[a = MyEnum.A: test.MyEnum]";
String expectedAnnotation = "AnnEnum(a = MyEnum.A: MyEnum)";
doTest(content, expectedAnnotation);
}
public void testQualifiedEnumAnnotation() throws IOException {
String content = getContent("AnnEnum(test.MyEnum.A)");
String expectedAnnotation = "AnnEnum[a = MyEnum.A: test.MyEnum]";
String content = getContent("AnnEnum(MyEnum.A)");
String expectedAnnotation = "AnnEnum(a = MyEnum.A: MyEnum)";
doTest(content, expectedAnnotation);
}
public void testUnqualifiedEnumAnnotation() throws IOException {
String content = getContent("AnnEnum(A)");
String expectedAnnotation = "AnnEnum[a = MyEnum.A: test.MyEnum]";
String expectedAnnotation = "AnnEnum(a = MyEnum.A: MyEnum)";
doTest(content, expectedAnnotation);
}
public void testIntArrayAnnotation() throws IOException {
String content = getContent("AnnIntArray(intArray(1, 2))");
String expectedAnnotation = "AnnIntArray[a = [IntegerValueType(1), IntegerValueType(2)]: jet.IntArray]";
String expectedAnnotation = "AnnIntArray(a = {IntegerValueType(1), IntegerValueType(2)}: IntArray)";
doTest(content, expectedAnnotation);
}
public void testIntArrayVarargAnnotation() throws IOException {
String content = getContent("AnnIntVararg(1, 2)");
String expectedAnnotation = "AnnIntVararg[a = [IntegerValueType(1), IntegerValueType(2)]: jet.IntArray]";
String expectedAnnotation = "AnnIntVararg(a = {IntegerValueType(1), IntegerValueType(2)}: IntArray)";
doTest(content, expectedAnnotation);
}
public void testStringArrayVarargAnnotation() throws IOException {
String content = getContent("AnnStringVararg(\"a\", \"b\")");
String expectedAnnotation = "AnnStringVararg[a = [\"a\", \"b\"]: jet.Array<jet.String>]";
String expectedAnnotation = "AnnStringVararg(a = {\"a\", \"b\"}: Array<String>)";
doTest(content, expectedAnnotation);
}
public void testStringArrayAnnotation() throws IOException {
String content = getContent("AnnStringArray(array(\"a\"))");
String expectedAnnotation = "AnnStringArray[a = [\"a\"]: jet.Array<jet.String>]";
String expectedAnnotation = "AnnStringArray(a = {\"a\"}: Array<String>)";
doTest(content, expectedAnnotation);
}
public void testEnumArrayAnnotation() throws IOException {
String content = getContent("AnnArrayOfEnum(array(MyEnum.A))");
String expectedAnnotation = "AnnArrayOfEnum[a = [MyEnum.A]: jet.Array<test.MyEnum>]";
String expectedAnnotation = "AnnArrayOfEnum(a = {MyEnum.A}: Array<MyEnum>)";
doTest(content, expectedAnnotation);
}
public void testAnnotationAnnotation() throws Exception {
String content = getContent("AnnAnn(AnnInt(1))");
String expectedAnnotation = "AnnAnn[a = AnnInt[a = IntegerValueType(1)]: test.AnnInt]";
String expectedAnnotation = "AnnAnn(a = AnnInt(a = IntegerValueType(1): IntegerValueType(1)): AnnInt)";
doTest(content, expectedAnnotation);
}
public void testJavaClassAnnotation() throws Exception {
String content = getContent("AnnClass(javaClass<MyClass>())");
String expectedAnnotation = "AnnClass[a = MyClass.class: java.lang.Class<test.MyClass>]";
String expectedAnnotation = "AnnClass(a = MyClass.class: Class<MyClass>)";
doTest(content, expectedAnnotation);
}
}
@@ -20,9 +20,9 @@ import com.google.common.collect.Maps;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.renderer.DescriptorRenderer;
import java.util.Collections;
import java.util.Map;
@@ -59,6 +59,6 @@ public class AnnotationDescriptorImpl implements AnnotationDescriptor {
@Override
public String toString() {
return annotationType.toString() + DescriptorUtils.getSortedValueArguments(this, null);
return DescriptorRenderer.TEXT.renderAnnotation(this);
}
}
@@ -0,0 +1,105 @@
/*
* Copyright 2010-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.lang.descriptors.annotations;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.resolve.constants.*;
import org.jetbrains.jet.lang.resolve.constants.StringValue;
public abstract class DefaultAnnotationArgumentVisitor<R, D> implements AnnotationArgumentVisitor<R, D> {
public abstract R visitValue(@NotNull CompileTimeConstant<?> value, D data);
@Override
public R visitLongValue(@NotNull LongValue value, D data) {
return visitValue(value, data);
}
@Override
public R visitIntValue(IntValue value, D data) {
return visitValue(value, data);
}
@Override
public R visitShortValue(ShortValue value, D data) {
return visitValue(value, data);
}
@Override
public R visitByteValue(ByteValue value, D data) {
return visitValue(value, data);
}
@Override
public R visitDoubleValue(DoubleValue value, D data) {
return visitValue(value, data);
}
@Override
public R visitFloatValue(FloatValue value, D data) {
return visitValue(value, data);
}
@Override
public R visitBooleanValue(BooleanValue value, D data) {
return visitValue(value, data);
}
@Override
public R visitCharValue(CharValue value, D data) {
return visitValue(value, data);
}
@Override
public R visitStringValue(StringValue value, D data) {
return visitValue(value, data);
}
@Override
public R visitNullValue(NullValue value, D data) {
return visitValue(value, data);
}
@Override
public R visitErrorValue(ErrorValue value, D data) {
return visitValue(value, data);
}
@Override
public R visitEnumValue(EnumValue value, D data) {
return visitValue(value, data);
}
@Override
public R visitArrayValue(ArrayValue value, D data) {
return visitValue(value, data);
}
@Override
public R visitAnnotationValue(AnnotationValue value, D data) {
return visitValue(value, data);
}
@Override
public R visitJavaClassValue(JavaClassValue value, D data) {
return visitValue(value, data);
}
@Override
public R visitNumberTypeValue(IntegerValueTypeConstant value, D data) {
return visitValue(value, data);
}
}
@@ -23,9 +23,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
import org.jetbrains.jet.lang.descriptors.impl.AnonymousFunctionDescriptor;
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
import org.jetbrains.jet.lang.resolve.name.FqName;
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
import org.jetbrains.jet.lang.resolve.name.Name;
@@ -35,9 +33,11 @@ import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.lang.types.*;
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.renderer.DescriptorRenderer;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import static org.jetbrains.jet.lang.descriptors.ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER;
@@ -345,23 +345,6 @@ public class DescriptorUtils {
return Visibilities.PUBLIC;
}
@NotNull
public static List<String> getSortedValueArguments(
@NotNull AnnotationDescriptor descriptor,
@Nullable DescriptorRenderer rendererForTypesIfNecessary
) {
List<String> resultList = Lists.newArrayList();
for (Map.Entry<ValueParameterDescriptor, CompileTimeConstant<?>> entry : descriptor.getAllValueArguments().entrySet()) {
CompileTimeConstant<?> value = entry.getValue();
String typeSuffix = rendererForTypesIfNecessary == null
? ""
: ": " + rendererForTypesIfNecessary.renderType(value.getType(KotlinBuiltIns.getInstance()));
resultList.add(entry.getKey().getName().asString() + " = " + value.toString() + typeSuffix);
}
Collections.sort(resultList);
return resultList;
}
@Nullable
public static ClassDescriptor getInnerClassByName(@NotNull ClassDescriptor classDescriptor, @NotNull String innerClassName) {
ClassifierDescriptor classifier = classDescriptor.getDefaultType().getMemberScope().getClassifier(Name.identifier(innerClassName));
@@ -28,6 +28,14 @@ public class AnnotationValue extends CompileTimeConstant<AnnotationDescriptor> {
super(value);
}
@NotNull
@Override
public AnnotationDescriptor getValue() {
AnnotationDescriptor value = super.getValue();
assert value != null : "Guaranteed by constructor";
return value;
}
@Override
@NotNull
public JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns) {
@@ -17,7 +17,6 @@
package org.jetbrains.jet.lang.resolve.constants;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
@@ -33,6 +32,14 @@ public class ArrayValue extends CompileTimeConstant<List<CompileTimeConstant<?>>
this.type = type;
}
@NotNull
@Override
public List<CompileTimeConstant<?>> getValue() {
List<CompileTimeConstant<?>> value = super.getValue();
assert value != null : "Guaranteed by constructor";
return value;
}
@NotNull
@Override
public JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns) {
@@ -27,6 +27,7 @@ public class JavaClassValue extends CompileTimeConstant<JetType> {
super(value);
}
@NotNull
@Override
public JetType getValue() {
return value.getArguments().iterator().next().getType();
@@ -20,6 +20,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.TypeProjection;
@@ -67,6 +68,9 @@ public interface DescriptorRenderer extends Renderer<DeclarationDescriptor> {
@NotNull
String renderTypeArguments(@NotNull List<TypeProjection> typeArguments);
@NotNull
String renderAnnotation(@NotNull AnnotationDescriptor annotation);
@NotNull
@Override
String render(@NotNull DeclarationDescriptor declarationDescriptor);
@@ -19,12 +19,15 @@ package org.jetbrains.jet.renderer;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.Function;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.descriptors.annotations.Annotated;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
import org.jetbrains.jet.lang.descriptors.annotations.DefaultAnnotationArgumentVisitor;
import org.jetbrains.jet.lang.descriptors.impl.DeclarationDescriptorVisitorEmptyBodies;
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import org.jetbrains.jet.lang.resolve.constants.*;
import org.jetbrains.jet.lang.resolve.name.FqName;
import org.jetbrains.jet.lang.resolve.name.FqNameBase;
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
@@ -34,9 +37,7 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import java.util.*;
import static org.jetbrains.jet.lang.types.TypeUtils.CANT_INFER_LAMBDA_PARAM_TYPE;
import static org.jetbrains.jet.lang.types.TypeUtils.CANT_INFER_TYPE_PARAMETER;
import static org.jetbrains.jet.lang.types.TypeUtils.DONT_CARE;
import static org.jetbrains.jet.lang.types.TypeUtils.*;
public class DescriptorRendererImpl implements DescriptorRenderer {
private final boolean shortNames;
@@ -90,7 +91,6 @@ public class DescriptorRendererImpl implements DescriptorRenderer {
this.excludedAnnotationClasses = Sets.newHashSet(excludedAnnotationClasses);
}
/* FORMATTING */
@NotNull
private String renderKeyword(@NotNull String keyword) {
@@ -317,15 +317,72 @@ public class DescriptorRendererImpl implements DescriptorRenderer {
assert annotationClass != null;
if (!excludedAnnotationClasses.contains(DescriptorUtils.getFqNameSafe(annotationClass))) {
builder.append(renderType(annotation.getType()));
if (verbose) {
builder.append("(").append(StringUtil.join(DescriptorUtils.getSortedValueArguments(annotation, this), ", ")).append(")");
}
builder.append(" ");
builder.append(renderAnnotation(annotation)).append(" ");
}
}
}
@Override
@NotNull
public String renderAnnotation(@NotNull AnnotationDescriptor annotation) {
StringBuilder sb = new StringBuilder();
sb.append(renderType(annotation.getType()));
if (verbose) {
sb.append("(").append(StringUtil.join(renderAndSortAnnotationArguments(annotation), ", ")).append(")");
}
return sb.toString();
}
@NotNull
private List<String> renderAndSortAnnotationArguments(@NotNull AnnotationDescriptor descriptor) {
List<String> resultList = Lists.newArrayList();
for (Map.Entry<ValueParameterDescriptor, CompileTimeConstant<?>> entry : descriptor.getAllValueArguments().entrySet()) {
CompileTimeConstant<?> value = entry.getValue();
String typeSuffix = ": " + renderType(value.getType(KotlinBuiltIns.getInstance()));
resultList.add(entry.getKey().getName().asString() + " = " + renderConstant(value) + typeSuffix);
}
Collections.sort(resultList);
return resultList;
}
@NotNull
private String renderConstant(@NotNull CompileTimeConstant<?> value) {
return value.accept(
new DefaultAnnotationArgumentVisitor<String, Void>() {
@Override
public String visitValue(@NotNull CompileTimeConstant<?> value, Void data) {
return value.toString();
}
@Override
public String visitArrayValue(ArrayValue value, Void data) {
return "{" +
StringUtil.join(
value.getValue(),
new Function<CompileTimeConstant<?>, String>() {
@Override
public String fun(CompileTimeConstant<?> constant) {
return renderConstant(constant);
}
},
", ") +
"}";
}
@Override
public String visitAnnotationValue(AnnotationValue value, Void data) {
return renderAnnotation(value.getValue());
}
@Override
public String visitJavaClassValue(JavaClassValue value, Void data) {
return renderType(value.getValue()) + ".class";
}
},
null
);
}
private void renderVisibility(@NotNull Visibility visibility, @NotNull StringBuilder builder) {
if (!modifiers.contains(Modifier.VISIBILITY)) return;
if (normalizedVisibilities) {