|
| 1 | +class Expr extends @expr { |
| 2 | + string toString() { none() } |
| 3 | +} |
| 4 | + |
| 5 | +class ExprParent extends @exprparent { |
| 6 | + string toString() { none() } |
| 7 | +} |
| 8 | + |
| 9 | +class RangeStmt extends @rangestmt { |
| 10 | + string toString() { none() } |
| 11 | +} |
| 12 | + |
| 13 | +class Location extends @location { |
| 14 | + string toString() { none() } |
| 15 | +} |
| 16 | + |
| 17 | +newtype TAddedExpr = TRangeElement(RangeStmt stmt) |
| 18 | + |
| 19 | +module Fresh = QlBuiltins::NewEntity<TAddedExpr>; |
| 20 | + |
| 21 | +class TNewExpr = @expr or Fresh::EntityId; |
| 22 | + |
| 23 | +class NewExpr extends TNewExpr { |
| 24 | + string toString() { none() } |
| 25 | +} |
| 26 | + |
| 27 | +class TNewExprParent = @exprparent or Fresh::EntityId; |
| 28 | + |
| 29 | +class NewExprParent extends TNewExprParent { |
| 30 | + string toString() { none() } |
| 31 | +} |
| 32 | + |
| 33 | +class TNewLocatable = @locatable or Fresh::EntityId; |
| 34 | + |
| 35 | +class NewLocatable extends TNewLocatable { |
| 36 | + string toString() { none() } |
| 37 | +} |
| 38 | + |
| 39 | +predicate isRangeElementChild(ExprParent parent, int idx, RangeStmt range) { |
| 40 | + parent = range and |
| 41 | + idx in [0 .. 1] |
| 42 | +} |
| 43 | + |
| 44 | +query predicate new_exprs(NewExpr id, int kind, NewExprParent parent, int idx) { |
| 45 | + exists(RangeStmt range | |
| 46 | + id = Fresh::map(TRangeElement(range)) and |
| 47 | + kind = 55 and |
| 48 | + parent = range and |
| 49 | + idx = 0 |
| 50 | + ) |
| 51 | + or |
| 52 | + exists(ExprParent oldParent | exprs(id, kind, oldParent, idx) | |
| 53 | + exists(RangeStmt range | isRangeElementChild(oldParent, idx, range) | |
| 54 | + parent = Fresh::map(TRangeElement(range)) |
| 55 | + ) |
| 56 | + or |
| 57 | + not isRangeElementChild(oldParent, idx, _) and |
| 58 | + parent = oldParent |
| 59 | + ) |
| 60 | +} |
| 61 | + |
| 62 | +query predicate new_has_location(NewLocatable locatable, Location location) { |
| 63 | + has_location(locatable, location) |
| 64 | + or |
| 65 | + exists(RangeStmt range | |
| 66 | + locatable = Fresh::map(TRangeElement(range)) and |
| 67 | + has_location(range, location) |
| 68 | + ) |
| 69 | +} |
0 commit comments