mirror of
https://github.com/github/codeql.git
synced 2026-02-20 17:03:41 +01:00
Add AST library for control expressions (conditionals and loops)
This commit is contained in:
404
ql/src/codeql_ruby/ast/Control.qll
Normal file
404
ql/src/codeql_ruby/ast/Control.qll
Normal file
@@ -0,0 +1,404 @@
|
||||
private import codeql_ruby.AST
|
||||
private import internal.Control
|
||||
|
||||
/**
|
||||
* A control expression that can be any of the following:
|
||||
* - `case`
|
||||
* - `if`/`unless` (including expression-modifier variants)
|
||||
* - ternary-if (`?:`)
|
||||
* - `while`/`until` (including expression-modifier variants)
|
||||
* - `for`
|
||||
*/
|
||||
class ControlExpr extends Expr {
|
||||
override ControlExpr::Range range;
|
||||
}
|
||||
|
||||
/**
|
||||
* A conditional expression: `if`/`unless` (including expression-modifier
|
||||
* variants), and ternary-if (`?:`) expressions.
|
||||
*/
|
||||
class ConditionalExpr extends Expr {
|
||||
override ConditionalExpr::Range range;
|
||||
|
||||
/**
|
||||
* Gets the condition expression. For example, the result is `foo` in the
|
||||
* following:
|
||||
* ```rb
|
||||
* if foo
|
||||
* bar = 1
|
||||
* end
|
||||
* ```
|
||||
*/
|
||||
final Expr getCondition() { result = range.getCondition() }
|
||||
|
||||
/** Gets the 'then' branch of this conditional expression. */
|
||||
Expr getThen() { result = range.getThen() }
|
||||
|
||||
/** Gets the 'else' branch of this conditional expression, if any. */
|
||||
Expr getElse() { result = range.getElse() }
|
||||
}
|
||||
|
||||
/**
|
||||
* An `if` or `elsif` expression.
|
||||
* ```
|
||||
*/
|
||||
class IfOrElsifExpr extends ConditionalExpr {
|
||||
override IfOrElsifExpr::Range range;
|
||||
|
||||
/** Gets the 'then' branch of this `if`/`elsif` expression. */
|
||||
final override ThenExpr getThen() { result = range.getThen() }
|
||||
|
||||
/**
|
||||
* Gets the `elsif`/`else` branch of this `if`/`elsif` expression, if any. In
|
||||
* the following example, the result is an `ElseExpr` containing `b`.
|
||||
* ```rb
|
||||
* if foo
|
||||
* a
|
||||
* else
|
||||
* b
|
||||
* end
|
||||
* ```
|
||||
* But there is no result for the following:
|
||||
* ```rb
|
||||
* if foo
|
||||
* a
|
||||
* end
|
||||
* ```
|
||||
* There can be at most one result, since `elsif` branches nest. In the
|
||||
* following example, `ifExpr.getElse()` returns an `ElsifExpr`, and the
|
||||
* `else` branch is nested inside that. To get the `ElseExpr` for the `else`
|
||||
* branch, i.e. the one containing `c`, use
|
||||
* `getElse().(ElsifExpr).getElse()`.
|
||||
* ```rb
|
||||
* if foo
|
||||
* a
|
||||
* elsif bar
|
||||
* b
|
||||
* else
|
||||
* c
|
||||
* end
|
||||
* ```
|
||||
*/
|
||||
final override Expr getElse() { result = range.getElse() }
|
||||
}
|
||||
|
||||
/**
|
||||
* An `if` expression.
|
||||
* ```rb
|
||||
* if x
|
||||
* y += 1
|
||||
* end
|
||||
* ```
|
||||
*/
|
||||
class IfExpr extends IfOrElsifExpr, @if {
|
||||
final override IfExpr::Range range;
|
||||
|
||||
final override string getAPrimaryQlClass() { result = "IfExpr" }
|
||||
|
||||
final override string toString() { result = "if ..." }
|
||||
}
|
||||
|
||||
/**
|
||||
* An `elsif` expression.
|
||||
* ```rb
|
||||
* if x
|
||||
* a += 1
|
||||
* elsif y
|
||||
* a += 2
|
||||
* end
|
||||
* ```
|
||||
*/
|
||||
class ElsifExpr extends ConditionalExpr {
|
||||
final override ElsifExpr::Range range;
|
||||
|
||||
final override string getAPrimaryQlClass() { result = "ElsifExpr" }
|
||||
|
||||
final override string toString() { result = "elsif ..." }
|
||||
}
|
||||
|
||||
/**
|
||||
* An `unless` expression.
|
||||
* ```rb
|
||||
* unless x == 0
|
||||
* y /= x
|
||||
* end
|
||||
* ```
|
||||
*/
|
||||
class UnlessExpr extends ConditionalExpr, @unless {
|
||||
final override UnlessExpr::Range range;
|
||||
|
||||
final override string getAPrimaryQlClass() { result = "UnlessExpr" }
|
||||
|
||||
final override string toString() { result = "unless ..." }
|
||||
}
|
||||
|
||||
/**
|
||||
* An expression modified using `if`. In the following example, `getCondition`
|
||||
* returns the `Expr` for `bar`, and `getThen` returns the `Expr` for `foo`.
|
||||
* ```rb
|
||||
* foo if bar
|
||||
* ```
|
||||
*/
|
||||
class IfModifierExpr extends ConditionalExpr, @if_modifier {
|
||||
final override IfModifierExpr::Range range;
|
||||
|
||||
final override string getAPrimaryQlClass() { result = "IfModifierExpr" }
|
||||
|
||||
final override string toString() { result = "... if ..." }
|
||||
|
||||
/**
|
||||
* Does not hold, since `if`-modified expressions cannot have `else`
|
||||
* branches.
|
||||
*/
|
||||
final override Expr getElse() { none() }
|
||||
}
|
||||
|
||||
/**
|
||||
* An expression modified using `unless`. For example, in:
|
||||
* ```rb
|
||||
* y /= x unless x == 0
|
||||
* ```
|
||||
* `getCondition` returns the `x == 0` expression, and `getThen` returns the
|
||||
* `y /= x` expression.
|
||||
*/
|
||||
class UnlessModifierExpr extends ConditionalExpr, @unless_modifier {
|
||||
final override UnlessModifierExpr::Range range;
|
||||
|
||||
final override string getAPrimaryQlClass() { result = "UnlessModifierExpr" }
|
||||
|
||||
final override string toString() { result = "... unless ..." }
|
||||
|
||||
/**
|
||||
* Does not hold, since `unless`-modified expressions cannot have `else`
|
||||
* branches.
|
||||
*/
|
||||
final override Expr getElse() { none() }
|
||||
}
|
||||
|
||||
/**
|
||||
* A conditional expression using the ternary (`?:`) operator.
|
||||
* ```rb
|
||||
* (a > b) ? a : b
|
||||
* ```
|
||||
*/
|
||||
class TernaryIfExpr extends ConditionalExpr, @conditional {
|
||||
final override TernaryIfExpr::Range range;
|
||||
|
||||
final override string getAPrimaryQlClass() { result = "TernaryIfExpr" }
|
||||
|
||||
final override string toString() { result = "... ? ... : ..." }
|
||||
}
|
||||
|
||||
class CaseExpr extends ControlExpr, @case__ {
|
||||
final override CaseExpr::Range range;
|
||||
|
||||
final override string getAPrimaryQlClass() { result = "CaseExpr" }
|
||||
|
||||
final override string toString() { result = "case ..." }
|
||||
|
||||
/**
|
||||
* Gets the expression being compared, if any. For example, `foo` in the following example.
|
||||
* ```rb
|
||||
* case foo
|
||||
* when 0
|
||||
* puts 'zero'
|
||||
* when 1
|
||||
* puts 'one'
|
||||
* end
|
||||
* ```
|
||||
* There is no result for the following example:
|
||||
* ```rb
|
||||
* case
|
||||
* when a then 0
|
||||
* when b then 1
|
||||
* else 2
|
||||
* end
|
||||
* ```
|
||||
*/
|
||||
final Expr getValue() { result = range.getValue() }
|
||||
|
||||
/**
|
||||
* Gets the `n`th branch of this case expression, either a `WhenExpr` or an
|
||||
* `ElseExpr`.
|
||||
*/
|
||||
final Expr getBranch(int n) { result = range.getBranch(n) }
|
||||
|
||||
/**
|
||||
* Gets a branch of this case expression, either a `WhenExpr` or an
|
||||
* `ElseExpr`.
|
||||
*/
|
||||
final Expr getABranch() { result = this.getBranch(_) }
|
||||
|
||||
/** Gets a `when` branch of this case expression. */
|
||||
final WhenExpr getAWhenBranch() { result = range.getAWhenBranch() }
|
||||
|
||||
/** Gets the `else` branch of this case expression, if any. */
|
||||
final ElseExpr getElseBranch() { result = range.getElseBranch() }
|
||||
|
||||
/**
|
||||
* Gets the number of branches of this case expression.
|
||||
*/
|
||||
final int getNumberOfBranches() { result = count(this.getBranch(_)) }
|
||||
}
|
||||
|
||||
/**
|
||||
* A `when` branch of a `case` expression.
|
||||
* ```rb
|
||||
* case
|
||||
* when a>b then x
|
||||
* end
|
||||
* ```
|
||||
*/
|
||||
class WhenExpr extends Expr, @when {
|
||||
final override WhenExpr::Range range;
|
||||
|
||||
final override string getAPrimaryQlClass() { result = "WhenExpr" }
|
||||
|
||||
final override string toString() { result = "when ..." }
|
||||
|
||||
/** Gets the body of this case-when expression. */
|
||||
final ThenExpr getBody() { result = range.getBody() }
|
||||
|
||||
/**
|
||||
* Gets the `n`th pattern (or condition) in this case-when expression.
|
||||
*/
|
||||
final Expr getPattern(int n) { result = range.getPattern(n) }
|
||||
|
||||
/**
|
||||
* Gets a pattern (or condition) in this case-when expression.
|
||||
*/
|
||||
final Expr getAPattern() { result = this.getPattern(_) }
|
||||
|
||||
/**
|
||||
* Gets the number of patterns in this case-when expression.
|
||||
*/
|
||||
final int getNumberOfPatterns() { result = count(this.getPattern(_)) }
|
||||
}
|
||||
|
||||
/**
|
||||
* A loop. That is, a `for` loop, a `while` or `until` loop, or their
|
||||
* expression-modifier variants.
|
||||
*/
|
||||
class Loop extends ControlExpr {
|
||||
override Loop::Range range;
|
||||
|
||||
/** Gets the body of this loop. */
|
||||
Expr getBody() { result = range.getBody() }
|
||||
}
|
||||
|
||||
/**
|
||||
* A `while` loop.
|
||||
* ```rb
|
||||
* while a < b
|
||||
* p a
|
||||
* a += 2
|
||||
* end
|
||||
* ```
|
||||
*/
|
||||
class WhileExpr extends Loop, @while {
|
||||
final override WhileExpr::Range range;
|
||||
|
||||
final override string getAPrimaryQlClass() { result = "WhileExpr" }
|
||||
|
||||
final override string toString() { result = "while ..." }
|
||||
|
||||
/** Gets the body of this `while` loop. */
|
||||
final override DoExpr getBody() { result = range.getBody() }
|
||||
|
||||
/** Gets the condition expression of this `while` loop. */
|
||||
final Expr getCondition() { result = range.getCondition() }
|
||||
}
|
||||
|
||||
/**
|
||||
* An `until` loop.
|
||||
* ```rb
|
||||
* until a >= b
|
||||
* p a
|
||||
* a += 1
|
||||
* end
|
||||
* ```
|
||||
*/
|
||||
class UntilExpr extends Loop, @until {
|
||||
final override UntilExpr::Range range;
|
||||
|
||||
final override string getAPrimaryQlClass() { result = "UntilExpr" }
|
||||
|
||||
final override string toString() { result = "until ..." }
|
||||
|
||||
/** Gets the body of this `until` loop. */
|
||||
final override DoExpr getBody() { result = range.getBody() }
|
||||
|
||||
/** Gets the condition expression of this `until` loop. */
|
||||
final Expr getCondition() { result = range.getCondition() }
|
||||
}
|
||||
|
||||
/**
|
||||
* An expression looped using the `while` modifier. In the following example,
|
||||
* `getCondition` returns the `Expr` for `bar`, and `getBody` returns the
|
||||
* `Expr` for `foo`.
|
||||
* ```rb
|
||||
* foo while bar
|
||||
* ```
|
||||
*/
|
||||
class WhileModifierExpr extends Loop, @while_modifier {
|
||||
final override WhileModifierExpr::Range range;
|
||||
|
||||
final override string getAPrimaryQlClass() { result = "WhileModifierExpr" }
|
||||
|
||||
final override string toString() { result = "... while ..." }
|
||||
|
||||
/** Gets the condition expression of this `while`-modifier. */
|
||||
final Expr getCondition() { result = range.getCondition() }
|
||||
}
|
||||
|
||||
/**
|
||||
* An expression looped using the `until` modifier. In the following example,
|
||||
* `getCondition` returns the `Expr` for `bar`, and `getBody` returns the
|
||||
* `Expr` for `foo`.
|
||||
* ```rb
|
||||
* foo until bar
|
||||
* ```
|
||||
*/
|
||||
class UntilModifierExpr extends Loop, @until_modifier {
|
||||
final override UntilModifierExpr::Range range;
|
||||
|
||||
final override string getAPrimaryQlClass() { result = "UntilModifierExpr" }
|
||||
|
||||
final override string toString() { result = "... until ..." }
|
||||
|
||||
/** Gets the condition expression of this `until`-modifier. */
|
||||
final Expr getCondition() { result = range.getCondition() }
|
||||
}
|
||||
|
||||
/**
|
||||
* A `for` loop.
|
||||
* ```rb
|
||||
* for val in 1..n
|
||||
* sum += val
|
||||
* end
|
||||
* ```
|
||||
*/
|
||||
class ForExpr extends Loop, @for {
|
||||
final override ForExpr::Range range;
|
||||
|
||||
final override string getAPrimaryQlClass() { result = "ForExpr" }
|
||||
|
||||
final override string toString() { result = "for ... in ..." }
|
||||
|
||||
/** Gets the body of this `for` loop. */
|
||||
final override Expr getBody() { result = range.getBody() }
|
||||
|
||||
/** Gets the pattern representing the iteration argument. */
|
||||
final Pattern getPattern() { result = range.getPattern() }
|
||||
|
||||
/**
|
||||
* Gets the value being iterated over. In the following example, the result
|
||||
* is the expression `1..10`:
|
||||
* ```rb
|
||||
* for n in 1..10 do
|
||||
* puts n
|
||||
* end
|
||||
* ```
|
||||
*/
|
||||
final Expr getValue() { result = range.getValue() }
|
||||
}
|
||||
@@ -73,3 +73,59 @@ class RegexLiteral extends Literal, @regex {
|
||||
|
||||
final override string getAPrimaryQlClass() { result = "RegexLiteral" }
|
||||
}
|
||||
|
||||
/** A sequence of expressions. */
|
||||
class ExprSequence extends Expr {
|
||||
override ExprSequence::Range range;
|
||||
|
||||
/** Gets the `n`th expression in this sequence. */
|
||||
final Expr getExpr(int n) { result = this.(ExprSequence::Range).getExpr(n) }
|
||||
|
||||
/** Gets an expression in this sequence. */
|
||||
final Expr getAnExpr() { result = this.getExpr(_) }
|
||||
|
||||
/** Gets the last expression in this sequence. */
|
||||
final Expr getLastExpr() { result = this.getExpr(this.getNumberOfExpressions() - 1) }
|
||||
|
||||
/** Gets the number of expressions in this sequence. */
|
||||
final int getNumberOfExpressions() { result = count(this.getAnExpr()) }
|
||||
|
||||
/** Holds if this sequence has no expressions. */
|
||||
final predicate isEmpty() { this.getNumberOfExpressions() = 0 }
|
||||
}
|
||||
|
||||
/**
|
||||
* A sequence of expressions in a `then` branch of an `if`, `unless`, or `when`
|
||||
* expression.
|
||||
*/
|
||||
class ThenExpr extends ExprSequence, @then {
|
||||
final override ThenExpr::Range range;
|
||||
|
||||
final override string getAPrimaryQlClass() { result = "ThenExpr" }
|
||||
|
||||
final override string toString() { result = "then ..." }
|
||||
}
|
||||
|
||||
/**
|
||||
* A sequence of expressions in an `else` branch of an `if`, `unless`, or
|
||||
* `case` expression.
|
||||
*/
|
||||
class ElseExpr extends ExprSequence, @else {
|
||||
final override ElseExpr::Range range;
|
||||
|
||||
final override string getAPrimaryQlClass() { result = "ElseExpr" }
|
||||
|
||||
final override string toString() { result = "else ..." }
|
||||
}
|
||||
|
||||
/**
|
||||
* A sequence of expressions representing the body of a `for`, `while`, or
|
||||
* `until` loop.
|
||||
*/
|
||||
class DoExpr extends ExprSequence, @do {
|
||||
final override DoExpr::Range range;
|
||||
|
||||
final override string getAPrimaryQlClass() { result = "DoExpr" }
|
||||
|
||||
final override string toString() { result = "do ..." }
|
||||
}
|
||||
|
||||
176
ql/src/codeql_ruby/ast/internal/Control.qll
Normal file
176
ql/src/codeql_ruby/ast/internal/Control.qll
Normal file
@@ -0,0 +1,176 @@
|
||||
private import codeql_ruby.AST
|
||||
private import codeql_ruby.ast.internal.Expr
|
||||
private import codeql_ruby.ast.internal.Pattern
|
||||
private import codeql_ruby.ast.internal.TreeSitter
|
||||
|
||||
module ControlExpr {
|
||||
abstract class Range extends Expr::Range { }
|
||||
}
|
||||
|
||||
module ConditionalExpr {
|
||||
abstract class Range extends ControlExpr::Range {
|
||||
abstract Expr getCondition();
|
||||
|
||||
abstract Expr getThen();
|
||||
|
||||
abstract Expr getElse();
|
||||
}
|
||||
}
|
||||
|
||||
module IfOrElsifExpr {
|
||||
abstract class Range extends ConditionalExpr::Range { }
|
||||
}
|
||||
|
||||
module IfExpr {
|
||||
class Range extends IfOrElsifExpr::Range, @if {
|
||||
final override Generated::If generated;
|
||||
|
||||
final override Expr getCondition() { result = generated.getCondition() }
|
||||
|
||||
final override ThenExpr getThen() { result = generated.getConsequence() }
|
||||
|
||||
final override Expr getElse() { result = generated.getAlternative() }
|
||||
}
|
||||
}
|
||||
|
||||
module ElsifExpr {
|
||||
class Range extends IfOrElsifExpr::Range, @elsif {
|
||||
final override Generated::Elsif generated;
|
||||
|
||||
final override Expr getCondition() { result = generated.getCondition() }
|
||||
|
||||
final override ThenExpr getThen() { result = generated.getConsequence() }
|
||||
|
||||
final override Expr getElse() { result = generated.getAlternative() }
|
||||
}
|
||||
}
|
||||
|
||||
module UnlessExpr {
|
||||
class Range extends ConditionalExpr::Range, @unless {
|
||||
final override Generated::Unless generated;
|
||||
|
||||
final override Expr getCondition() { result = generated.getCondition() }
|
||||
|
||||
final override ThenExpr getThen() { result = generated.getConsequence() }
|
||||
|
||||
final override ElseExpr getElse() { result = generated.getAlternative() }
|
||||
}
|
||||
}
|
||||
|
||||
module IfModifierExpr {
|
||||
class Range extends ConditionalExpr::Range, @if_modifier {
|
||||
final override Generated::IfModifier generated;
|
||||
|
||||
final override Expr getCondition() { result = generated.getCondition() }
|
||||
|
||||
final override Expr getThen() { result = generated.getBody() }
|
||||
|
||||
final override Expr getElse() { none() }
|
||||
}
|
||||
}
|
||||
|
||||
module UnlessModifierExpr {
|
||||
class Range extends ConditionalExpr::Range, @unless_modifier {
|
||||
final override Generated::UnlessModifier generated;
|
||||
|
||||
final override Expr getCondition() { result = generated.getCondition() }
|
||||
|
||||
final override Expr getThen() { result = generated.getBody() }
|
||||
|
||||
final override Expr getElse() { none() }
|
||||
}
|
||||
}
|
||||
|
||||
module TernaryIfExpr {
|
||||
class Range extends ConditionalExpr::Range, @conditional {
|
||||
final override Generated::Conditional generated;
|
||||
|
||||
final override Expr getCondition() { result = generated.getCondition() }
|
||||
|
||||
final override Expr getThen() { result = generated.getConsequence() }
|
||||
|
||||
final override Expr getElse() { result = generated.getAlternative() }
|
||||
}
|
||||
}
|
||||
|
||||
module CaseExpr {
|
||||
class Range extends ControlExpr::Range {
|
||||
final override Generated::Case generated;
|
||||
|
||||
final Expr getValue() { result = generated.getValue() }
|
||||
|
||||
final Expr getBranch(int n) { result = generated.getChild(n) }
|
||||
|
||||
final WhenExpr getAWhenBranch() { result = this.getBranch(_) }
|
||||
|
||||
final ElseExpr getElseBranch() { result = this.getBranch(_) }
|
||||
}
|
||||
}
|
||||
|
||||
module WhenExpr {
|
||||
class Range extends Expr::Range, @when {
|
||||
final override Generated::When generated;
|
||||
|
||||
final ThenExpr getBody() { result = generated.getBody() }
|
||||
|
||||
final Expr getPattern(int n) { result = generated.getPattern(n).getChild() }
|
||||
}
|
||||
}
|
||||
|
||||
module Loop {
|
||||
abstract class Range extends ControlExpr::Range {
|
||||
abstract Expr getBody();
|
||||
}
|
||||
}
|
||||
|
||||
module WhileExpr {
|
||||
class Range extends Loop::Range, @while {
|
||||
final override Generated::While generated;
|
||||
|
||||
final override DoExpr getBody() { result = generated.getBody() }
|
||||
|
||||
final Expr getCondition() { result = generated.getCondition() }
|
||||
}
|
||||
}
|
||||
|
||||
module UntilExpr {
|
||||
class Range extends Loop::Range, @until {
|
||||
final override Generated::Until generated;
|
||||
|
||||
final override DoExpr getBody() { result = generated.getBody() }
|
||||
|
||||
final Expr getCondition() { result = generated.getCondition() }
|
||||
}
|
||||
}
|
||||
|
||||
module WhileModifierExpr {
|
||||
class Range extends Loop::Range, @while_modifier {
|
||||
final override Generated::WhileModifier generated;
|
||||
|
||||
final override Expr getBody() { result = generated.getBody() }
|
||||
|
||||
final Expr getCondition() { result = generated.getCondition() }
|
||||
}
|
||||
}
|
||||
|
||||
module UntilModifierExpr {
|
||||
class Range extends Loop::Range, @until_modifier {
|
||||
final override Generated::UntilModifier generated;
|
||||
|
||||
final override Expr getBody() { result = generated.getBody() }
|
||||
|
||||
final Expr getCondition() { result = generated.getCondition() }
|
||||
}
|
||||
}
|
||||
|
||||
module ForExpr {
|
||||
class Range extends Loop::Range, @for {
|
||||
final override Generated::For generated;
|
||||
|
||||
final override DoExpr getBody() { result = generated.getBody() }
|
||||
|
||||
final Pattern getPattern() { result = generated.getPattern() }
|
||||
|
||||
final Expr getValue() { result = generated.getValue().getChild() }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import codeql_ruby.AST
|
||||
private import codeql_ruby.AST
|
||||
private import codeql_ruby.ast.internal.TreeSitter
|
||||
|
||||
module Expr {
|
||||
@@ -59,3 +59,33 @@ module RegexLiteral {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module ExprSequence {
|
||||
abstract class Range extends Expr::Range {
|
||||
abstract Expr getExpr(int n);
|
||||
}
|
||||
}
|
||||
|
||||
module ThenExpr {
|
||||
class Range extends ExprSequence::Range, @then {
|
||||
final override Generated::Then generated;
|
||||
|
||||
final override Expr getExpr(int n) { result = generated.getChild(n) }
|
||||
}
|
||||
}
|
||||
|
||||
module ElseExpr {
|
||||
class Range extends ExprSequence::Range, @else {
|
||||
final override Generated::Else generated;
|
||||
|
||||
final override Expr getExpr(int n) { result = generated.getChild(n) }
|
||||
}
|
||||
}
|
||||
|
||||
module DoExpr {
|
||||
class Range extends ExprSequence::Range, @do {
|
||||
final override Generated::Do generated;
|
||||
|
||||
final override Expr getExpr(int n) { result = generated.getChild(n) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ private predicate patternNode(Generated::AstNode n, boolean parameter) {
|
||||
any(Generated::Assignment assign).getLeft(),
|
||||
any(Generated::OperatorAssignment assign).getLeft(),
|
||||
any(Generated::ExceptionVariable exceptionVariable).getChild(),
|
||||
any(Generated::For for).getPattern(_)
|
||||
any(Generated::For for).getPattern()
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -621,22 +621,22 @@ module Generated {
|
||||
class For extends @for, AstNode {
|
||||
override string getAPrimaryQlClass() { result = "For" }
|
||||
|
||||
override Location getLocation() { for_def(this, _, _, _, _, result) }
|
||||
override Location getLocation() { for_def(this, _, _, _, _, _, result) }
|
||||
|
||||
Do getBody() { for_def(this, _, _, result, _, _) }
|
||||
Do getBody() { for_def(this, _, _, result, _, _, _) }
|
||||
|
||||
AstNode getPattern(int i) { for_pattern(this, i, result) }
|
||||
AstNode getPattern() { for_def(this, _, _, _, result, _, _) }
|
||||
|
||||
In getValue() { for_def(this, _, _, _, result, _) }
|
||||
In getValue() { for_def(this, _, _, _, _, result, _) }
|
||||
|
||||
override AstNode getParent() { for_def(this, result, _, _, _, _) }
|
||||
override AstNode getParent() { for_def(this, result, _, _, _, _, _) }
|
||||
|
||||
override int getParentIndex() { for_def(this, _, result, _, _, _) }
|
||||
override int getParentIndex() { for_def(this, _, result, _, _, _, _) }
|
||||
|
||||
override AstNode getAFieldOrChild() {
|
||||
for_def(this, _, _, result, _, _) or
|
||||
for_pattern(this, _, result) or
|
||||
for_def(this, _, _, _, result, _)
|
||||
for_def(this, _, _, result, _, _, _) or
|
||||
for_def(this, _, _, _, result, _, _) or
|
||||
for_def(this, _, _, _, _, result, _)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -779,15 +779,15 @@ module Generated {
|
||||
class Interpolation extends @interpolation, AstNode {
|
||||
override string getAPrimaryQlClass() { result = "Interpolation" }
|
||||
|
||||
override Location getLocation() { interpolation_def(this, _, _, _, result) }
|
||||
override Location getLocation() { interpolation_def(this, _, _, result) }
|
||||
|
||||
UnderscoreStatement getChild() { interpolation_def(this, _, _, result, _) }
|
||||
UnderscoreStatement getChild() { interpolation_child(this, result) }
|
||||
|
||||
override AstNode getParent() { interpolation_def(this, result, _, _, _) }
|
||||
override AstNode getParent() { interpolation_def(this, result, _, _) }
|
||||
|
||||
override int getParentIndex() { interpolation_def(this, _, result, _, _) }
|
||||
override int getParentIndex() { interpolation_def(this, _, result, _) }
|
||||
|
||||
override AstNode getAFieldOrChild() { interpolation_def(this, _, _, result, _) }
|
||||
override AstNode getAFieldOrChild() { interpolation_child(this, result) }
|
||||
}
|
||||
|
||||
class KeywordParameter extends @keyword_parameter, AstNode {
|
||||
|
||||
Reference in New Issue
Block a user