mirror of
https://github.com/github/codeql.git
synced 2026-05-03 12:45:27 +02:00
Ruby: InClause and WhenClause are no longer Expr
This commit is contained in:
@@ -364,13 +364,13 @@ class CaseExpr extends ControlExpr instanceof CaseExprImpl {
|
||||
* Gets the `n`th branch of this case expression, either a `WhenExpr`, an
|
||||
* `InClause`, or a `StmtSequence`.
|
||||
*/
|
||||
final Expr getBranch(int n) { result = super.getBranch(n) }
|
||||
final AstNode getBranch(int n) { result = super.getBranch(n) }
|
||||
|
||||
/**
|
||||
* Gets a branch of this case expression, either a `WhenExpr`, an
|
||||
* `InClause`, or a `StmtSequence`.
|
||||
*/
|
||||
final Expr getABranch() { result = this.getBranch(_) }
|
||||
final AstNode getABranch() { result = this.getBranch(_) }
|
||||
|
||||
/** Gets the `n`th `when` branch of this case expression. */
|
||||
deprecated final WhenExpr getWhenBranch(int n) { result = this.getBranch(n) }
|
||||
@@ -409,7 +409,7 @@ class CaseExpr extends ControlExpr instanceof CaseExprImpl {
|
||||
* end
|
||||
* ```
|
||||
*/
|
||||
class WhenExpr extends Expr, TWhenExpr {
|
||||
class WhenExpr extends AstNode, TWhenExpr {
|
||||
private Ruby::When g;
|
||||
|
||||
WhenExpr() { this = TWhenExpr(g) }
|
||||
@@ -461,7 +461,7 @@ class WhenExpr extends Expr, TWhenExpr {
|
||||
* end
|
||||
* ```
|
||||
*/
|
||||
class InClause extends Expr, TInClause {
|
||||
class InClause extends AstNode, TInClause {
|
||||
private Ruby::InClause g;
|
||||
|
||||
InClause() { this = TInClause(g) }
|
||||
|
||||
@@ -657,10 +657,9 @@ class TSelf = TSelfReal or TSelfSynth;
|
||||
class TDestructuredLhsExpr = TDestructuredLeftAssignment or TLeftAssignmentList;
|
||||
|
||||
class TExpr =
|
||||
TSelf or TArgumentList or TInClause or TRescueClause or TRescueModifierExpr or TPair or
|
||||
TStringConcatenation or TCall or TBlockArgument or TConstantAccess or TControlExpr or
|
||||
TWhenExpr or TLiteral or TCallable or TVariableAccess or TStmtSequence or TOperation or
|
||||
TForwardArgument or TDestructuredLhsExpr;
|
||||
TSelf or TArgumentList or TRescueClause or TRescueModifierExpr or TPair or TStringConcatenation or
|
||||
TCall or TBlockArgument or TConstantAccess or TControlExpr or TLiteral or TCallable or
|
||||
TVariableAccess or TStmtSequence or TOperation or TForwardArgument or TDestructuredLhsExpr;
|
||||
|
||||
class TSplatExpr = TSplatExprReal or TSplatExprSynth;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ private import codeql.ruby.ast.internal.AST
|
||||
abstract class CaseExprImpl extends ControlExpr, TCase {
|
||||
abstract Expr getValue();
|
||||
|
||||
abstract Expr getBranch(int n);
|
||||
abstract AstNode getBranch(int n);
|
||||
}
|
||||
|
||||
class CaseWhenExpr extends CaseExprImpl, TCaseExpr {
|
||||
@@ -15,7 +15,7 @@ class CaseWhenExpr extends CaseExprImpl, TCaseExpr {
|
||||
|
||||
final override Expr getValue() { toGenerated(result) = g.getValue() }
|
||||
|
||||
final override Expr getBranch(int n) {
|
||||
final override AstNode getBranch(int n) {
|
||||
toGenerated(result) = g.getChild(n) or
|
||||
toGenerated(result) = g.getChild(n)
|
||||
}
|
||||
@@ -28,7 +28,7 @@ class CaseMatch extends CaseExprImpl, TCaseMatch {
|
||||
|
||||
final override Expr getValue() { toGenerated(result) = g.getValue() }
|
||||
|
||||
final override Expr getBranch(int n) {
|
||||
final override AstNode getBranch(int n) {
|
||||
toGenerated(result) = g.getClauses(n)
|
||||
or
|
||||
n = count(g.getClauses(_)) and toGenerated(result) = g.getElse()
|
||||
|
||||
@@ -422,7 +422,7 @@ module Trees {
|
||||
super.last(last, c)
|
||||
or
|
||||
not exists(this.getElseBranch()) and
|
||||
exists(MatchingCompletion lc, Expr lastBranch |
|
||||
exists(MatchingCompletion lc, AstNode lastBranch |
|
||||
lastBranch = max(int i | | this.getBranch(i) order by i) and
|
||||
lc.getValue() = false and
|
||||
last(lastBranch, last, lc) and
|
||||
@@ -436,7 +436,7 @@ module Trees {
|
||||
first(this.getBranch(0), succ) and
|
||||
c instanceof SimpleCompletion
|
||||
or
|
||||
exists(int i, Expr branch | branch = this.getBranch(i) |
|
||||
exists(int i, AstNode branch | branch = this.getBranch(i) |
|
||||
last(branch, pred, c) and
|
||||
first(this.getBranch(i + 1), succ) and
|
||||
c.(MatchingCompletion).getValue() = false
|
||||
|
||||
@@ -16,4 +16,4 @@ query predicate caseWhenBranches(CaseExpr c, WhenExpr when, int pIndex, Expr p,
|
||||
body = when.getBody()
|
||||
}
|
||||
|
||||
query predicate caseAllBranches(CaseExpr c, int n, Expr branch) { branch = c.getBranch(n) }
|
||||
query predicate caseAllBranches(CaseExpr c, int n, AstNode branch) { branch = c.getBranch(n) }
|
||||
|
||||
Reference in New Issue
Block a user