Skip to content

Commit

Permalink
Tree-sitter: Emit empty_location relation to avoid scan
Browse files Browse the repository at this point in the history
  • Loading branch information
hvitved committed May 27, 2024
1 parent e1a959c commit 82bbef2
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ql/ql/src/ql.dbscheme
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ locations_default(
int endColumn: int ref
);

empty_location(
int location: @location_default ref
);

files(
unique int id: @file,
string name: string ref
Expand Down
2 changes: 1 addition & 1 deletion ruby/ql/lib/codeql/Locations.qll
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}
4 changes: 4 additions & 0 deletions ruby/ql/lib/ruby.dbscheme
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ locations_default(
int endColumn: int ref
);

empty_location(
int location: @location_default ref
);

files(
unique int id: @file,
string name: string ref
Expand Down
3 changes: 2 additions & 1 deletion shared/tree-sitter-extractor/src/extractor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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(
Expand Down
4 changes: 4 additions & 0 deletions shared/tree-sitter-extractor/src/generator/prefix.dbscheme
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ locations_default(
int endColumn: int ref
);

empty_location(
int location: @location_default ref
);

files(
unique int id: @file,
string name: string ref
Expand Down

0 comments on commit 82bbef2

Please sign in to comment.