diff --git a/config/dbscheme-fragments.json b/config/dbscheme-fragments.json index 2a56ed57bae..c56289ff171 100644 --- a/config/dbscheme-fragments.json +++ b/config/dbscheme-fragments.json @@ -28,6 +28,7 @@ "/*- Yaml dbscheme -*/", "/*- Blame dbscheme -*/", "/*- JSON dbscheme -*/", - "/*- Python dbscheme -*/" + "/*- Python dbscheme -*/", + "/*- Empty location -*/" ] } \ No newline at end of file diff --git a/ql/ql/src/ql.dbscheme b/ql/ql/src/ql.dbscheme index e36eec681ed..6b7646b90f9 100644 --- a/ql/ql/src/ql.dbscheme +++ b/ql/ql/src/ql.dbscheme @@ -36,6 +36,12 @@ containerparent( unique int child: @container ref ); +/*- Empty location -*/ + +empty_location( + int location: @location_default ref +); + /*- Source location prefix -*/ /** diff --git a/ruby/ql/lib/codeql/Locations.qll b/ruby/ql/lib/codeql/Locations.qll index 87198146d88..148c6b01f2d 100644 --- a/ruby/ql/lib/codeql/Locations.qll +++ b/ruby/ql/lib/codeql/Locations.qll @@ -64,5 +64,5 @@ class Location extends @location_default { /** An entity representing an empty location. */ class EmptyLocation extends Location { - EmptyLocation() { this.hasLocationInfo("", 0, 0, 0, 0) } + EmptyLocation() { empty_location(this) } } diff --git a/ruby/ql/lib/ruby.dbscheme b/ruby/ql/lib/ruby.dbscheme index 440de75c71e..63af05c01bd 100644 --- a/ruby/ql/lib/ruby.dbscheme +++ b/ruby/ql/lib/ruby.dbscheme @@ -36,6 +36,12 @@ containerparent( unique int child: @container ref ); +/*- Empty location -*/ + +empty_location( + int location: @location_default ref +); + /*- Source location prefix -*/ /** diff --git a/shared/tree-sitter-extractor/src/extractor/mod.rs b/shared/tree-sitter-extractor/src/extractor/mod.rs index 7afe5d3a0c0..1c7d3c96ddd 100644 --- a/shared/tree-sitter-extractor/src/extractor/mod.rs +++ b/shared/tree-sitter-extractor/src/extractor/mod.rs @@ -75,7 +75,7 @@ fn populate_empty_file(writer: &mut trap::Writer) -> trap::Label { pub fn populate_empty_location(writer: &mut trap::Writer) { let file_label = populate_empty_file(writer); - global_location( + let loc_label = global_location( writer, file_label, trap::Location { @@ -85,6 +85,7 @@ pub fn populate_empty_location(writer: &mut trap::Writer) { end_column: 0, }, ); + writer.add_tuple("empty_location", vec![trap::Arg::Label(loc_label)]); } pub fn populate_parent_folders( diff --git a/shared/tree-sitter-extractor/src/generator/prefix.dbscheme b/shared/tree-sitter-extractor/src/generator/prefix.dbscheme index fbfee072524..96c7feaaf19 100644 --- a/shared/tree-sitter-extractor/src/generator/prefix.dbscheme +++ b/shared/tree-sitter-extractor/src/generator/prefix.dbscheme @@ -33,6 +33,12 @@ containerparent( unique int child: @container ref ); +/*- Empty location -*/ + +empty_location( + int location: @location_default ref +); + /*- Source location prefix -*/ /**