11private import codeql.ruby.AST
22private import internal.AST
3+ private import internal.Control
34private import internal.TreeSitter
45
56/**
@@ -337,9 +338,7 @@ class TernaryIfExpr extends ConditionalExpr, TTernaryIfExpr {
337338 * end
338339 * ```
339340 */
340- class CaseExpr extends ControlExpr , TCase {
341- final override string getAPrimaryQlClass ( ) { result = "CaseExpr" }
342-
341+ class CaseExpr extends ControlExpr instanceof CaseExprImpl {
343342 /**
344343 * Gets the expression being compared, if any. For example, `foo` in the following example.
345344 * ```rb
@@ -359,17 +358,17 @@ class CaseExpr extends ControlExpr, TCase {
359358 * end
360359 * ```
361360 */
362- Expr getValue ( ) { none ( ) }
361+ final Expr getValue ( ) { result = super . getValue ( ) }
363362
364363 /**
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`.
367366 */
368- Expr getBranch ( int n ) { none ( ) }
367+ final Expr getBranch ( int n ) { result = super . getBranch ( n ) }
369368
370369 /**
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`.
373372 */
374373 final Expr getABranch ( ) { result = this .getBranch ( _) }
375374
@@ -387,10 +386,12 @@ class CaseExpr extends ControlExpr, TCase {
387386 */
388387 final int getNumberOfBranches ( ) { result = count ( this .getBranch ( _) ) }
389388
389+ final override string getAPrimaryQlClass ( ) { result = "CaseExpr" }
390+
390391 final override string toString ( ) { result = "case ..." }
391392
392393 override AstNode getAChild ( string pred ) {
393- result = super .getAChild ( pred )
394+ result = ControlExpr . super .getAChild ( pred )
394395 or
395396 pred = "getValue" and result = this .getValue ( )
396397 or
@@ -400,33 +401,6 @@ class CaseExpr extends ControlExpr, TCase {
400401 }
401402}
402403
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-
430404/**
431405 * A `when` branch of a `case` expression.
432406 * ```rb
0 commit comments