Move PatternExpr to correct file

This commit is contained in:
Chris Smowton
2023-11-15 15:09:49 +00:00
parent 8f10d29f68
commit 176adf4376
2 changed files with 26 additions and 26 deletions

View File

@@ -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() + "(...)" }

View File

@@ -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;