github / github/codeql

Java: Javadoc.getCommentedElement / Documentable.getJavadoc does not work for annotated elements

未关闭
#3,698 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
Java question
主要语言
CodeQL
星标
10.1k
派生
2.1k
平均合并
2 天 15 小时
30 天内合并 PR
141

描述

**Description of the issue**
It appears `Javadoc.getCommentedElement()` respectively `Documentable.getJavadoc()`, to which it delegates, does not work for annotated elements.
Example query for demo projects on https://lgtm.com/query/lang:java/:
```ql
import java

from Javadoc javadoc, int javadocEnd, Documentable documentable, int documentableStart
where
not exists (javadoc.getCommentedElement())
and not isNormalComment(javadoc)
and javadocEnd = javadoc.getLocation().getEndLine()
and documentable.getCompilationUnit() = javadoc.getFile()
and documentableStart = documentable.getLocation().getStartLine()
and documentableStart < javadocEnd + 3
and documentableStart > javadocEnd
select javadoc, documentable
```

Also note that there appears to be something weird going on, because when trying to exclude annotated elements from that query, it still finds them:
```
and not exists (documentable.(Annotatable).getAnAnnotation())
```
Though on the other hand checking `not exists (annotation.getAnnotatedElement())` does not find anything.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。