github / github/codeql

Java: Add predicates for getting annotated types / TypeAccess

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

描述

Would it be possible to add predicates for getting annotated (`ElementType.TYPE_USE`) types? Respectively `TypeAccess` instances which would then allow getting the annotations.

It appears currently one would have to write complicated predicates for getting the respective `TypeAccess`.
E.g. to get the `TypeAccess` of the method return type, the following appears to work:
```
TypeAccess getReturnTypeAccess(Method m) {
exists (TypeAccess typeAccess |
typeAccess.getParent() = m
and result = typeAccess
)
}
```
Though maybe it is incomplete and also returns generic type parameters and `throws` clause types (haven't tested it yet).
Edit: It appears the return type `TypeAccess` has the child index -1 of the method.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

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