Skip to content

Commit

Permalink
Updates JsonFormatter to include line and column at end of location. C…
Browse files Browse the repository at this point in the history
…loses #680
  • Loading branch information
geraldWilliam committed Dec 8, 2023
1 parent d24a727 commit 326f750
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Sources/PeripheryKit/Formatters/JsonFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class JsonFormatter: OutputFormatter {
"accessibility": result.declaration.accessibility.value.rawValue,
"ids": Array(result.declaration.usrs),
"hints": [describe(result.annotation)],
"location": outputPath(result.declaration.location).string
"location": locationOutput(result.declaration.location)
]
jsonObject.append(object)

Expand All @@ -38,7 +38,7 @@ final class JsonFormatter: OutputFormatter {
"accessibility": "",
"ids": [ref.usr],
"hints": [redundantConformanceHint],
"location": outputPath(ref.location).string
"location": locationOutput(ref.location)
]
jsonObject.append(object)
}
Expand All @@ -51,4 +51,13 @@ final class JsonFormatter: OutputFormatter {
let json = String(data: data, encoding: .utf8)
return json ?? ""
}

private func locationOutput(_ location: SourceLocation) -> String {
[
outputPath(location).string,
String(location.line),
String(location.column)
]
.joined(separator: ":")
}
}

0 comments on commit 326f750

Please sign in to comment.