Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 176adf4

Browse files
committed
Move PatternExpr to correct file
1 parent 8f10d29 commit 176adf4

2 files changed

Lines changed: 26 additions & 26 deletions

File tree

java/ql/lib/semmle/code/java/Expr.qll

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff 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))`. */
25842610
class RecordPatternExpr extends Expr, @recordpatternexpr {
25852611
override string toString() { result = this.getType().toString() + "(...)" }

java/ql/lib/semmle/code/java/Statement.qll

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff 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 */
560534
class PatternCase extends SwitchCase {
561535
PatternExpr pattern;

0 commit comments

Comments
 (0)