Add more annotation tests

This commit is contained in:
Tamas Vajk
2022-04-13 09:58:45 +02:00
committed by Chris Smowton
parent a0cd9fea34
commit f465dd5362
6 changed files with 197 additions and 103 deletions

View File

@@ -0,0 +1,3 @@
public @interface Annot0j {
int abc() default 0;
}

View File

@@ -0,0 +1,15 @@
public @interface Annot1j {
int a() default 2;
String b() default "ab";
Class c() default X.class;
Y d() default Y.A;
Y[] e() default { Y.A, Y.B };
Annot0j f() default @Annot0j(
abc = 1
);
}

View File

@@ -1,68 +1,117 @@
Annot0j.java:
# 0| [CompilationUnit] Annot0j
# 1| 1: [Interface] Annot0j
# 2| 1: [Method] abc
# 2| 3: [TypeAccess] int
Annot1j.java:
# 0| [CompilationUnit] Annot1j
# 1| 1: [Interface] Annot1j
# 2| 1: [Method] a
# 2| 3: [TypeAccess] int
# 4| 2: [Method] b
# 4| 3: [TypeAccess] String
# 6| 3: [Method] c
# 6| 3: [TypeAccess] Class<>
# 8| 4: [Method] d
# 8| 3: [TypeAccess] Y
# 10| 5: [Method] e
# 10| 3: [ArrayTypeAccess] ...[]
# 10| 0: [TypeAccess] Y
# 12| 6: [Method] f
# 12| 3: [TypeAccess] Annot0j
def.kt:
# 0| [CompilationUnit] def
# 0| 1: [Class] DefKt
# 13| 1: [Method] fn
# 23| 1: [Method] fn
#-----| 4: (Parameters)
# 13| 0: [Parameter] a
# 13| 5: [BlockStmt] { ... }
# 14| 0: [ExprStmt] <Expr>;
# 14| 0: [MethodAccess] println(...)
# 14| -1: [TypeAccess] ConsoleKt
# 14| 0: [MethodAccess] abc(...)
# 14| -1: [VarAccess] a
# 1| 2: [Interface] SomeAnnotation
# 1| 1: [Method] abc
# 1| 2: [Method] y
# 3| 3: [Interface] ReplaceWith
# 3| 1: [Method] expression
# 5| 4: [Interface] Deprecated
# 6| 1: [Method] message
# 7| 2: [Method] replaceWith
# 9| 5: [Class] X
# 23| 0: [Parameter] a
# 23| 5: [BlockStmt] { ... }
# 24| 0: [ExprStmt] <Expr>;
# 24| 0: [MethodAccess] println(...)
# 24| -1: [TypeAccess] ConsoleKt
# 24| 0: [MethodAccess] a(...)
# 24| -1: [VarAccess] a
# 3| 2: [Interface] Annot0k
# 3| 1: [Method] a
# 5| 3: [Interface] Annot1k
# 6| 1: [Method] a
# 7| 2: [Method] b
# 8| 3: [Method] c
# 9| 4: [Method] d
# 10| 5: [Method] e
# 11| 6: [Method] f
# 14| 4: [Class] X
# 14| 1: [Constructor] X
# 14| 5: [BlockStmt] { ... }
# 14| 0: [SuperConstructorInvocationStmt] super(...)
# 14| 1: [BlockStmt] { ... }
# 15| 5: [Class] Y
# 0| 2: [Method] values
# 0| 2: [Method] valueOf
#-----| 4: (Parameters)
# 0| 0: [Parameter] value
# 15| 4: [Constructor] Y
# 15| 5: [BlockStmt] { ... }
# 15| 0: [ExprStmt] <Expr>;
# 15| 0: [ClassInstanceExpr] new Enum(...)
# 15| -3: [TypeAccess] Unit
# 15| 0: [TypeAccess] Y
# 15| 1: [BlockStmt] { ... }
# 19| 6: [Class] Z
#-----| -3: (Annotations)
# 9| 1: [Annotation] Deprecated
# 0| 1: [StringLiteral] This class is deprecated
# 0| 1: [Annotation] ReplaceWith
# 0| 1: [StringLiteral] Y
# 10| 2: [Annotation] SomeAnnotation
# 0| 1: [IntegerLiteral] 5
# 0| 1: [StringLiteral] a
# 11| 1: [Constructor] X
# 9| 5: [BlockStmt] { ... }
# 9| 0: [SuperConstructorInvocationStmt] super(...)
# 11| 1: [BlockStmt] { ... }
# 19| 1: [Annotation] Annot0k
# 0| 1: [IntegerLiteral] 1
# 20| 2: [Annotation] Annot1k
# 0| 1: [IntegerLiteral] 2
# 0| 1: [StringLiteral] ab
# 0| 1: [TypeLiteral] X.class
# 0| 0: [TypeAccess] X
# 0| 1: [VarAccess] B
# 0| 1: [ArrayInit] {...}
# 0| 1: [VarAccess] C
# 0| 1: [VarAccess] A
# 0| 1: [Annotation] Annot0k
# 0| 1: [IntegerLiteral] 1
# 21| 1: [Constructor] Z
# 19| 5: [BlockStmt] { ... }
# 19| 0: [SuperConstructorInvocationStmt] super(...)
# 21| 1: [BlockStmt] { ... }
use.java:
# 0| [CompilationUnit] use
# 6| 1: [Class] use
#-----| -3: (Annotations)
# 2| 1: [Annotation] Deprecated
# 3| 1: [StringLiteral] "This class is deprecated"
# 4| 2: [Annotation] ReplaceWith
# 4| 1: [StringLiteral] "Y"
# 5| 2: [Annotation] SomeAnnotation
# 5| 2: [StringLiteral] "b"
# 1| 1: [Class] use
#-----| -1: (Base Types)
# 6| 0: [TypeAccess] SomeAnnotation
# 8| 2: [Method] abc
# 1| 0: [TypeAccess] Annot0k
# 3| 2: [Method] a
#-----| 1: (Annotations)
# 7| 1: [Annotation] Override
# 8| 3: [TypeAccess] int
# 8| 5: [BlockStmt] { ... }
# 8| 0: [ReturnStmt] return ...
# 8| 0: [IntegerLiteral] 1
# 10| 3: [Method] y
# 2| 1: [Annotation] Override
# 3| 3: [TypeAccess] int
# 3| 5: [BlockStmt] { ... }
# 3| 0: [ReturnStmt] return ...
# 3| 0: [IntegerLiteral] 1
# 6| 3: [Method] annotationType
#-----| 1: (Annotations)
# 9| 1: [Annotation] Override
# 10| 3: [TypeAccess] String
# 10| 5: [BlockStmt] { ... }
# 10| 0: [ReturnStmt] return ...
# 10| 0: [StringLiteral] ""
# 13| 4: [Method] annotationType
#-----| 1: (Annotations)
# 12| 1: [Annotation] Override
# 13| 3: [TypeAccess] Class<? extends Annotation>
# 13| 0: [WildcardTypeAccess] ? ...
# 13| 0: [TypeAccess] Annotation
# 13| 5: [BlockStmt] { ... }
# 14| 0: [ReturnStmt] return ...
# 14| 0: [NullLiteral] null
# 5| 1: [Annotation] Override
# 6| 3: [TypeAccess] Class<? extends Annotation>
# 6| 0: [WildcardTypeAccess] ? ...
# 6| 0: [TypeAccess] Annotation
# 6| 5: [BlockStmt] { ... }
# 7| 0: [ReturnStmt] return ...
# 7| 0: [NullLiteral] null
# 12| 4: [Class] Z
#-----| -3: (Annotations)
# 10| 1: [Annotation] Annot0j
# 10| 1: [IntegerLiteral] 1
# 11| 2: [Annotation] Annot1j
# 11| 1: [IntegerLiteral] 1
# 11| 2: [StringLiteral] "ac"
# 11| 3: [TypeLiteral] X.class
# 11| 0: [TypeAccess] X
# 11| 4: [VarAccess] Y.B
# 11| -1: [TypeAccess] Y
# 11| 5: [ArrayInit] {...}
# 11| 3: [VarAccess] Y.C
# 11| -1: [TypeAccess] Y
# 11| 4: [VarAccess] Y.A
# 11| -1: [TypeAccess] Y
# 11| 6: [Annotation] Annot0j
# 11| 1: [IntegerLiteral] 2

View File

@@ -1,30 +1,50 @@
annotationDeclarations
| def.kt:1:1:1:87 | SomeAnnotation | def.kt:1:53:1:66 | abc |
| def.kt:1:1:1:87 | SomeAnnotation | def.kt:1:69:1:86 | y |
| def.kt:3:1:3:52 | ReplaceWith | def.kt:3:30:3:51 | expression |
| def.kt:5:1:7:51 | Deprecated | def.kt:6:5:6:23 | message |
| def.kt:5:1:7:51 | Deprecated | def.kt:7:5:7:50 | replaceWith |
| Annot0j.java:1:19:1:25 | Annot0j | Annot0j.java:2:9:2:11 | abc |
| Annot1j.java:1:19:1:25 | Annot1j | Annot1j.java:2:9:2:9 | a |
| Annot1j.java:1:19:1:25 | Annot1j | Annot1j.java:4:12:4:12 | b |
| Annot1j.java:1:19:1:25 | Annot1j | Annot1j.java:6:11:6:11 | c |
| Annot1j.java:1:19:1:25 | Annot1j | Annot1j.java:8:7:8:7 | d |
| Annot1j.java:1:19:1:25 | Annot1j | Annot1j.java:10:9:10:9 | e |
| Annot1j.java:1:19:1:25 | Annot1j | Annot1j.java:12:13:12:13 | f |
| def.kt:3:1:3:60 | Annot0k | def.kt:3:44:3:59 | a |
| def.kt:5:1:12:1 | Annot1k | def.kt:6:5:6:18 | a |
| def.kt:5:1:12:1 | Annot1k | def.kt:7:5:7:24 | b |
| def.kt:5:1:12:1 | Annot1k | def.kt:8:5:8:31 | c |
| def.kt:5:1:12:1 | Annot1k | def.kt:9:5:9:18 | d |
| def.kt:5:1:12:1 | Annot1k | def.kt:10:5:10:32 | e |
| def.kt:5:1:12:1 | Annot1k | def.kt:11:5:11:31 | f |
annotations
| def.kt:0:0:0:0 | ReplaceWith | def.kt:9:1:9:57 | Deprecated | def.kt:3:1:3:52 | ReplaceWith |
| def.kt:9:1:9:57 | Deprecated | def.kt:9:1:11:7 | X | def.kt:5:1:7:51 | Deprecated |
| def.kt:10:1:10:24 | SomeAnnotation | def.kt:9:1:11:7 | X | def.kt:1:1:1:87 | SomeAnnotation |
| use.java:2:1:4:48 | Deprecated | use.java:6:14:6:16 | use | def.kt:5:1:7:51 | Deprecated |
| use.java:4:18:4:47 | ReplaceWith | use.java:2:1:4:48 | Deprecated | def.kt:3:1:3:52 | ReplaceWith |
| use.java:5:1:5:24 | SomeAnnotation | use.java:6:14:6:16 | use | def.kt:1:1:1:87 | SomeAnnotation |
| def.kt:0:0:0:0 | Annot0k | def.kt:20:1:20:40 | Annot1k | def.kt:3:1:3:60 | Annot0k |
| def.kt:19:1:19:17 | Annot0k | def.kt:19:1:21:10 | Z | def.kt:3:1:3:60 | Annot0k |
| def.kt:20:1:20:40 | Annot1k | def.kt:19:1:21:10 | Z | def.kt:5:1:12:1 | Annot1k |
| use.java:10:5:10:21 | Annot0j | use.java:12:18:12:18 | Z | Annot0j.java:1:19:1:25 | Annot0j |
| use.java:11:5:11:90 | Annot1j | use.java:12:18:12:18 | Z | Annot1j.java:1:19:1:25 | Annot1j |
| use.java:11:73:11:89 | Annot0j | use.java:11:5:11:90 | Annot1j | Annot0j.java:1:19:1:25 | Annot0j |
annotationValues
| def.kt:0:0:0:0 | ReplaceWith | def.kt:0:0:0:0 | Y |
| def.kt:9:1:9:57 | Deprecated | def.kt:0:0:0:0 | ReplaceWith |
| def.kt:9:1:9:57 | Deprecated | def.kt:0:0:0:0 | This class is deprecated |
| def.kt:10:1:10:24 | SomeAnnotation | def.kt:0:0:0:0 | 5 |
| def.kt:10:1:10:24 | SomeAnnotation | def.kt:0:0:0:0 | a |
| use.java:2:1:4:48 | Deprecated | use.java:3:14:3:39 | "This class is deprecated" |
| use.java:2:1:4:48 | Deprecated | use.java:4:18:4:47 | ReplaceWith |
| use.java:4:18:4:47 | ReplaceWith | use.java:4:44:4:46 | "Y" |
| use.java:5:1:5:24 | SomeAnnotation | use.java:5:21:5:23 | "b" |
| def.kt:0:0:0:0 | Annot0k | def.kt:0:0:0:0 | 1 |
| def.kt:19:1:19:17 | Annot0k | def.kt:0:0:0:0 | 1 |
| def.kt:20:1:20:40 | Annot1k | def.kt:0:0:0:0 | 2 |
| def.kt:20:1:20:40 | Annot1k | def.kt:0:0:0:0 | Annot0k |
| def.kt:20:1:20:40 | Annot1k | def.kt:0:0:0:0 | B |
| def.kt:20:1:20:40 | Annot1k | def.kt:0:0:0:0 | X.class |
| def.kt:20:1:20:40 | Annot1k | def.kt:0:0:0:0 | ab |
| def.kt:20:1:20:40 | Annot1k | def.kt:0:0:0:0 | {...} |
| use.java:10:5:10:21 | Annot0j | use.java:10:20:10:20 | 1 |
| use.java:11:5:11:90 | Annot1j | use.java:11:18:11:18 | 1 |
| use.java:11:5:11:90 | Annot1j | use.java:11:25:11:28 | "ac" |
| use.java:11:5:11:90 | Annot1j | use.java:11:35:11:41 | X.class |
| use.java:11:5:11:90 | Annot1j | use.java:11:48:11:50 | Y.B |
| use.java:11:5:11:90 | Annot1j | use.java:11:57:11:66 | {...} |
| use.java:11:5:11:90 | Annot1j | use.java:11:73:11:89 | Annot0j |
| use.java:11:73:11:89 | Annot0j | use.java:11:88:11:88 | 2 |
#select
| Annot0j.java:1:19:1:25 | Annot0j | Interface |
| Annot1j.java:1:19:1:25 | Annot1j | Interface |
| def.kt:0:0:0:0 | DefKt | Class |
| def.kt:1:1:1:87 | SomeAnnotation | Interface |
| def.kt:3:1:3:52 | ReplaceWith | Interface |
| def.kt:5:1:7:51 | Deprecated | Interface |
| def.kt:9:1:11:7 | X | Class |
| use.java:6:14:6:16 | use | Class |
| def.kt:3:1:3:60 | Annot0k | Interface |
| def.kt:5:1:12:1 | Annot1k | Interface |
| def.kt:14:1:14:10 | X | Class |
| def.kt:15:1:17:1 | Y | Class |
| def.kt:19:1:21:10 | Z | Class |
| use.java:1:14:1:16 | use | Class |
| use.java:12:18:12:18 | Z | Class |

View File

@@ -1,16 +1,26 @@
annotation class SomeAnnotation(@get:JvmName("abc") val x: Int = 5, val y: String = "")
import kotlin.reflect.KClass
annotation class ReplaceWith(val expression: String)
annotation class Annot0k(@get:JvmName("a") val abc: Int = 0)
annotation class Deprecated(
val message: String,
val replaceWith: ReplaceWith = ReplaceWith(""))
annotation class Annot1k(
val a: Int = 2,
val b: String = "ab",
val c: KClass<*> = X::class,
val d: Y = Y.A,
val e: Array<Y> = [Y.A, Y.B],
val f: Annot0k = Annot0k(1)
)
@Deprecated("This class is deprecated", ReplaceWith("Y"))
@SomeAnnotation(y = "a")
class X
fun fn(a: SomeAnnotation) {
println(a.x)
class X {}
enum class Y {
A,B,C
}
@Annot0k(abc = 1)
@Annot1k(d = Y.B, e = arrayOf(Y.C, Y.A))
class Z {}
fun fn(a: Annot0k) {
println(a.abc)
}

View File

@@ -1,16 +1,13 @@
@Deprecated(
message = "This class is deprecated",
replaceWith = @ReplaceWith(expression = "Y"))
@SomeAnnotation(y = "b")
public class use implements SomeAnnotation {
public class use implements Annot0k {
@Override
public int abc() { return 1; }
@Override
public String y() { return ""; }
public int a() { return 1; }
@Override
public Class<? extends java.lang.annotation.Annotation> annotationType() {
return null;
}
@Annot0j(abc = 1)
@Annot1j(a = 1, b = "ac", c = X.class, d = Y.B, e = {Y.C, Y.A}, f = @Annot0j(abc = 2))
public class Z { }
}