Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include Line and Column in Location for JSON and CSV Outputs - Issue 680 #681

Merged
merged 2 commits into from
Dec 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 ?? "")"
}
}
4 changes: 2 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": locationDescription(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": locationDescription(ref.location)
]
jsonObject.append(object)
}
Expand Down
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
Loading