mirror of
https://github.com/github/codeql.git
synced 2026-04-30 03:05:15 +02:00
JavaScript: Store JSON locations in json_locations table instead of hasLocation.
This commit is contained in:
@@ -43,6 +43,7 @@ public class JSONExtractor implements IExtractor {
|
||||
throw recoverableErrors.get(0).asUserError();
|
||||
|
||||
Label fileLabel = locationManager.getFileLabel();
|
||||
locationManager.setHasLocationTable("json_locations");
|
||||
v.accept(
|
||||
new Visitor<Context, Label>() {
|
||||
private Label emit(JSONValue nd, int kind, Context c) {
|
||||
|
||||
@@ -37,7 +37,7 @@ public class Main {
|
||||
* A version identifier that should be updated every time the extractor changes in such a way that
|
||||
* it may produce different tuples for the same file under the same {@link ExtractorConfig}.
|
||||
*/
|
||||
public static final String EXTRACTOR_VERSION = "2019-04-17";
|
||||
public static final String EXTRACTOR_VERSION = "2019-07-24";
|
||||
|
||||
public static final Pattern NEWLINE = Pattern.compile("\n");
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import javascript
|
||||
* A JSON-encoded value, which may be a primitive value, an array or an object.
|
||||
*/
|
||||
class JSONValue extends @json_value, Locatable {
|
||||
override Location getLocation() { hasLocation(this, result) }
|
||||
override Location getLocation() { json_locations(this, result) }
|
||||
|
||||
/** Gets the parent value to which this value belongs, if any. */
|
||||
JSONValue getParent() { json(this, _, result, _, _) }
|
||||
@@ -79,5 +79,7 @@ class JSONObject extends @json_object, JSONValue {
|
||||
* An error reported by the JSON parser.
|
||||
*/
|
||||
class JSONParseError extends @json_parse_error, Error {
|
||||
override Location getLocation() { json_locations(this, result) }
|
||||
|
||||
override string getMessage() { json_errors(this, result) }
|
||||
}
|
||||
|
||||
@@ -905,6 +905,9 @@ json_properties (int obj: @json_object ref,
|
||||
json_errors (unique int id: @json_parse_error,
|
||||
varchar(900) message: string ref);
|
||||
|
||||
json_locations(unique int locatable: @json_locatable ref,
|
||||
int location: @location_default ref);
|
||||
|
||||
case @json_value.kind of
|
||||
0 = @json_null
|
||||
| 1 = @json_boolean
|
||||
@@ -915,6 +918,8 @@ case @json_value.kind of
|
||||
|
||||
@json_parent = @json_object | @json_array | @file;
|
||||
|
||||
@json_locatable = @json_value | @json_parse_error;
|
||||
|
||||
// locations
|
||||
@ast_node = @toplevel | @stmt | @expr | @property | @typeexpr;
|
||||
|
||||
@@ -922,9 +927,9 @@ case @json_value.kind of
|
||||
| @ast_node
|
||||
| @comment
|
||||
| @line
|
||||
| @js_parse_error | @regexp_parse_error | @json_parse_error
|
||||
| @js_parse_error | @regexp_parse_error
|
||||
| @regexpterm
|
||||
| @json_value
|
||||
| @json_locatable
|
||||
| @token
|
||||
| @cfg_node
|
||||
| @jsdoc | @jsdoc_type_expr | @jsdoc_tag
|
||||
|
||||
Reference in New Issue
Block a user