Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2fd8e61

Browse files
committed
Add test of Java/Kotlin annotation naming consistency
1 parent 24434ed commit 2fd8e61

6 files changed

Lines changed: 79 additions & 0 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
User.java:
2+
# 0| [CompilationUnit] User
3+
# 1| 1: [Class] User
4+
# 3| 2: [Method] user
5+
# 3| 3: [TypeAccess] void
6+
#-----| 4: (Parameters)
7+
# 3| 0: [Parameter] a1
8+
# 3| 0: [TypeAccess] Ann1
9+
# 3| 1: [Parameter] a2
10+
# 3| 0: [TypeAccess] Ann2
11+
# 3| 5: [BlockStmt] { ... }
12+
# 4| 0: [ExprStmt] <Expr>;
13+
# 4| 0: [MethodAccess] x(...)
14+
# 4| -1: [VarAccess] a1
15+
# 4| 1: [ExprStmt] <Expr>;
16+
# 4| 0: [MethodAccess] z(...)
17+
# 4| -1: [VarAccess] a2
18+
# 4| 2: [ExprStmt] <Expr>;
19+
# 4| 0: [ClassInstanceExpr] new Annotated(...)
20+
# 4| -3: [TypeAccess] Annotated
21+
test.kt:
22+
# 0| [CompilationUnit] test
23+
# 3| 1: [Interface] Ann1
24+
# 3| 1: [Method] x
25+
# 3| 2: [Method] y
26+
# 5| 2: [Interface] Ann2
27+
# 5| 1: [Method] z
28+
# 5| 2: [Method] w
29+
# 5| 3: [Method] v
30+
# 5| 4: [Method] u
31+
# 7| 3: [Interface] Ann3
32+
# 7| 1: [Method] a
33+
# 9| 4: [Class] Annotated
34+
#-----| -3: (Annotations)
35+
# 9| 2: [Annotation] Ann1
36+
# 0| 1: [IntegerLiteral] 1
37+
# 0| 1: [Annotation] Ann2
38+
# 0| 1: [StringLiteral] "Hello"
39+
# 0| 1: [TypeLiteral] String.class
40+
# 0| 0: [TypeAccess] String
41+
# 0| 1: [ArrayInit] {...}
42+
# 0| 1: [IntegerLiteral] 1
43+
# 0| 1: [IntegerLiteral] 2
44+
# 0| 1: [IntegerLiteral] 3
45+
# 0| 1: [ArrayInit] {...}
46+
# 0| 1: [Annotation] Ann3
47+
# 0| 1: [IntegerLiteral] 1
48+
# 0| 1: [Annotation] Ann3
49+
# 0| 1: [IntegerLiteral] 2
50+
# 10| 1: [Constructor] Annotated
51+
# 9| 5: [BlockStmt] { ... }
52+
# 9| 0: [SuperConstructorInvocationStmt] super(...)
53+
# 10| 1: [BlockStmt] { ... }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
semmle/code/java/PrintAst.ql
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
public class User {
2+
3+
public static void user(Ann1 a1, Ann2 a2) {
4+
a1.x(); a2.z(); new Annotated();
5+
}
6+
7+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import kotlin.reflect.KClass
2+
3+
annotation class Ann1(val x: Int, val y: Ann2) { }
4+
5+
annotation class Ann2(val z: String, val w: KClass<*>, val v: IntArray, val u: Array<Ann3>) { }
6+
7+
annotation class Ann3(val a: Int) { }
8+
9+
@Ann1(1, Ann2("Hello", String::class, intArrayOf(1, 2, 3), arrayOf(Ann3(1), Ann3(2))))
10+
class Annotated { }
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from create_database_utils import *
2+
3+
os.mkdir('out')
4+
os.mkdir('out2')
5+
run_codeql_database_create(["kotlinc test.kt -d out", "javac User.java -cp out -d out2"], lang="java")
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import kotlin.reflect.KClass
2+
3+
fun f(x: KClass<*>) = x

0 commit comments

Comments
 (0)