JS: Fix bad join order in getNextToken()

This commit is contained in:
Asger F
2025-09-12 09:49:52 +02:00
parent 39f74d808b
commit a5819a14be

View File

@@ -4,6 +4,13 @@
import javascript
private predicate adjacentTokens(Token token1, Token token2) {
exists(TopLevel top, int index |
tokeninfo(token1, _, top, index, _) and
tokeninfo(token2, _, top, index + 1, _)
)
}
/**
* A token occurring in a piece of JavaScript source code.
*
@@ -27,10 +34,7 @@ class Token extends Locatable, @token {
string getValue() { tokeninfo(this, _, _, _, result) }
/** Gets the token following this token inside the same toplevel structure, if any. */
Token getNextToken() {
this.getTopLevel() = result.getTopLevel() and
this.getIndex() + 1 = result.getIndex()
}
Token getNextToken() { adjacentTokens(this, result) }
/** Gets the token preceding this token inside the same toplevel structure, if any. */
Token getPreviousToken() { result.getNextToken() = this }