@@ -76,8 +76,8 @@ pub fn populate_empty_location(writer: &mut trap::Writer) {
76
76
let file_label = populate_empty_file ( writer) ;
77
77
let loc_label = global_location (
78
78
writer,
79
- file_label,
80
79
trap:: Location {
80
+ file_label,
81
81
start_line : 0 ,
82
82
start_column : 0 ,
83
83
end_line : 0 ,
@@ -129,12 +129,11 @@ pub fn populate_parent_folders(
129
129
/** Get the label for the given location, defining it a global ID if it doesn't exist yet. */
130
130
fn global_location (
131
131
writer : & mut trap:: Writer ,
132
- file_label : trap:: Label ,
133
132
location : trap:: Location ,
134
133
) -> trap:: Label {
135
134
let ( loc_label, fresh) = writer. global_id ( & format ! (
136
135
"loc,{{{}}},{},{},{},{}" ,
137
- file_label,
136
+ location . file_label,
138
137
location. start_line,
139
138
location. start_column,
140
139
location. end_line,
@@ -145,7 +144,7 @@ fn global_location(
145
144
"locations_default" ,
146
145
vec ! [
147
146
trap:: Arg :: Label ( loc_label) ,
148
- trap:: Arg :: Label ( file_label) ,
147
+ trap:: Arg :: Label ( location . file_label) ,
149
148
trap:: Arg :: Int ( location. start_line) ,
150
149
trap:: Arg :: Int ( location. start_column) ,
151
150
trap:: Arg :: Int ( location. end_line) ,
@@ -160,7 +159,6 @@ fn global_location(
160
159
* yet for this file. */
161
160
fn location_label (
162
161
writer : & mut trap:: Writer ,
163
- file_label : trap:: Label ,
164
162
location : trap:: Location ,
165
163
) -> trap:: Label {
166
164
let ( loc_label, fresh) = writer. location_label ( location) ;
@@ -169,7 +167,7 @@ fn location_label(
169
167
"locations_default" ,
170
168
vec ! [
171
169
trap:: Arg :: Label ( loc_label) ,
172
- trap:: Arg :: Label ( file_label) ,
170
+ trap:: Arg :: Label ( location . file_label) ,
173
171
trap:: Arg :: Int ( location. start_line) ,
174
172
trap:: Arg :: Int ( location. start_column) ,
175
173
trap:: Arg :: Int ( location. end_line) ,
@@ -312,8 +310,8 @@ impl<'a> Visitor<'a> {
312
310
node : Node ,
313
311
status_page : bool ,
314
312
) {
315
- let loc = location_for ( self , node) ;
316
- let loc_label = location_label ( self . trap_writer , self . file_label , loc) ;
313
+ let loc = location_for ( self , self . file_label , node) ;
314
+ let loc_label = location_label ( self . trap_writer , loc) ;
317
315
let mut mesg = self . diagnostics_writer . new_entry (
318
316
"parse-error" ,
319
317
"Could not process some files due to syntax errors" ,
@@ -364,8 +362,8 @@ impl<'a> Visitor<'a> {
364
362
return ;
365
363
}
366
364
let ( id, _, child_nodes) = self . stack . pop ( ) . expect ( "Vistor: empty stack" ) ;
367
- let loc = location_for ( self , node) ;
368
- let loc_label = location_label ( self . trap_writer , self . file_label , loc) ;
365
+ let loc = location_for ( self , self . file_label , node) ;
366
+ let loc_label = location_label ( self . trap_writer , loc) ;
369
367
let table = self
370
368
. schema
371
369
. get ( & TypeName {
@@ -627,7 +625,7 @@ fn sliced_source_arg(source: &[u8], n: Node) -> trap::Arg {
627
625
// Emit a pair of `TrapEntry`s for the provided node, appropriately calibrated.
628
626
// The first is the location and label definition, and the second is the
629
627
// 'Located' entry.
630
- fn location_for ( visitor : & mut Visitor , n : Node ) -> trap:: Location {
628
+ fn location_for ( visitor : & mut Visitor , file_label : trap :: Label , n : Node ) -> trap:: Location {
631
629
// Tree-sitter row, column values are 0-based while CodeQL starts
632
630
// counting at 1. In addition Tree-sitter's row and column for the
633
631
// end position are exclusive while CodeQL's end positions are inclusive.
@@ -685,6 +683,7 @@ fn location_for(visitor: &mut Visitor, n: Node) -> trap::Location {
685
683
}
686
684
}
687
685
trap:: Location {
686
+ file_label,
688
687
start_line,
689
688
start_column,
690
689
end_line,
0 commit comments