-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathAnnotationType.ql
More file actions
46 lines (43 loc) · 1.38 KB
/
AnnotationType.ql
File metadata and controls
46 lines (43 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import java
class RelevantAnnotationType extends AnnotationType {
RelevantAnnotationType() { this.getCompilationUnit().hasName("AnnotationType") }
}
query predicate annotationType(
RelevantAnnotationType t, string flagsString, string targets, string retentionPolicy
) {
flagsString =
concat(string s |
t.isInherited() and s = "inherited"
or
t.isDocumented() and s = "documented"
or
t.isRepeatable() and s = "repeatable"
|
s, "," order by s
) and
(
// Workaround to test if no explicit @Target is specified; in that case any string except
// TYPE_USE, which represents type contexts, is considered a target because it might be
// added to ElementType in a future JDK version
if t.isATargetType("<any-target>")
then
if t.isATargetType("TYPE_USE")
then targets = "BUG: Includes TYPE_USE"
else targets = "<any-target>"
else
targets =
concat(string s |
exists(EnumConstant elementType |
elementType.getDeclaringType().hasQualifiedName("java.lang.annotation", "ElementType") and
s = elementType.getName() and
t.isATargetType(s)
)
|
s, "," order by s
)
) and
retentionPolicy = t.getRetentionPolicy()
}
query AnnotationType containingAnnotationType(RelevantAnnotationType t) {
result = t.getContainingAnnotationType()
}