mirror of
https://github.com/github/codeql.git
synced 2026-04-24 08:15:14 +02:00
Move PatternExpr to correct file
This commit is contained in:
@@ -2580,6 +2580,32 @@ class NotNullExpr extends UnaryExpr, @notnullexpr {
|
||||
override string getAPrimaryQlClass() { result = "NotNullExpr" }
|
||||
}
|
||||
|
||||
/**
|
||||
* A binding or record pattern.
|
||||
*
|
||||
* Note binding patterns are represented as `LocalVariableDeclExpr`s.
|
||||
*/
|
||||
class PatternExpr extends Expr {
|
||||
PatternExpr() {
|
||||
(
|
||||
this.getParent() instanceof SwitchCase or
|
||||
this.getParent() instanceof InstanceOfExpr or
|
||||
this.getParent() instanceof PatternExpr
|
||||
) and
|
||||
(this instanceof LocalVariableDeclExpr or this instanceof RecordPatternExpr)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets this pattern cast to a binding pattern.
|
||||
*/
|
||||
LocalVariableDeclExpr asBindingPattern() { result = this }
|
||||
|
||||
/**
|
||||
* Gets this pattern cast to a record pattern.
|
||||
*/
|
||||
RecordPatternExpr asRecordPattern() { result = this }
|
||||
}
|
||||
|
||||
/** A record pattern expr, as in `if (x instanceof SomeRecord(int field))`. */
|
||||
class RecordPatternExpr extends Expr, @recordpatternexpr {
|
||||
override string toString() { result = this.getType().toString() + "(...)" }
|
||||
|
||||
@@ -530,32 +530,6 @@ class ConstCase extends SwitchCase {
|
||||
override string getAPrimaryQlClass() { result = "ConstCase" }
|
||||
}
|
||||
|
||||
/**
|
||||
* A binding or record pattern.
|
||||
*
|
||||
* Note binding patterns are represented as `LocalVariableDeclExpr`s.
|
||||
*/
|
||||
class PatternExpr extends Expr {
|
||||
PatternExpr() {
|
||||
(
|
||||
this.getParent() instanceof SwitchCase or
|
||||
this.getParent() instanceof InstanceOfExpr or
|
||||
this.getParent() instanceof PatternExpr
|
||||
) and
|
||||
(this instanceof LocalVariableDeclExpr or this instanceof RecordPatternExpr)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets this pattern cast to a binding pattern.
|
||||
*/
|
||||
LocalVariableDeclExpr asBindingPattern() { result = this }
|
||||
|
||||
/**
|
||||
* Gets this pattern cast to a record pattern.
|
||||
*/
|
||||
RecordPatternExpr asRecordPattern() { result = this }
|
||||
}
|
||||
|
||||
/** A pattern case of a `switch` statement */
|
||||
class PatternCase extends SwitchCase {
|
||||
PatternExpr pattern;
|
||||
|
||||
Reference in New Issue
Block a user