Skip to content

Commit 94d2e95

Browse files
committed
Tree-sitter: Emit empty_location relation to avoid scan
1 parent 44f666c commit 94d2e95

File tree

6 files changed

+23
-3
lines changed

6 files changed

+23
-3
lines changed

config/dbscheme-fragments.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"/*- Yaml dbscheme -*/",
2929
"/*- Blame dbscheme -*/",
3030
"/*- JSON dbscheme -*/",
31-
"/*- Python dbscheme -*/"
31+
"/*- Python dbscheme -*/",
32+
"/*- Empty location -*/"
3233
]
3334
}

ql/ql/src/ql.dbscheme

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ containerparent(
3636
unique int child: @container ref
3737
);
3838

39+
/*- Empty location -*/
40+
41+
empty_location(
42+
int location: @location_default ref
43+
);
44+
3945
/*- Source location prefix -*/
4046

4147
/**

ruby/ql/lib/codeql/Locations.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,5 @@ class Location extends @location_default {
6464

6565
/** An entity representing an empty location. */
6666
class EmptyLocation extends Location {
67-
EmptyLocation() { this.hasLocationInfo("", 0, 0, 0, 0) }
67+
EmptyLocation() { empty_location(this) }
6868
}

ruby/ql/lib/ruby.dbscheme

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ containerparent(
3636
unique int child: @container ref
3737
);
3838

39+
/*- Empty location -*/
40+
41+
empty_location(
42+
int location: @location_default ref
43+
);
44+
3945
/*- Source location prefix -*/
4046

4147
/**

shared/tree-sitter-extractor/src/extractor/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ fn populate_empty_file(writer: &mut trap::Writer) -> trap::Label {
7575

7676
pub fn populate_empty_location(writer: &mut trap::Writer) {
7777
let file_label = populate_empty_file(writer);
78-
global_location(
78+
let loc_label = global_location(
7979
writer,
8080
file_label,
8181
trap::Location {
@@ -85,6 +85,7 @@ pub fn populate_empty_location(writer: &mut trap::Writer) {
8585
end_column: 0,
8686
},
8787
);
88+
writer.add_tuple("empty_location", vec![trap::Arg::Label(loc_label)]);
8889
}
8990

9091
pub fn populate_parent_folders(

shared/tree-sitter-extractor/src/generator/prefix.dbscheme

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ containerparent(
3333
unique int child: @container ref
3434
);
3535

36+
/*- Empty location -*/
37+
38+
empty_location(
39+
int location: @location_default ref
40+
);
41+
3642
/*- Source location prefix -*/
3743

3844
/**

0 commit comments

Comments
 (0)