Skip to content

Commit cfb273a

Browse files
authored
Merge pull request github#12799 from erik-krogh/oneColumn
JS: use 1-based column locations for diagnostics
2 parents f4b79ea + d3cc1d6 commit cfb273a

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,9 +1245,9 @@ private void doExtract(FileExtractor extractor, Path file, ExtractorState state)
12451245
}
12461246
DiagnosticLocation diagLoc = builder
12471247
.setStartLine(err.getPosition().getLine())
1248-
.setStartColumn(err.getPosition().getColumn())
1248+
.setStartColumn(err.getPosition().getColumn() + 1) // convert from 0-based to 1-based
12491249
.setEndLine(err.getPosition().getLine())
1250-
.setEndColumn(err.getPosition().getColumn())
1250+
.setEndColumn(err.getPosition().getColumn() + 1) // convert from 0-based to 1-based
12511251
.build();
12521252
writeDiagnostics(msg, JSDiagnosticKind.PARSE_ERROR, diagLoc);
12531253
}

javascript/ql/integration-tests/all-platforms/diagnostics/syntax-error/diagnostics.expected

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"location": {
3-
"endColumn": 4,
3+
"endColumn": 5,
44
"endLine": 1,
55
"file": "bad.js",
6-
"startColumn": 4,
6+
"startColumn": 5,
77
"startLine": 1
88
},
99
"markdownMessage": "A parse error occurred: `Unexpected token`. Check the syntax of the file. If the file is invalid, correct the error or [exclude](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/customizing-code-scanning) the file from analysis.",

0 commit comments

Comments
 (0)