diff --git a/Sources/PeripheryKit/Formatters/CsvFormatter.swift b/Sources/PeripheryKit/Formatters/CsvFormatter.swift index df7f72c60..4bcb55193 100644 --- a/Sources/PeripheryKit/Formatters/CsvFormatter.swift +++ b/Sources/PeripheryKit/Formatters/CsvFormatter.swift @@ -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 ?? "")" } } diff --git a/Sources/PeripheryKit/Formatters/JsonFormatter.swift b/Sources/PeripheryKit/Formatters/JsonFormatter.swift index 417c04d34..ccfabc932 100644 --- a/Sources/PeripheryKit/Formatters/JsonFormatter.swift +++ b/Sources/PeripheryKit/Formatters/JsonFormatter.swift @@ -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) @@ -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) } @@ -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: ":") - } } diff --git a/Sources/PeripheryKit/Formatters/OutputFormatter.swift b/Sources/PeripheryKit/Formatters/OutputFormatter.swift index d29f28f2d..c801972a9 100644 --- a/Sources/PeripheryKit/Formatters/OutputFormatter.swift +++ b/Sources/PeripheryKit/Formatters/OutputFormatter.swift @@ -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 {