github / github/codeql

Java: Make `Annotatable` abstract / refine `Annotation.getAnnotatedElement()`

Đang mở
#8,647 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
question
Ngôn ngữ chính
CodeQL
Star
10.1k
Fork
2.1k
Merge trung bình
2 ngày 15 giờ
Pull request đã merge (30 ngày)
141

Mô tả

Currently `Annotatable` is a regular CodeQL class which extends `Element`. This makes it cover a lot of entity types which are not actually annotatable, such as all expressions, statements (only some statements are annotatable) and files. This is probably not a big issue, but it prevents for example the CodeQL compiler from detecting incompatible casts.

A related issue is how `Annotation.getAnnotatedElement()` is defined (and that it currently has `Element` as result type). At the moment it erroneously has `Annotation` and `ArrayInit` as result when they contain nested annotations, e.g. `@Outer(@Innter)`, or `@Outer({@Inner(1), @Inner(2)})`.
Example query:
```codeql
import java

from Annotatable a
where not (
a instanceof FieldDeclaration
or a instanceof Member
or a instanceof Package
or a instanceof RefType
or a instanceof TypeAccess
or a instanceof Variable
)
select a, a.getPrimaryQlClasses(), a.getAnAnnotation()
```
[Query Console link](https://lgtm.com/query/6189668047736089840/)

If you give me a hint what the desired solution to this is, I can try to give it a go, unless you want to fix this yourselves of course.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.