File tree Expand file tree Collapse file tree
java/ql/lib/semmle/code/java Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2580,6 +2580,32 @@ class NotNullExpr extends UnaryExpr, @notnullexpr {
25802580 override string getAPrimaryQlClass ( ) { result = "NotNullExpr" }
25812581}
25822582
2583+ /**
2584+ * A binding or record pattern.
2585+ *
2586+ * Note binding patterns are represented as `LocalVariableDeclExpr`s.
2587+ */
2588+ class PatternExpr extends Expr {
2589+ PatternExpr ( ) {
2590+ (
2591+ this .getParent ( ) instanceof SwitchCase or
2592+ this .getParent ( ) instanceof InstanceOfExpr or
2593+ this .getParent ( ) instanceof PatternExpr
2594+ ) and
2595+ ( this instanceof LocalVariableDeclExpr or this instanceof RecordPatternExpr )
2596+ }
2597+
2598+ /**
2599+ * Gets this pattern cast to a binding pattern.
2600+ */
2601+ LocalVariableDeclExpr asBindingPattern ( ) { result = this }
2602+
2603+ /**
2604+ * Gets this pattern cast to a record pattern.
2605+ */
2606+ RecordPatternExpr asRecordPattern ( ) { result = this }
2607+ }
2608+
25832609/** A record pattern expr, as in `if (x instanceof SomeRecord(int field))`. */
25842610class RecordPatternExpr extends Expr , @recordpatternexpr {
25852611 override string toString ( ) { result = this .getType ( ) .toString ( ) + "(...)" }
Original file line number Diff line number Diff line change @@ -530,32 +530,6 @@ class ConstCase extends SwitchCase {
530530 override string getAPrimaryQlClass ( ) { result = "ConstCase" }
531531}
532532
533- /**
534- * A binding or record pattern.
535- *
536- * Note binding patterns are represented as `LocalVariableDeclExpr`s.
537- */
538- class PatternExpr extends Expr {
539- PatternExpr ( ) {
540- (
541- this .getParent ( ) instanceof SwitchCase or
542- this .getParent ( ) instanceof InstanceOfExpr or
543- this .getParent ( ) instanceof PatternExpr
544- ) and
545- ( this instanceof LocalVariableDeclExpr or this instanceof RecordPatternExpr )
546- }
547-
548- /**
549- * Gets this pattern cast to a binding pattern.
550- */
551- LocalVariableDeclExpr asBindingPattern ( ) { result = this }
552-
553- /**
554- * Gets this pattern cast to a record pattern.
555- */
556- RecordPatternExpr asRecordPattern ( ) { result = this }
557- }
558-
559533/** A pattern case of a `switch` statement */
560534class PatternCase extends SwitchCase {
561535 PatternExpr pattern ;
You can’t perform that action at this time.
0 commit comments