Skip to content

Commit 8f56ede

Browse files
authored
Merge pull request github#15966 from hvitved/treesitter-split-up-node-info-table
Tree-sitter: Split up `ast_node_info` table into two tables
2 parents e3be205 + 31e0463 commit 8f56ede

File tree

25 files changed

+14315
-8460
lines changed

25 files changed

+14315
-8460
lines changed

ql/ql/src/codeql_ql/ast/internal/TreeSitter.qll

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ module QL {
1212
string toString() { result = this.getAPrimaryQlClass() }
1313

1414
/** Gets the location of this element. */
15-
final L::Location getLocation() { ql_ast_node_info(this, _, _, result) }
15+
final L::Location getLocation() { ql_ast_node_location(this, result) }
1616

1717
/** Gets the parent of this element. */
18-
final AstNode getParent() { ql_ast_node_info(this, result, _, _) }
18+
final AstNode getParent() { ql_ast_node_parent(this, result, _) }
1919

2020
/** Gets the index of this node among the children of its parent. */
21-
final int getParentIndex() { ql_ast_node_info(this, _, result, _) }
21+
final int getParentIndex() { ql_ast_node_parent(this, _, result) }
2222

2323
/** Gets a field or child node of this node. */
2424
AstNode getAFieldOrChild() { none() }
@@ -1282,13 +1282,13 @@ module Dbscheme {
12821282
string toString() { result = this.getAPrimaryQlClass() }
12831283

12841284
/** Gets the location of this element. */
1285-
final L::Location getLocation() { dbscheme_ast_node_info(this, _, _, result) }
1285+
final L::Location getLocation() { dbscheme_ast_node_location(this, result) }
12861286

12871287
/** Gets the parent of this element. */
1288-
final AstNode getParent() { dbscheme_ast_node_info(this, result, _, _) }
1288+
final AstNode getParent() { dbscheme_ast_node_parent(this, result, _) }
12891289

12901290
/** Gets the index of this node among the children of its parent. */
1291-
final int getParentIndex() { dbscheme_ast_node_info(this, _, result, _) }
1291+
final int getParentIndex() { dbscheme_ast_node_parent(this, _, result) }
12921292

12931293
/** Gets a field or child node of this node. */
12941294
AstNode getAFieldOrChild() { none() }
@@ -1618,13 +1618,13 @@ module Blame {
16181618
string toString() { result = this.getAPrimaryQlClass() }
16191619

16201620
/** Gets the location of this element. */
1621-
final L::Location getLocation() { blame_ast_node_info(this, _, _, result) }
1621+
final L::Location getLocation() { blame_ast_node_location(this, result) }
16221622

16231623
/** Gets the parent of this element. */
1624-
final AstNode getParent() { blame_ast_node_info(this, result, _, _) }
1624+
final AstNode getParent() { blame_ast_node_parent(this, result, _) }
16251625

16261626
/** Gets the index of this node among the children of its parent. */
1627-
final int getParentIndex() { blame_ast_node_info(this, _, result, _) }
1627+
final int getParentIndex() { blame_ast_node_parent(this, _, result) }
16281628

16291629
/** Gets a field or child node of this node. */
16301630
AstNode getAFieldOrChild() { none() }
@@ -1731,13 +1731,13 @@ module JSON {
17311731
string toString() { result = this.getAPrimaryQlClass() }
17321732

17331733
/** Gets the location of this element. */
1734-
final L::Location getLocation() { json_ast_node_info(this, _, _, result) }
1734+
final L::Location getLocation() { json_ast_node_location(this, result) }
17351735

17361736
/** Gets the parent of this element. */
1737-
final AstNode getParent() { json_ast_node_info(this, result, _, _) }
1737+
final AstNode getParent() { json_ast_node_parent(this, result, _) }
17381738

17391739
/** Gets the index of this node among the children of its parent. */
1740-
final int getParentIndex() { json_ast_node_info(this, _, result, _) }
1740+
final int getParentIndex() { json_ast_node_parent(this, _, result) }
17411741

17421742
/** Gets a field or child node of this node. */
17431743
AstNode getAFieldOrChild() { none() }

ql/ql/src/ql.dbscheme

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -972,14 +972,16 @@ case @ql_token.kind of
972972

973973
@ql_ast_node = @ql_add_expr | @ql_aggregate | @ql_annot_arg | @ql_annotation | @ql_arityless_predicate_expr | @ql_as_expr | @ql_as_exprs | @ql_body | @ql_bool | @ql_call_body | @ql_call_or_unqual_agg_expr | @ql_charpred | @ql_class_member | @ql_classless_predicate | @ql_comp_term | @ql_conjunction | @ql_dataclass | @ql_datatype | @ql_datatype_branch | @ql_datatype_branches | @ql_disjunction | @ql_expr_aggregate_body | @ql_expr_annotation | @ql_field | @ql_full_aggregate_body | @ql_higher_order_term | @ql_if_term | @ql_implication | @ql_import_directive | @ql_import_module_expr | @ql_in_expr | @ql_instance_of | @ql_literal | @ql_member_predicate | @ql_module | @ql_module_alias_body | @ql_module_expr | @ql_module_instantiation | @ql_module_member | @ql_module_name | @ql_module_param | @ql_mul_expr | @ql_negation | @ql_order_by | @ql_order_bys | @ql_par_expr | @ql_predicate_alias_body | @ql_predicate_expr | @ql_prefix_cast | @ql_ql | @ql_qualified_expr | @ql_qualified_rhs | @ql_quantified | @ql_range | @ql_select | @ql_set_literal | @ql_signature_expr | @ql_special_call | @ql_super_ref | @ql_token | @ql_type_alias_body | @ql_type_expr | @ql_type_union_body | @ql_unary_expr | @ql_unqual_agg_body | @ql_var_decl | @ql_var_name | @ql_variable
974974

975-
@ql_ast_node_parent = @file | @ql_ast_node
975+
ql_ast_node_location(
976+
unique int node: @ql_ast_node ref,
977+
int loc: @location_default ref
978+
);
976979

977980
#keyset[parent, parent_index]
978-
ql_ast_node_info(
981+
ql_ast_node_parent(
979982
unique int node: @ql_ast_node ref,
980-
int parent: @ql_ast_node_parent ref,
981-
int parent_index: int ref,
982-
int loc: @location_default ref
983+
int parent: @ql_ast_node ref,
984+
int parent_index: int ref
983985
);
984986

985987
/*- Dbscheme dbscheme -*/
@@ -1159,14 +1161,16 @@ case @dbscheme_token.kind of
11591161

11601162
@dbscheme_ast_node = @dbscheme_annotation | @dbscheme_args_annotation | @dbscheme_branch | @dbscheme_case_decl | @dbscheme_col_type | @dbscheme_column | @dbscheme_dbscheme | @dbscheme_entry | @dbscheme_repr_type | @dbscheme_table | @dbscheme_table_name | @dbscheme_token | @dbscheme_union_decl
11611163

1162-
@dbscheme_ast_node_parent = @dbscheme_ast_node | @file
1164+
dbscheme_ast_node_location(
1165+
unique int node: @dbscheme_ast_node ref,
1166+
int loc: @location_default ref
1167+
);
11631168

11641169
#keyset[parent, parent_index]
1165-
dbscheme_ast_node_info(
1170+
dbscheme_ast_node_parent(
11661171
unique int node: @dbscheme_ast_node ref,
1167-
int parent: @dbscheme_ast_node_parent ref,
1168-
int parent_index: int ref,
1169-
int loc: @location_default ref
1172+
int parent: @dbscheme_ast_node ref,
1173+
int parent_index: int ref
11701174
);
11711175

11721176
/*- Blame dbscheme -*/
@@ -1222,14 +1226,16 @@ case @blame_token.kind of
12221226

12231227
@blame_ast_node = @blame_blame_entry | @blame_blame_info | @blame_file_entry | @blame_token
12241228

1225-
@blame_ast_node_parent = @blame_ast_node | @file
1229+
blame_ast_node_location(
1230+
unique int node: @blame_ast_node ref,
1231+
int loc: @location_default ref
1232+
);
12261233

12271234
#keyset[parent, parent_index]
1228-
blame_ast_node_info(
1235+
blame_ast_node_parent(
12291236
unique int node: @blame_ast_node ref,
1230-
int parent: @blame_ast_node_parent ref,
1231-
int parent_index: int ref,
1232-
int loc: @location_default ref
1237+
int parent: @blame_ast_node ref,
1238+
int parent_index: int ref
12331239
);
12341240

12351241
/*- JSON dbscheme -*/
@@ -1304,13 +1310,15 @@ case @json_token.kind of
13041310

13051311
@json_ast_node = @json_array | @json_document | @json_object | @json_pair | @json_string__ | @json_token
13061312

1307-
@json_ast_node_parent = @file | @json_ast_node
1313+
json_ast_node_location(
1314+
unique int node: @json_ast_node ref,
1315+
int loc: @location_default ref
1316+
);
13081317

13091318
#keyset[parent, parent_index]
1310-
json_ast_node_info(
1319+
json_ast_node_parent(
13111320
unique int node: @json_ast_node ref,
1312-
int parent: @json_ast_node_parent ref,
1313-
int parent_index: int ref,
1314-
int loc: @location_default ref
1321+
int parent: @json_ast_node ref,
1322+
int parent_index: int ref
13151323
);
13161324

0 commit comments

Comments
 (0)