github / github/codeql

Java: Add predicates for getting annotated types / TypeAccess

Aperta
#3,417 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Java question
Lingua principale
CodeQL
Stelle
10.1k
Fork
2.1k
Merge medio
2g 15h
PR unite (30g)
141

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.