Skip to content

Commit 3404bcf

Browse files
authored
Merge pull request github#6680 from github/igfoo/java_location
Java: Use the standard URL format for Location.toString()
2 parents 68ed325 + 4fbb165 commit 3404bcf

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
lgtm,codescanning
2+
* The format of the Location.toString() output has changed to
3+
`file:///path/to/file:startLine:startColumn:endLine:endColumn`.

java/ql/lib/semmle/code/Location.qll

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -168,18 +168,10 @@ class Location extends @location {
168168

169169
/** Gets a string representation containing the file and range for this location. */
170170
string toString() {
171-
exists(File f, int startLine, int startCol, int endLine, int endCol |
172-
locations_default(this, f, startLine, startCol, endLine, endCol)
171+
exists(string filepath, int startLine, int startCol, int endLine, int endCol |
172+
this.hasLocationInfo(filepath, startLine, startCol, endLine, endCol)
173173
|
174-
if endLine = startLine
175-
then
176-
result =
177-
f.toString() + ":" + startLine.toString() + "[" + startCol.toString() + "-" +
178-
endCol.toString() + "]"
179-
else
180-
result =
181-
f.toString() + ":" + startLine.toString() + "[" + startCol.toString() + "]-" +
182-
endLine.toString() + "[" + endCol.toString() + "]"
174+
toUrl(filepath, startLine, startCol, endLine, endCol, result)
183175
)
184176
}
185177

0 commit comments

Comments
 (0)