@@ -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 ,
@@ -127,14 +127,10 @@ pub fn populate_parent_folders(
127
127
}
128
128
129
129
/** Get the label for the given location, defining it a global ID if it doesn't exist yet. */
130
- fn global_location (
131
- writer : & mut trap:: Writer ,
132
- file_label : trap:: Label ,
133
- location : trap:: Location ,
134
- ) -> trap:: Label {
130
+ fn global_location ( writer : & mut trap:: Writer , location : trap:: Location ) -> trap:: Label {
135
131
let ( loc_label, fresh) = writer. global_id ( & format ! (
136
132
"loc,{{{}}},{},{},{},{}" ,
137
- file_label,
133
+ location . file_label,
138
134
location. start_line,
139
135
location. start_column,
140
136
location. end_line,
@@ -145,7 +141,7 @@ fn global_location(
145
141
"locations_default" ,
146
142
vec ! [
147
143
trap:: Arg :: Label ( loc_label) ,
148
- trap:: Arg :: Label ( file_label) ,
144
+ trap:: Arg :: Label ( location . file_label) ,
149
145
trap:: Arg :: Int ( location. start_line) ,
150
146
trap:: Arg :: Int ( location. start_column) ,
151
147
trap:: Arg :: Int ( location. end_line) ,
@@ -158,18 +154,14 @@ fn global_location(
158
154
159
155
/** Get the label for the given location, creating it as a fresh ID if we haven't seen the location
160
156
* yet for this file. */
161
- fn location_label (
162
- writer : & mut trap:: Writer ,
163
- file_label : trap:: Label ,
164
- location : trap:: Location ,
165
- ) -> trap:: Label {
157
+ fn location_label ( writer : & mut trap:: Writer , location : trap:: Location ) -> trap:: Label {
166
158
let ( loc_label, fresh) = writer. location_label ( location) ;
167
159
if fresh {
168
160
writer. add_tuple (
169
161
"locations_default" ,
170
162
vec ! [
171
163
trap:: Arg :: Label ( loc_label) ,
172
- trap:: Arg :: Label ( file_label) ,
164
+ trap:: Arg :: Label ( location . file_label) ,
173
165
trap:: Arg :: Int ( location. start_line) ,
174
166
trap:: Arg :: Int ( location. start_column) ,
175
167
trap:: Arg :: Int ( location. end_line) ,
@@ -312,8 +304,8 @@ impl<'a> Visitor<'a> {
312
304
node : Node ,
313
305
status_page : bool ,
314
306
) {
315
- let loc = location_for ( self , node) ;
316
- let loc_label = location_label ( self . trap_writer , self . file_label , loc) ;
307
+ let loc = location_for ( self , self . file_label , node) ;
308
+ let loc_label = location_label ( self . trap_writer , loc) ;
317
309
let mut mesg = self . diagnostics_writer . new_entry (
318
310
"parse-error" ,
319
311
"Could not process some files due to syntax errors" ,
@@ -364,8 +356,8 @@ impl<'a> Visitor<'a> {
364
356
return ;
365
357
}
366
358
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) ;
359
+ let loc = location_for ( self , self . file_label , node) ;
360
+ let loc_label = location_label ( self . trap_writer , loc) ;
369
361
let table = self
370
362
. schema
371
363
. get ( & TypeName {
@@ -627,7 +619,7 @@ fn sliced_source_arg(source: &[u8], n: Node) -> trap::Arg {
627
619
// Emit a pair of `TrapEntry`s for the provided node, appropriately calibrated.
628
620
// The first is the location and label definition, and the second is the
629
621
// 'Located' entry.
630
- fn location_for ( visitor : & mut Visitor , n : Node ) -> trap:: Location {
622
+ fn location_for ( visitor : & mut Visitor , file_label : trap :: Label , n : Node ) -> trap:: Location {
631
623
// Tree-sitter row, column values are 0-based while CodeQL starts
632
624
// counting at 1. In addition Tree-sitter's row and column for the
633
625
// end position are exclusive while CodeQL's end positions are inclusive.
@@ -685,6 +677,7 @@ fn location_for(visitor: &mut Visitor, n: Node) -> trap::Location {
685
677
}
686
678
}
687
679
trap:: Location {
680
+ file_label,
688
681
start_line,
689
682
start_column,
690
683
end_line,
0 commit comments