From c6d0cc264bea70e1d651392b529cf969c572574e Mon Sep 17 00:00:00 2001 From: Gerald Burke Date: Fri, 8 Dec 2023 09:35:23 -0600 Subject: [PATCH] update CsvParser to include line and column in location output to match behavior of version 2.16.0 --- Sources/PeripheryKit/Formatters/CsvFormatter.swift | 2 +- Sources/PeripheryKit/Formatters/JsonFormatter.swift | 13 ++----------- .../PeripheryKit/Formatters/OutputFormatter.swift | 9 +++++++++ 3 files changed, 12 insertions(+), 12 deletions(-) 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 {