Skip to content

Commit fef0e1f

Browse files
committed
JS: sync shared dbscheme fragments
1 parent 7225ef0 commit fef0e1f

File tree

2 files changed

+142
-105
lines changed

2 files changed

+142
-105
lines changed

config/dbscheme-fragments.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
{
22
"files": [
3+
"javascript/ql/lib/semmlecode.javascript.dbscheme",
34
],
45
"fragments": [
6+
"/*- External data -*/",
7+
"/*- Files and folders -*/",
8+
"/*- Source location prefix -*/",
9+
"/*- Lines of code -*/",
10+
"/*- Configuration files with key value pairs -*/",
11+
"/*- YAML -*/",
12+
"/*- XML Files -*/",
13+
"/*- JavaScript-specific part -*/"
514
]
615
}

javascript/ql/lib/semmlecode.javascript.dbscheme

Lines changed: 133 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,132 @@
11
/*** Standard fragments ***/
22

3-
/** Files and folders **/
3+
/*- Files and folders -*/
44

5-
@location = @location_default;
6-
7-
locations_default(unique int id: @location_default,
8-
int file: @file ref,
9-
int beginLine: int ref,
10-
int beginColumn: int ref,
11-
int endLine: int ref,
12-
int endColumn: int ref
13-
);
14-
15-
@sourceline = @locatable;
16-
17-
numlines(int element_id: @sourceline ref,
18-
int num_lines: int ref,
19-
int num_code: int ref,
20-
int num_comment: int ref
21-
);
5+
/**
6+
* The location of an element.
7+
* The location spans column `startcolumn` of line `startline` to
8+
* column `endcolumn` of line `endline` in file `file`.
9+
* For more information, see
10+
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
11+
*/
12+
locations_default(
13+
unique int id: @location_default,
14+
int file: @file ref,
15+
int beginLine: int ref,
16+
int beginColumn: int ref,
17+
int endLine: int ref,
18+
int endColumn: int ref
19+
);
2220

23-
files(unique int id: @file,
24-
varchar(900) name: string ref);
21+
files(
22+
unique int id: @file,
23+
string name: string ref
24+
);
2525

26-
folders(unique int id: @folder,
27-
varchar(900) name: string ref);
26+
folders(
27+
unique int id: @folder,
28+
string name: string ref
29+
);
2830

31+
@container = @file | @folder
2932

30-
@container = @folder | @file ;
33+
containerparent(
34+
int parent: @container ref,
35+
unique int child: @container ref
36+
);
3137

38+
/*- Lines of code -*/
3239

33-
containerparent(int parent: @container ref,
34-
unique int child: @container ref);
40+
numlines(
41+
int element_id: @sourceline ref,
42+
int num_lines: int ref,
43+
int num_code: int ref,
44+
int num_comment: int ref
45+
);
3546

36-
/** Duplicate code **/
47+
/*- Duplicate code -*/
3748

3849
duplicateCode(
3950
unique int id : @duplication,
40-
varchar(900) relativePath : string ref,
41-
int equivClass : int ref);
51+
string relativePath : string ref,
52+
int equivClass : int ref
53+
);
4254

4355
similarCode(
4456
unique int id : @similarity,
45-
varchar(900) relativePath : string ref,
46-
int equivClass : int ref);
57+
string relativePath : string ref,
58+
int equivClass : int ref
59+
);
4760

48-
@duplication_or_similarity = @duplication | @similarity;
61+
@duplication_or_similarity = @duplication | @similarity
4962

5063
tokens(
5164
int id : @duplication_or_similarity ref,
5265
int offset : int ref,
5366
int beginLine : int ref,
5467
int beginColumn : int ref,
5568
int endLine : int ref,
56-
int endColumn : int ref);
69+
int endColumn : int ref
70+
);
5771

58-
/** External data **/
72+
/*- External data -*/
5973

74+
/**
75+
* External data, loaded from CSV files during snapshot creation. See
76+
* [Tutorial: Incorporating external data](https://help.semmle.com/wiki/display/SD/Tutorial%3A+Incorporating+external+data)
77+
* for more information.
78+
*/
6079
externalData(
6180
int id : @externalDataElement,
62-
varchar(900) path : string ref,
81+
string path : string ref,
6382
int column: int ref,
64-
varchar(900) value : string ref
83+
string value : string ref
6584
);
6685

86+
/*- Snapshot date -*/
87+
6788
snapshotDate(unique date snapshotDate : date ref);
6889

69-
sourceLocationPrefix(varchar(900) prefix : string ref);
90+
/*- Source location prefix -*/
7091

71-
/** Version control data **/
92+
/**
93+
* The source location of the snapshot.
94+
*/
95+
sourceLocationPrefix(string prefix : string ref);
96+
97+
/*- Version control data -*/
7298

7399
svnentries(
74-
int id : @svnentry,
75-
varchar(500) revision : string ref,
76-
varchar(500) author : string ref,
100+
unique int id : @svnentry,
101+
string revision : string ref,
102+
string author : string ref,
77103
date revisionDate : date ref,
78104
int changeSize : int ref
79-
);
105+
)
80106

81107
svnaffectedfiles(
82108
int id : @svnentry ref,
83109
int file : @file ref,
84-
varchar(500) action : string ref
85-
);
110+
string action : string ref
111+
)
86112

87113
svnentrymsg(
88-
int id : @svnentry ref,
89-
varchar(500) message : string ref
90-
);
114+
unique int id : @svnentry ref,
115+
string message : string ref
116+
)
91117

92118
svnchurn(
93119
int commit : @svnentry ref,
94120
int file : @file ref,
95121
int addedLines : int ref,
96122
int deletedLines : int ref
97-
);
123+
)
98124

125+
/*- JavaScript-specific part -*/
99126

100-
/*** JavaScript-specific part ***/
127+
@location = @location_default
128+
129+
@sourceline = @locatable;
101130

102131
filetype(
103132
int file: @file ref,
@@ -1046,14 +1075,50 @@ jsdoc_has_new_parameter (int fn: @jsdoc_function_type_expr ref);
10461075

10471076
jsdoc_errors (unique int id: @jsdoc_error, int tag: @jsdoc_tag ref, varchar(900) message: string ref, varchar(900) tostring: string ref);
10481077

1049-
// YAML
1078+
@dataflownode = @expr | @function_decl_stmt | @class_decl_stmt | @namespace_declaration | @enum_declaration | @property;
1079+
1080+
@optionalchainable = @call_expr | @propaccess;
1081+
1082+
isOptionalChaining(int id: @optionalchainable ref);
1083+
1084+
/**
1085+
* The time taken for the extraction of a file.
1086+
* This table contains non-deterministic content.
1087+
*
1088+
* The sum of the `time` column for each (`file`, `timerKind`) pair
1089+
* is the total time taken for extraction of `file`. The `extractionPhase`
1090+
* column provides a granular view of the extraction time of the file.
1091+
*/
1092+
extraction_time(
1093+
int file : @file ref,
1094+
// see `com.semmle.js.extractor.ExtractionMetrics.ExtractionPhase`.
1095+
int extractionPhase: int ref,
1096+
// 0 for the elapsed CPU time in nanoseconds, 1 for the elapsed wallclock time in nanoseconds
1097+
int timerKind: int ref,
1098+
float time: float ref
1099+
)
1100+
1101+
/**
1102+
* Non-timing related data for the extraction of a single file.
1103+
* This table contains non-deterministic content.
1104+
*/
1105+
extraction_data(
1106+
int file : @file ref,
1107+
// the absolute path to the cache file
1108+
varchar(900) cacheFile: string ref,
1109+
boolean fromCache: boolean ref,
1110+
int length: int ref
1111+
)
1112+
1113+
/*- YAML -*/
1114+
10501115
#keyset[parent, idx]
10511116
yaml (unique int id: @yaml_node,
10521117
int kind: int ref,
10531118
int parent: @yaml_node_parent ref,
10541119
int idx: int ref,
1055-
varchar(900) tag: string ref,
1056-
varchar(900) tostring: string ref);
1120+
string tag: string ref,
1121+
string tostring: string ref);
10571122

10581123
case @yaml_node.kind of
10591124
0 = @yaml_scalar_node
@@ -1067,41 +1132,41 @@ case @yaml_node.kind of
10671132
@yaml_node_parent = @yaml_collection_node | @file;
10681133

10691134
yaml_anchors (unique int node: @yaml_node ref,
1070-
varchar(900) anchor: string ref);
1135+
string anchor: string ref);
10711136

10721137
yaml_aliases (unique int alias: @yaml_alias_node ref,
1073-
varchar(900) target: string ref);
1138+
string target: string ref);
10741139

10751140
yaml_scalars (unique int scalar: @yaml_scalar_node ref,
10761141
int style: int ref,
1077-
varchar(900) value: string ref);
1142+
string value: string ref);
10781143

10791144
yaml_errors (unique int id: @yaml_error,
1080-
varchar(900) message: string ref);
1145+
string message: string ref);
10811146

10821147
yaml_locations(unique int locatable: @yaml_locatable ref,
10831148
int location: @location_default ref);
10841149

10851150
@yaml_locatable = @yaml_node | @yaml_error;
10861151

1087-
/* XML Files */
1152+
/*- XML Files -*/
10881153

10891154
xmlEncoding(
10901155
unique int id: @file ref,
1091-
varchar(900) encoding: string ref
1156+
string encoding: string ref
10921157
);
10931158

10941159
xmlDTDs(
10951160
unique int id: @xmldtd,
1096-
varchar(900) root: string ref,
1097-
varchar(900) publicId: string ref,
1098-
varchar(900) systemId: string ref,
1161+
string root: string ref,
1162+
string publicId: string ref,
1163+
string systemId: string ref,
10991164
int fileid: @file ref
11001165
);
11011166

11021167
xmlElements(
11031168
unique int id: @xmlelement,
1104-
varchar(900) name: string ref,
1169+
string name: string ref,
11051170
int parentid: @xmlparent ref,
11061171
int idx: int ref,
11071172
int fileid: @file ref
@@ -1110,16 +1175,16 @@ xmlElements(
11101175
xmlAttrs(
11111176
unique int id: @xmlattribute,
11121177
int elementid: @xmlelement ref,
1113-
varchar(900) name: string ref,
1114-
varchar(3600) value: string ref,
1178+
string name: string ref,
1179+
string value: string ref,
11151180
int idx: int ref,
11161181
int fileid: @file ref
11171182
);
11181183

11191184
xmlNs(
11201185
int id: @xmlnamespace,
1121-
varchar(900) prefixName: string ref,
1122-
varchar(900) URI: string ref,
1186+
string prefixName: string ref,
1187+
string URI: string ref,
11231188
int fileid: @file ref
11241189
);
11251190

@@ -1131,14 +1196,14 @@ xmlHasNs(
11311196

11321197
xmlComments(
11331198
unique int id: @xmlcomment,
1134-
varchar(3600) text: string ref,
1199+
string text: string ref,
11351200
int parentid: @xmlparent ref,
11361201
int fileid: @file ref
11371202
);
11381203

11391204
xmlChars(
11401205
unique int id: @xmlcharacters,
1141-
varchar(3600) text: string ref,
1206+
string text: string ref,
11421207
int parentid: @xmlparent ref,
11431208
int idx: int ref,
11441209
int isCDATA: int ref,
@@ -1155,15 +1220,7 @@ xmllocations(
11551220

11561221
@xmllocatable = @xmlcharacters | @xmlelement | @xmlcomment | @xmlattribute | @xmldtd | @file | @xmlnamespace;
11571222

1158-
@dataflownode = @expr | @function_decl_stmt | @class_decl_stmt | @namespace_declaration | @enum_declaration | @property;
1159-
1160-
@optionalchainable = @call_expr | @propaccess;
1161-
1162-
isOptionalChaining(int id: @optionalchainable ref);
1163-
1164-
/*
1165-
* configuration files with key value pairs
1166-
*/
1223+
/*- Configuration files with key value pairs -*/
11671224

11681225
configs(
11691226
unique int id: @config
@@ -1187,32 +1244,3 @@ configLocations(
11871244
);
11881245

11891246
@configLocatable = @config | @configName | @configValue;
1190-
1191-
/**
1192-
* The time taken for the extraction of a file.
1193-
* This table contains non-deterministic content.
1194-
*
1195-
* The sum of the `time` column for each (`file`, `timerKind`) pair
1196-
* is the total time taken for extraction of `file`. The `extractionPhase`
1197-
* column provides a granular view of the extraction time of the file.
1198-
*/
1199-
extraction_time(
1200-
int file : @file ref,
1201-
// see `com.semmle.js.extractor.ExtractionMetrics.ExtractionPhase`.
1202-
int extractionPhase: int ref,
1203-
// 0 for the elapsed CPU time in nanoseconds, 1 for the elapsed wallclock time in nanoseconds
1204-
int timerKind: int ref,
1205-
float time: float ref
1206-
)
1207-
1208-
/**
1209-
* Non-timing related data for the extraction of a single file.
1210-
* This table contains non-deterministic content.
1211-
*/
1212-
extraction_data(
1213-
int file : @file ref,
1214-
// the absolute path to the cache file
1215-
varchar(900) cacheFile: string ref,
1216-
boolean fromCache: boolean ref,
1217-
int length: int ref
1218-
)

0 commit comments

Comments
 (0)