mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
Add test for annotations with annotation-array-typed fields
This commit is contained in:
14
java/ql/test/library-tests/annotation-arrays/Test.java
Normal file
14
java/ql/test/library-tests/annotation-arrays/Test.java
Normal file
@@ -0,0 +1,14 @@
|
||||
class Test {
|
||||
|
||||
@interface CustomAnnotation {
|
||||
String value();
|
||||
}
|
||||
|
||||
@interface ArrayValues {
|
||||
CustomAnnotation[] annotationValues();
|
||||
}
|
||||
|
||||
@ArrayValues(annotationValues = @CustomAnnotation(value = "only")) private int fieldWithSingular;
|
||||
@ArrayValues(annotationValues = {@CustomAnnotation(value = "val1"), @CustomAnnotation(value = "val2")}) private int fieldWithMultiple;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
| Test.java:11:82:11:98 | fieldWithSingular | Test.java:11:3:11:68 | ArrayValues | Test.java:11:35:11:67 | {...} | Test.java:11:35:11:67 | CustomAnnotation |
|
||||
| Test.java:12:119:12:135 | fieldWithMultiple | Test.java:12:3:12:105 | ArrayValues | Test.java:12:35:12:104 | {...} | Test.java:12:36:12:68 | CustomAnnotation |
|
||||
| Test.java:12:119:12:135 | fieldWithMultiple | Test.java:12:3:12:105 | ArrayValues | Test.java:12:35:12:104 | {...} | Test.java:12:71:12:103 | CustomAnnotation |
|
||||
9
java/ql/test/library-tests/annotation-arrays/test.ql
Normal file
9
java/ql/test/library-tests/annotation-arrays/test.ql
Normal file
@@ -0,0 +1,9 @@
|
||||
import java
|
||||
|
||||
from Field f, Annotation ann, Expr value, Expr valueChild
|
||||
where
|
||||
f.getDeclaringType().fromSource() and
|
||||
ann = f.getAnAnnotation() and
|
||||
value = ann.getAValue() and
|
||||
valueChild.getParent() = value
|
||||
select f, ann, value, valueChild
|
||||
Reference in New Issue
Block a user