Add test for annotations with annotation-array-typed fields

This commit is contained in:
Chris Smowton
2022-09-15 22:03:04 +01:00
parent bc93a22e7d
commit 80968eef47
3 changed files with 26 additions and 0 deletions

View 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;
}

View File

@@ -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 |

View 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