Skip to content

Commit bdc97f6

Browse files
committed
Modify PrettyPrinter to output diagnostics using shortened relative paths
1 parent f9b10f2 commit bdc97f6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Sources/SwiftFormat/PrettyPrint/PrettyPrint.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,10 +816,13 @@ public class PrettyPrinter {
816816
private func diagnose(_ message: Finding.Message, category: PrettyPrintFindingCategory) {
817817
// Add 1 since columns uses 1-based indices.
818818
let column = outputBuffer.column + 1
819+
let converter = context.sourceLocationConverter
820+
let absolutePosition = converter.position(ofLine: outputBuffer.lineNumber, column: column)
821+
let sourceLocation = converter.location(for: absolutePosition)
819822
context.findingEmitter.emit(
820823
message,
821824
category: category,
822-
location: Finding.Location(file: context.fileURL.path, line: outputBuffer.lineNumber, column: column)
825+
location: Finding.Location(sourceLocation)
823826
)
824827
}
825828
}

0 commit comments

Comments
 (0)