Skip to content

Commit 0214352

Browse files
authored
Merge pull request #4341 from joefarebrother/location-tostring
Java: Include column numbers in Location.toString
2 parents 7e6fa7b + 8e82687 commit 0214352

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,18 @@ class Location extends @location {
150150

151151
/** Gets a string representation containing the file and range for this location. */
152152
string toString() {
153-
exists(File f, int startLine, int endLine |
154-
locations_default(this, f, startLine, _, endLine, _)
153+
exists(File f, int startLine, int startCol, int endLine, int endCol |
154+
locations_default(this, f, startLine, startCol, endLine, endCol)
155155
|
156156
if endLine = startLine
157-
then result = f.toString() + ":" + startLine.toString()
158-
else result = f.toString() + ":" + startLine.toString() + "-" + endLine.toString()
157+
then
158+
result =
159+
f.toString() + ":" + startLine.toString() + "[" + startCol.toString() + "-" +
160+
endCol.toString() + "]"
161+
else
162+
result =
163+
f.toString() + ":" + startLine.toString() + "[" + startCol.toString() + "]-" +
164+
endLine.toString() + "[" + endCol.toString() + "]"
159165
)
160166
}
161167

0 commit comments

Comments
 (0)