Swift: add BraceStmt.getVariable(_) child with logic in QL.

This commit is contained in:
Nora Dimitrijević
2023-05-23 15:42:37 +02:00
parent 2529312d1d
commit 387cde5972
2 changed files with 20 additions and 0 deletions

View File

@@ -11,4 +11,23 @@ class BraceStmt extends Generated::BraceStmt {
}
override string toString() { result = "{ ... }" }
override AstNode getImmediateElement(int index) {
result =
rank[index + 1](AstNode element, int i |
element = super.getImmediateElement(i) and
not element instanceof VarDecl
|
element order by i
)
}
override VarDecl getVariable(int index) {
result =
rank[index + 1](VarDecl variable, int i |
variable = super.getImmediateElement(i)
|
variable order by i
)
}
}

View File

@@ -935,6 +935,7 @@ class StmtCondition(AstNode):
elements: list[ConditionElement] | child
class BraceStmt(Stmt):
variables: list[VarDecl] | child | doc("variable declared in the scope of this brace statement")
elements: list[AstNode] | child
class BreakStmt(Stmt):