-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathAnnotatable.ql
More file actions
34 lines (28 loc) · 1.52 KB
/
Annotatable.ql
File metadata and controls
34 lines (28 loc) · 1.52 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
import java
class RelevantAnnotatable extends Annotatable {
RelevantAnnotatable() {
this.getCompilationUnit().hasName("Annotatable") and this.getCompilationUnit().fromSource()
}
}
query Annotation declaredAnnotation(RelevantAnnotatable a) { result = a.getADeclaredAnnotation() }
/** Note: Only has the annotations as result which are not also considered _declared_. */
query Annotation annotationAdditional(RelevantAnnotatable a) {
result = a.getAnAnnotation() and not result = a.getADeclaredAnnotation()
}
/** Sanity check to verify that `getADeclaredAnnotation()` is a subset of `getAnAnnotation()` */
query Annotation bugAnnotationAdditional(RelevantAnnotatable a) {
result = a.getADeclaredAnnotation() and not result = a.getAnAnnotation()
}
/** Note: Only has the annotations as result which are not part of `getAnAnnotation()`. */
query Annotation associatedAnnotationAdditional(RelevantAnnotatable a) {
result = a.getAnAssociatedAnnotation() and not result = a.getAnAnnotation()
}
/**
* Covers all results of `getAnAssociatedAnnotation()` which are not also a result of `getAnAnnotation()`.
* This should only be the case for a base class using an inheritable annotation `A` and a subclass which
* has an annotation `CA` of the container type of `A`. In that case `A` is not considered _associated_
* and the _indirect_ annotations from `CA` are considered instead.
*/
query Annotation associatedAnnotationNotInherited(RelevantAnnotatable a) {
result = a.getAnAnnotation() and not result = a.getAnAssociatedAnnotation()
}