mirror of
https://github.com/github/codeql.git
synced 2026-02-20 17:03:41 +01:00
AST: add Pattern::getRestIndex
This commit is contained in:
@@ -29,8 +29,6 @@ module AstNode {
|
||||
or
|
||||
this instanceof Generated::RestAssignment
|
||||
or
|
||||
this = any(Generated::RestAssignment ra).getChild()
|
||||
or
|
||||
this instanceof Generated::SymbolArray
|
||||
or
|
||||
this instanceof Generated::Interpolation
|
||||
|
||||
@@ -20,6 +20,8 @@ predicate explicitAssignmentNode(Generated::AstNode n, Generated::AstNode assign
|
||||
parent instanceof Generated::DestructuredLeftAssignment
|
||||
or
|
||||
parent instanceof Generated::LeftAssignmentList
|
||||
or
|
||||
parent instanceof Generated::RestAssignment
|
||||
)
|
||||
}
|
||||
|
||||
@@ -74,6 +76,14 @@ module TuplePattern {
|
||||
|
||||
class Range extends Pattern::Range, Range_ {
|
||||
Pattern::Range getElement(int i) {
|
||||
exists(Generated::AstNode c | c = getChild(i) |
|
||||
result = c.(Generated::RestAssignment).getChild()
|
||||
or
|
||||
not c instanceof Generated::RestAssignment and result = c
|
||||
)
|
||||
}
|
||||
|
||||
private Generated::AstNode getChild(int i) {
|
||||
result = this.(Generated::DestructuredParameter).getChild(i)
|
||||
or
|
||||
result = this.(Generated::DestructuredLeftAssignment).getChild(i)
|
||||
@@ -81,6 +91,8 @@ module TuplePattern {
|
||||
result = this.(Generated::LeftAssignmentList).getChild(i)
|
||||
}
|
||||
|
||||
int getRestIndex() { result = unique(int i | getChild(i) instanceof Generated::RestAssignment) }
|
||||
|
||||
override Variable getAVariable() { result = this.getElement(_).getAVariable() }
|
||||
|
||||
override string toString() { result = "(..., ...)" }
|
||||
|
||||
Reference in New Issue
Block a user