mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
JS: Add DataFlow::Node.getLocation
This commit is contained in:
@@ -23,31 +23,27 @@ private import semmle.javascript.internal.CachedStages
|
||||
* ```
|
||||
*/
|
||||
class AstNode extends @ast_node, NodeInStmtContainer {
|
||||
override Location getLocation() { hasLocation(this, result) }
|
||||
|
||||
override File getFile() {
|
||||
result = this.getLocation().getFile() // Specialized for performance reasons
|
||||
}
|
||||
|
||||
/** Gets the first token belonging to this element. */
|
||||
Token getFirstToken() {
|
||||
exists(Location l1, Location l2 |
|
||||
exists(DbLocation l1, DbLocation l2, string filepath, int startline, int startcolumn |
|
||||
l1 = this.getLocation() and
|
||||
l2 = result.getLocation() and
|
||||
l1.getFile() = l2.getFile() and
|
||||
l1.getStartLine() = l2.getStartLine() and
|
||||
l1.getStartColumn() = l2.getStartColumn()
|
||||
l1.hasLocationInfo(filepath, startline, startcolumn, _, _) and
|
||||
l2.hasLocationInfo(filepath, startline, startcolumn, _, _)
|
||||
)
|
||||
}
|
||||
|
||||
/** Gets the last token belonging to this element. */
|
||||
Token getLastToken() {
|
||||
exists(Location l1, Location l2 |
|
||||
exists(DbLocation l1, DbLocation l2, string filepath, int endline, int endcolumn |
|
||||
l1 = this.getLocation() and
|
||||
l2 = result.getLocation() and
|
||||
l1.getFile() = l2.getFile() and
|
||||
l1.getEndLine() = l2.getEndLine() and
|
||||
l1.getEndColumn() = l2.getEndColumn()
|
||||
l1.hasLocationInfo(filepath, _, _, endline, endcolumn) and
|
||||
l2.hasLocationInfo(filepath, _, _, endline, endcolumn)
|
||||
) and
|
||||
// exclude empty EOF token
|
||||
not result instanceof EOFToken
|
||||
|
||||
Reference in New Issue
Block a user