Skip to content

Commit 4c04b8b

Browse files
committed
Add comment
1 parent d2f4255 commit 4c04b8b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

extractor/src/extractor.rs

+8
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,14 @@ fn sliced_source_arg(source: &Vec<u8>, n: Node) -> Arg {
274274

275275
// Emit a 'Located' TrapEntry for the provided node, appropriately calibrated.
276276
fn location_for<'a>(source: &Vec<u8>, fp: &String, label: Label, n: Node) -> TrapEntry {
277+
// Tree-sitter row, column values are 0-based while CodeQL starts
278+
// counting at 1. In addition Tree-sitter's row and column for the
279+
// end position are exclusive while CodeQL's end positions are inclusive.
280+
// This means that all values should be incremented by 1 and in addition the
281+
// end position needs to be shift 1 to the left. In most cases this means
282+
// simply incrementing all values except the end column except in cases where
283+
// the end column is 0 (start of a line). In such cases the end position must be
284+
// set to the end of the previous line.
277285
let start_line = n.start_position().row + 1;
278286
let start_col = n.start_position().column + 1;
279287
let mut end_line = n.end_position().row + 1;

0 commit comments

Comments
 (0)