mirror of
https://github.com/github/codeql.git
synced 2026-04-25 08:45:14 +02:00
Rust: Add helper predicates for accessing statements and expressions together.
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
// generated by codegen, remove this comment if you wish to edit this file
|
||||
/**
|
||||
* This module provides a hand-modifiable wrapper around the generated class `StmtList`.
|
||||
*
|
||||
@@ -26,5 +25,25 @@ module Impl {
|
||||
* // ^^^^^^^^^
|
||||
* ```
|
||||
*/
|
||||
class StmtList extends Generated::StmtList { }
|
||||
class StmtList extends Generated::StmtList {
|
||||
/**
|
||||
* Gets the `index`th statement or expression of this statement list (0-based).
|
||||
*/
|
||||
AstNode getStmtOrExpr(int index) {
|
||||
result = this.getStatement(index)
|
||||
or
|
||||
index = max(int i | exists(this.getStatement(i))) + 1 and
|
||||
result = this.getTailExpr()
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets any of the statements or expressions of this statement list.
|
||||
*/
|
||||
final AstNode getAStmtOrExpr() { result = this.getStmtOrExpr(_) }
|
||||
|
||||
/**
|
||||
* Gets the number of statements or expressions of this statement list.
|
||||
*/
|
||||
final int getNumberOfStmtOrExpr() { result = count(int i | exists(this.getStmtOrExpr(i))) }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user