|
| 1 | +// Removes all nodes nested inside a qualified type access, |
| 2 | +// and changes qualified type access nodes to "named type" nodes. |
| 3 | +// |
| 4 | +/* |
| 5 | + * jsdoc_type_exprs (unique int id: @jsdoc_type_expr, |
| 6 | + * int kind: int ref, |
| 7 | + * int parent: @jsdoc_type_expr_parent ref, |
| 8 | + * int idx: int ref, |
| 9 | + * varchar(900) tostring: string ref); |
| 10 | + */ |
| 11 | + |
| 12 | +class JSDocTypeExprParent extends @jsdoc_type_expr_parent { |
| 13 | + string toString() { none() } |
| 14 | +} |
| 15 | + |
| 16 | +class JSDocTypeExpr extends @jsdoc_type_expr { |
| 17 | + string toString() { none() } |
| 18 | + |
| 19 | + JSDocTypeExpr getChild(int n) { jsdoc_type_exprs(result, _, this, n, _) } |
| 20 | + |
| 21 | + int getNewKind() { jsdoc_type_exprs(this, result, _, _, _) } |
| 22 | + |
| 23 | + predicate shouldRemove() { this = any(JSDocQualifiedTypeAccess a).getChild(_) } |
| 24 | +} |
| 25 | + |
| 26 | +class JSDocQualifiedTypeAccess extends @jsdoc_qualified_type_expr, JSDocTypeExpr { |
| 27 | + override int getNewKind() { |
| 28 | + result = 5 |
| 29 | + /* 5 = @jsdoc_named_type_expr */ |
| 30 | + } |
| 31 | +} |
| 32 | + |
| 33 | +from JSDocTypeExpr node, JSDocTypeExprParent parent, int idx, string tostring |
| 34 | +where |
| 35 | + jsdoc_type_exprs(node, _, parent, idx, tostring) and |
| 36 | + not node.shouldRemove() |
| 37 | +select node, node.getNewKind(), parent, idx, tostring |
0 commit comments