CodeQL library for Java/Kotlin
codeql/java-all 0.8.9 (changelog, source)

Member predicate ForStmt::getAnIterationVariable

Gets a variable that is used as an iteration variable: it is defined, updated or tested in the head of the for statement.

This only returns variables that are quite certainly loop variables; for complex iterations, it may not return anything.

More precisely, it returns variables that are both accessed in the condition of this for statement and updated in the update expression of this for statement but may be initialized elsewhere.

Variable getAnIterationVariable()