|
| 1 | +class TAstNodeParent = @file or @erb_ast_node; |
| 2 | + |
| 3 | +abstract class AstNodeParent extends TAstNodeParent { |
| 4 | + string toString() { none() } |
| 5 | +} |
| 6 | + |
| 7 | +class AstNode extends AstNodeParent, @erb_ast_node { } |
| 8 | + |
| 9 | +class File extends AstNodeParent, @file { } |
| 10 | + |
| 11 | +class Location extends @location_default { |
| 12 | + string toString() { none() } |
| 13 | +} |
| 14 | + |
| 15 | +pragma[nomagic] |
| 16 | +predicate hasFileParent( |
| 17 | + AstNode n, File f, int startline, int startcolumn, int endline, int endcolumn |
| 18 | +) { |
| 19 | + exists(Location loc | |
| 20 | + not erb_ast_node_parent(n, _, _) and |
| 21 | + erb_ast_node_location(n, loc) and |
| 22 | + locations_default(loc, f, startline, startcolumn, endline, endcolumn) |
| 23 | + ) |
| 24 | +} |
| 25 | + |
| 26 | +pragma[nomagic] |
| 27 | +predicate hasFileParent(AstNode n, File f, int i) { |
| 28 | + n = |
| 29 | + rank[i + 1](AstNode n0, int startline, int startcolumn, int endline, int endcolumn | |
| 30 | + hasFileParent(n0, f, startline, startcolumn, endline, endcolumn) |
| 31 | + | |
| 32 | + n0 order by startline, startcolumn, endline, endcolumn |
| 33 | + ) |
| 34 | +} |
| 35 | + |
| 36 | +from AstNode n, AstNodeParent parent, int i, Location location |
| 37 | +where |
| 38 | + erb_ast_node_location(n, location) and |
| 39 | + ( |
| 40 | + erb_ast_node_parent(n, parent, i) |
| 41 | + or |
| 42 | + hasFileParent(n, parent, i) |
| 43 | + ) |
| 44 | +select n, parent, i, location |
0 commit comments