1
1
private import codeql.ruby.AST
2
2
private import internal.AST
3
+ private import internal.Control
3
4
private import internal.TreeSitter
4
5
5
6
/**
@@ -337,9 +338,7 @@ class TernaryIfExpr extends ConditionalExpr, TTernaryIfExpr {
337
338
* end
338
339
* ```
339
340
*/
340
- class CaseExpr extends ControlExpr , TCase {
341
- final override string getAPrimaryQlClass ( ) { result = "CaseExpr" }
342
-
341
+ class CaseExpr extends ControlExpr instanceof CaseExprImpl {
343
342
/**
344
343
* Gets the expression being compared, if any. For example, `foo` in the following example.
345
344
* ```rb
@@ -359,17 +358,17 @@ class CaseExpr extends ControlExpr, TCase {
359
358
* end
360
359
* ```
361
360
*/
362
- Expr getValue ( ) { none ( ) }
361
+ final Expr getValue ( ) { result = super . getValue ( ) }
363
362
364
363
/**
365
- * Gets the `n`th branch of this case expression, either a `WhenExpr`, or a
366
- * `InClause` or a `StmtSequence`.
364
+ * Gets the `n`th branch of this case expression, either a `WhenExpr`, an
365
+ * `InClause`, or a `StmtSequence`.
367
366
*/
368
- Expr getBranch ( int n ) { none ( ) }
367
+ final Expr getBranch ( int n ) { result = super . getBranch ( n ) }
369
368
370
369
/**
371
- * Gets a branch of this case expression, either a `WhenExpr`, or a
372
- * `InClause` or a `StmtSequence`.
370
+ * Gets a branch of this case expression, either a `WhenExpr`, an
371
+ * `InClause`, or a `StmtSequence`.
373
372
*/
374
373
final Expr getABranch ( ) { result = this .getBranch ( _) }
375
374
@@ -387,10 +386,12 @@ class CaseExpr extends ControlExpr, TCase {
387
386
*/
388
387
final int getNumberOfBranches ( ) { result = count ( this .getBranch ( _) ) }
389
388
389
+ final override string getAPrimaryQlClass ( ) { result = "CaseExpr" }
390
+
390
391
final override string toString ( ) { result = "case ..." }
391
392
392
393
override AstNode getAChild ( string pred ) {
393
- result = super .getAChild ( pred )
394
+ result = ControlExpr . super .getAChild ( pred )
394
395
or
395
396
pred = "getValue" and result = this .getValue ( )
396
397
or
@@ -400,33 +401,6 @@ class CaseExpr extends ControlExpr, TCase {
400
401
}
401
402
}
402
403
403
- private class CaseWhenExpr extends CaseExpr , TCaseExpr {
404
- private Ruby:: Case g ;
405
-
406
- CaseWhenExpr ( ) { this = TCaseExpr ( g ) }
407
-
408
- final override Expr getValue ( ) { toGenerated ( result ) = g .getValue ( ) }
409
-
410
- final override Expr getBranch ( int n ) {
411
- toGenerated ( result ) = g .getChild ( n ) or
412
- toGenerated ( result ) = g .getChild ( n )
413
- }
414
- }
415
-
416
- private class CaseMatch extends CaseExpr , TCaseMatch {
417
- private Ruby:: CaseMatch g ;
418
-
419
- CaseMatch ( ) { this = TCaseMatch ( g ) }
420
-
421
- final override Expr getValue ( ) { toGenerated ( result ) = g .getValue ( ) }
422
-
423
- final override Expr getBranch ( int n ) {
424
- toGenerated ( result ) = g .getClauses ( n )
425
- or
426
- n = count ( g .getClauses ( _) ) and toGenerated ( result ) = g .getElse ( )
427
- }
428
- }
429
-
430
404
/**
431
405
* A `when` branch of a `case` expression.
432
406
* ```rb
0 commit comments