From 86ae8012beaa51b8016109215be8832bbd863bc7 Mon Sep 17 00:00:00 2001 From: Asger F Date: Thu, 27 Mar 2025 11:31:36 +0100 Subject: [PATCH] Expand downgrade script --- .../jsdoc_type_exprs.ql | 37 +++++++++++++++++++ .../upgrade.properties | 2 + 2 files changed, 39 insertions(+) create mode 100644 javascript/downgrades/ccefb5e2d49318eea4aeafd4c6ae2af9f94ac72a/jsdoc_type_exprs.ql diff --git a/javascript/downgrades/ccefb5e2d49318eea4aeafd4c6ae2af9f94ac72a/jsdoc_type_exprs.ql b/javascript/downgrades/ccefb5e2d49318eea4aeafd4c6ae2af9f94ac72a/jsdoc_type_exprs.ql new file mode 100644 index 00000000000..4f12eb443f9 --- /dev/null +++ b/javascript/downgrades/ccefb5e2d49318eea4aeafd4c6ae2af9f94ac72a/jsdoc_type_exprs.ql @@ -0,0 +1,37 @@ +// Removes all nodes nested inside a qualified type access, +// and changes qualified type access nodes to "named type" nodes. +// +/* + * jsdoc_type_exprs (unique int id: @jsdoc_type_expr, + * int kind: int ref, + * int parent: @jsdoc_type_expr_parent ref, + * int idx: int ref, + * varchar(900) tostring: string ref); + */ + +class JSDocTypeExprParent extends @jsdoc_type_expr_parent { + string toString() { none() } +} + +class JSDocTypeExpr extends @jsdoc_type_expr { + string toString() { none() } + + JSDocTypeExpr getChild(int n) { jsdoc_type_exprs(result, _, this, n, _) } + + int getNewKind() { jsdoc_type_exprs(this, result, _, _, _) } + + predicate shouldRemove() { this = any(JSDocQualifiedTypeAccess a).getChild(_) } +} + +class JSDocQualifiedTypeAccess extends @jsdoc_qualified_type_expr, JSDocTypeExpr { + override int getNewKind() { + result = 5 + /* 5 = @jsdoc_named_type_expr */ + } +} + +from JSDocTypeExpr node, JSDocTypeExprParent parent, int idx, string tostring +where + jsdoc_type_exprs(node, _, parent, idx, tostring) and + not node.shouldRemove() +select node, node.getNewKind(), parent, idx, tostring diff --git a/javascript/downgrades/ccefb5e2d49318eea4aeafd4c6ae2af9f94ac72a/upgrade.properties b/javascript/downgrades/ccefb5e2d49318eea4aeafd4c6ae2af9f94ac72a/upgrade.properties index 9812f386f8c..d67984c6ef9 100644 --- a/javascript/downgrades/ccefb5e2d49318eea4aeafd4c6ae2af9f94ac72a/upgrade.properties +++ b/javascript/downgrades/ccefb5e2d49318eea4aeafd4c6ae2af9f94ac72a/upgrade.properties @@ -1,2 +1,4 @@ description: split up qualified names in jsdoc type exprs compatibility: backwards + +jsdoc_type_exprs.rel: run jsdoc_type_exprs.ql