Skip to content

Commit

Permalink
update CsvParser to include line and column in location output to mat…
Browse files Browse the repository at this point in the history
…ch behavior of version 2.16.0
  • Loading branch information
geraldWilliam committed Dec 8, 2023
1 parent 326f750 commit c6d0cc2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Sources/PeripheryKit/Formatters/CsvFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ final class CsvFormatter: OutputFormatter {
let joinedModifiers = attributes.joined(separator: "|")
let joinedAttributes = modifiers.joined(separator: "|")
let joinedUsrs = usrs.joined(separator: "|")
let path = outputPath(location)
let path = locationDescription(location)
return "\(kind),\(name ?? ""),\(joinedModifiers),\(joinedAttributes),\(accessibility ?? ""),\(joinedUsrs),\(path),\(hint ?? "")"
}
}
13 changes: 2 additions & 11 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": locationOutput(result.declaration.location)
"location": locationDescription(result.declaration.location)
]
jsonObject.append(object)

Expand All @@ -38,7 +38,7 @@ final class JsonFormatter: OutputFormatter {
"accessibility": "",
"ids": [ref.usr],
"hints": [redundantConformanceHint],
"location": locationOutput(ref.location)
"location": locationDescription(ref.location)
]
jsonObject.append(object)
}
Expand All @@ -51,13 +51,4 @@ 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: ":")
}
}
9 changes: 9 additions & 0 deletions Sources/PeripheryKit/Formatters/OutputFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ extension OutputFormatter {

return path
}

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

public extension OutputFormat {
Expand Down

0 comments on commit c6d0cc2

Please sign in to comment.