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 摘要。