mirror of
https://github.com/github/codeql.git
synced 2026-04-26 09:15:12 +02:00
@@ -250,6 +250,8 @@ class Pair extends Expr, @pair {
|
||||
class Rescue extends Expr, @rescue {
|
||||
final override Rescue::Range range;
|
||||
|
||||
final override string getAPrimaryQlClass() { result = "Rescue" }
|
||||
|
||||
/**
|
||||
* Gets the `n`th exception to match, if any. For example `FirstError` or `SecondError` in:
|
||||
* ```rb
|
||||
@@ -292,3 +294,31 @@ class Rescue extends Expr, @rescue {
|
||||
*/
|
||||
final StmtSequence getBody() { result = range.getBody() }
|
||||
}
|
||||
|
||||
/**
|
||||
* An expression with a `rescue` modifier. For example:
|
||||
* ```rb
|
||||
* contents = read_file rescue ""
|
||||
* ```
|
||||
*/
|
||||
class RescueExpr extends Expr, @rescue_modifier {
|
||||
final override RescueExpr::Range range;
|
||||
|
||||
final override string getAPrimaryQlClass() { result = "RescueExpr" }
|
||||
|
||||
/**
|
||||
* Gets the body of this `RescueExpr`.
|
||||
* ```rb
|
||||
* body rescue handler
|
||||
* ```
|
||||
*/
|
||||
final Stmt getBody() { result = range.getBody() }
|
||||
|
||||
/**
|
||||
* Gets the exception handler of this `RescueExpr`.
|
||||
* ```rb
|
||||
* body rescue handler
|
||||
* ```
|
||||
*/
|
||||
final Stmt getHandler() { result = range.getHandler() }
|
||||
}
|
||||
|
||||
@@ -63,8 +63,6 @@ module AstNode {
|
||||
or
|
||||
this instanceof Generated::Rational
|
||||
or
|
||||
this instanceof Generated::RescueModifier
|
||||
or
|
||||
this instanceof Generated::Subshell
|
||||
}
|
||||
|
||||
|
||||
@@ -320,6 +320,18 @@ module Rescue {
|
||||
}
|
||||
}
|
||||
|
||||
module RescueExpr {
|
||||
class Range extends Expr::Range, @rescue_modifier {
|
||||
final override Generated::RescueModifier generated;
|
||||
|
||||
final Stmt getBody() { result = generated.getBody() }
|
||||
|
||||
final Stmt getHandler() { result = generated.getHandler() }
|
||||
|
||||
final override string toString() { result = "... rescue ..." }
|
||||
}
|
||||
}
|
||||
|
||||
module Pair {
|
||||
class Range extends Expr::Range, @pair {
|
||||
final override Generated::Pair generated;
|
||||
|
||||
@@ -1534,7 +1534,7 @@ cfg.rb:
|
||||
#-----| -> Interpolation
|
||||
|
||||
# 130| ... = ...
|
||||
#-----| -> RescueModifier
|
||||
#-----| -> ... rescue ...
|
||||
|
||||
# 130| Constant
|
||||
#-----| -> ... = ...
|
||||
@@ -1542,7 +1542,7 @@ cfg.rb:
|
||||
# 130| 5
|
||||
#-----| -> Constant
|
||||
|
||||
# 133| RescueModifier
|
||||
# 133| ... rescue ...
|
||||
#-----| -> 1
|
||||
|
||||
# 133| ... / ...
|
||||
|
||||
Reference in New Issue
Block a user