Kapt: add some JeElement tests

(cherry picked from commit 948a4b6)
This commit is contained in:
Yan Zhulanow
2016-08-02 22:47:18 +03:00
committed by Yan Zhulanow
parent 0fc92c784b
commit 927280f7ce
51 changed files with 1154 additions and 14 deletions
@@ -0,0 +1,31 @@
// test.Main
package test
@MainAnno("A", 5)
class Main {
@field:XAnno(color = Color.GREEN)
val x: String
@get:YAnno(arrayOf<String>("Mary", "Tom"), intArrayOf(1, 3, 5), arrayOf<Color>(Color.GREEN, Color.RED))
val y: String
@set:ZAnno(String::class, arrayOf(String::class, Long::class, Main::class))
var z: String
// Property annotations are lost here (we don't create Elements (javac API) for the synthetic propertyName$annotations() methods)
@MainAnno("B", 6)
val zz: String
}
enum class Color {
RED, GREEN, BLUE
}
annotation class MainAnno(val a: String, val b: Int)
annotation class XAnno(val color: Color)
annotation class YAnno(val names: Array<String>, val ints: Array<Int>, val colors: Array<Color>)
annotation class ZAnno(val clazz: Class<*>, val classes = Array<Class<*>>)
@@ -0,0 +1,33 @@
@test.MainAnno(a = "A", b = 5)
public final class Main {
@test.XAnno(color = GREEN)
@org.jetbrains.annotations.NotNull
private final java.lang.String x
@org.jetbrains.annotations.NotNull
private final java.lang.String y
@org.jetbrains.annotations.NotNull
private java.lang.String z
@org.jetbrains.annotations.NotNull
private final java.lang.String zz
@org.jetbrains.annotations.NotNull
public final java.lang.String getX()
@test.YAnno(names = { "Mary", "Tom" }, ints = { 1, 3, 5 }, colors = { GREEN, RED })
@org.jetbrains.annotations.NotNull
public final java.lang.String getY()
@org.jetbrains.annotations.NotNull
public final java.lang.String getZ()
@test.ZAnno(clazz = java.lang.String.class, classes = { java.lang.String.class, long.class, test.Main.class })
public final void setZ(java.lang.String p)
@org.jetbrains.annotations.NotNull
public final java.lang.String getZz()
public void <init>()
}
@@ -0,0 +1,11 @@
// EnumClass
enum class EnumClass {
RED, GREEN, BLUE;
fun someFun() {
System.out.println("Hello, world!")
}
fun stringRepresentation() = this.toString()
}
@@ -0,0 +1,14 @@
public enum EnumClass {
public static final EnumClass RED
public static final EnumClass GREEN
public static final EnumClass BLUE
public final void someFun()
@org.jetbrains.annotations.NotNull
public final java.lang.String stringRepresentation()
protected void <init>()
}
@@ -0,0 +1,7 @@
// Anno
@Repeatable
@Deprecated
@Retention(AnnotationRetention.RUNTIME)
@Target(AnnotationTarget.CLASS, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.EXPRESSION)
annotation class Anno
@@ -0,0 +1,9 @@
@kotlin.annotation.Repeatable
@kotlin.Deprecated
@kotlin.annotation.Retention(value = RUNTIME)
@kotlin.annotation.Target(allowedTargets = { CLASS, CONSTRUCTOR, EXPRESSION })
@java.lang.annotation.Retention(value = RUNTIME)
@java.lang.annotation.Target(value = { TYPE, CONSTRUCTOR })
public abstract @interface Anno {
}
@@ -0,0 +1,30 @@
// MyClass
class MyClass {
companion object {
val CONST = 2
}
fun myClassFun() {}
class NestedClass {
companion object A {
val CONSTA = 3
}
fun nestedClassFun() {}
class NestedNestedClass {
fun nestedNestedClassFun() {}
}
}
inner class InnerClass {
fun innerClassFun() {}
}
interface InnerInterface {
fun innerInterfaceFun()
fun innerInterfaceFunWithImpl() = 5
}
}
@@ -0,0 +1,53 @@
public final class MyClass {
private static final int CONST
public static final MyClass.Companion Companion
public final void myClassFun()
public void <init>()
public static final class Companion {
public final int getCONST()
private void <init>()
}
public static final class NestedClass {
private static final int CONSTA
public static final MyClass.NestedClass.A A
public final void nestedClassFun()
public void <init>()
public static final class A {
public final int getCONSTA()
private void <init>()
}
public static final class NestedNestedClass {
public final void nestedNestedClassFun()
public void <init>()
}
}
public final class InnerClass {
public final void innerClassFun()
public void <init>()
}
public static abstract interface InnerInterface {
public abstract void innerInterfaceFun()
public abstract int innerInterfaceFunWithImpl()
public static final class DefaultImpls {
public static int innerInterfaceFunWithImpl(MyClass.InnerInterface $this)
}
}
}
@@ -0,0 +1,8 @@
// MyClass
@Repeatable
annotation class Anno(val name: String)
@Anno("Mary")
@Anno("Tom")
class MyClass
@@ -0,0 +1,5 @@
@Anno(name = "Mary")
@Anno(name = "Tom")
public final class MyClass {
public void <init>()
}
@@ -0,0 +1,10 @@
// test.Simple
package test
abstract class Simple(private val prop: String) {
protected val anotherProp: Int = 5
abstract fun strFun(val x: Long): String
fun voidFun() {}
}
@@ -0,0 +1,14 @@
public abstract class Simple {
private final int anotherProp
private final java.lang.String prop
protected final int getAnotherProp()
@org.jetbrains.annotations.NotNull
public abstract java.lang.String strFun(long x)
public final void voidFun()
public void <init>(java.lang.String prop)
}