Merge pull request #1342 from aschackmull/java/field-annotation-cu

Java: Check compilation unit of the same element in both disjuncts.
This commit is contained in:
yh-semmle
2019-05-22 16:36:24 -04:00
committed by GitHub

View File

@@ -25,11 +25,15 @@ class Annotation extends @annotation, Expr {
/** Gets the element being annotated. */
Element getAnnotatedElement() {
this.getParent().(Field).getDeclaration().getAField() = result and
this.getCompilationUnit().fromSource()
or
not result.(Field).getCompilationUnit().fromSource() and
this.getParent() = result
exists(Element e | e = this.getParent() |
if e.(Field).getCompilationUnit().fromSource()
then
exists(FieldDeclaration decl |
decl.getField(0) = e and
result = decl.getAField()
)
else result = e
)
}
/** Gets the annotation type declaration for this annotation. */