Skip to content

Commit 9f83dd5

Browse files
committed
Tree-sitter extractor: extract shared dbscheme fragments into 'prefix.dbscheme'
1 parent 2911a6c commit 9f83dd5

File tree

10 files changed

+228
-348
lines changed

10 files changed

+228
-348
lines changed

config/dbscheme-fragments.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
11
{
22
"files": [
33
"javascript/ql/lib/semmlecode.javascript.dbscheme",
4+
"ruby/ql/lib/ruby.dbscheme",
5+
"ql/ql/src/ql.dbscheme"
46
],
57
"fragments": [
68
"/*- External data -*/",
79
"/*- Files and folders -*/",
10+
"/*- Diagnostic messages -*/",
11+
"/*- Diagnostic messages: severity -*/",
812
"/*- Source location prefix -*/",
913
"/*- Lines of code -*/",
1014
"/*- Configuration files with key value pairs -*/",
1115
"/*- YAML -*/",
1216
"/*- XML Files -*/",
13-
"/*- JavaScript-specific part -*/"
17+
"/*- JavaScript-specific part -*/",
18+
"/*- Ruby dbscheme -*/",
19+
"/*- Erb dbscheme -*/",
20+
"/*- QL dbscheme -*/",
21+
"/*- Dbscheme dbscheme -*/",
22+
"/*- Yaml dbscheme -*/",
23+
"/*- Blame dbscheme -*/",
24+
"/*- JSON dbscheme -*/"
1425
]
1526
}

ql/ql/src/codeql/Locations.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import files.FileSystem
88
*
99
* For more information about locations see [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
1010
*/
11-
class Location extends @location {
11+
class Location extends @location_default {
1212
/** Gets the file for this location. */
1313
File getFile() { locations_default(this, result, _, _, _, _) }
1414

ql/ql/src/ql.dbscheme

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
// CodeQL database schema for QL
22
// Automatically generated from the tree-sitter grammar; do not edit
33

4-
@location = @location_default
5-
4+
/*- Files and folders -*/
5+
6+
/**
7+
* The location of an element.
8+
* The location spans column `startcolumn` of line `startline` to
9+
* column `endcolumn` of line `endline` in file `file`.
10+
* For more information, see
11+
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
12+
*/
613
locations_default(
714
unique int id: @location_default,
815
int file: @file ref,
9-
int start_line: int ref,
10-
int start_column: int ref,
11-
int end_line: int ref,
12-
int end_column: int ref
16+
int beginLine: int ref,
17+
int beginColumn: int ref,
18+
int endLine: int ref,
19+
int endColumn: int ref
1320
);
1421

1522
files(
@@ -29,9 +36,14 @@ containerparent(
2936
unique int child: @container ref
3037
);
3138

32-
sourceLocationPrefix(
33-
string prefix: string ref
34-
);
39+
/*- Source location prefix -*/
40+
41+
/**
42+
* The source location of the snapshot.
43+
*/
44+
sourceLocationPrefix(string prefix : string ref);
45+
46+
/*- Diagnostic messages -*/
3547

3648
diagnostics(
3749
unique int id: @diagnostic,
@@ -42,14 +54,15 @@ diagnostics(
4254
int location: @location_default ref
4355
);
4456

57+
/*- Diagnostic messages: severity -*/
58+
4559
case @diagnostic.severity of
4660
10 = @diagnostic_debug
4761
| 20 = @diagnostic_info
4862
| 30 = @diagnostic_warning
4963
| 40 = @diagnostic_error
5064
;
51-
52-
65+
/*- QL dbscheme -*/
5366
@ql_add_expr_left_type = @ql_add_expr | @ql_aggregate | @ql_call_or_unqual_agg_expr | @ql_comp_term | @ql_conjunction | @ql_disjunction | @ql_expr_annotation | @ql_if_term | @ql_implication | @ql_in_expr | @ql_instance_of | @ql_literal | @ql_mul_expr | @ql_negation | @ql_par_expr | @ql_prefix_cast | @ql_qualified_expr | @ql_quantified | @ql_range | @ql_set_literal | @ql_special_call | @ql_super_ref | @ql_unary_expr | @ql_variable
5467

5568
@ql_add_expr_right_type = @ql_add_expr | @ql_aggregate | @ql_call_or_unqual_agg_expr | @ql_comp_term | @ql_conjunction | @ql_disjunction | @ql_expr_annotation | @ql_if_term | @ql_implication | @ql_in_expr | @ql_instance_of | @ql_literal | @ql_mul_expr | @ql_negation | @ql_par_expr | @ql_prefix_cast | @ql_qualified_expr | @ql_quantified | @ql_range | @ql_set_literal | @ql_special_call | @ql_super_ref | @ql_unary_expr | @ql_variable
@@ -926,9 +939,10 @@ ql_ast_node_info(
926939
unique int node: @ql_ast_node ref,
927940
int parent: @ql_ast_node_parent ref,
928941
int parent_index: int ref,
929-
int loc: @location ref
942+
int loc: @location_default ref
930943
);
931944

945+
/*- Dbscheme dbscheme -*/
932946
dbscheme_annotation_args_annotation(
933947
unique int dbscheme_annotation: @dbscheme_annotation ref,
934948
unique int args_annotation: @dbscheme_args_annotation ref
@@ -1112,9 +1126,10 @@ dbscheme_ast_node_info(
11121126
unique int node: @dbscheme_ast_node ref,
11131127
int parent: @dbscheme_ast_node_parent ref,
11141128
int parent_index: int ref,
1115-
int loc: @location ref
1129+
int loc: @location_default ref
11161130
);
11171131

1132+
/*- Yaml dbscheme -*/
11181133
yaml_comment_def(
11191134
unique int id: @yaml_comment,
11201135
int child: @yaml_token_value ref
@@ -1184,9 +1199,10 @@ yaml_ast_node_info(
11841199
unique int node: @yaml_ast_node ref,
11851200
int parent: @yaml_ast_node_parent ref,
11861201
int parent_index: int ref,
1187-
int loc: @location ref
1202+
int loc: @location_default ref
11881203
);
11891204

1205+
/*- Blame dbscheme -*/
11901206
#keyset[blame_blame_entry, index]
11911207
blame_blame_entry_line(
11921208
int blame_blame_entry: @blame_blame_entry ref,
@@ -1246,9 +1262,10 @@ blame_ast_node_info(
12461262
unique int node: @blame_ast_node ref,
12471263
int parent: @blame_ast_node_parent ref,
12481264
int parent_index: int ref,
1249-
int loc: @location ref
1265+
int loc: @location_default ref
12501266
);
12511267

1268+
/*- JSON dbscheme -*/
12521269
#keyset[json_array, index]
12531270
json_array_child(
12541271
int json_array: @json_array ref,
@@ -1327,6 +1344,6 @@ json_ast_node_info(
13271344
unique int node: @json_ast_node ref,
13281345
int parent: @json_ast_node_parent ref,
13291346
int parent_index: int ref,
1330-
int loc: @location ref
1347+
int loc: @location_default ref
13311348
);
13321349

0 commit comments

Comments
 (0)