Skip to content

Commit 86ae801

Browse files
committed
Expand downgrade script
1 parent cccea91 commit 86ae801

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
description: split up qualified names in jsdoc type exprs
22
compatibility: backwards
3+
4+
jsdoc_type_exprs.rel: run jsdoc_type_exprs.ql

0 commit comments

Comments
 (0)