File tree 2 files changed +26
-1
lines changed
Tests/SwiftDiagnosticsTest 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -207,7 +207,7 @@ extension GroupedDiagnostics {
207
207
208
208
// Display file/line/column and diagnostic text for the primary diagnostic.
209
209
prefixString =
210
- " \( location. file ) : \( location. line ) : \( location. column) : \( diagnosticDecorator. decorateDiagnosticMessage ( primaryDiag. diagMessage) ) \n "
210
+ " \( location. presumedFile ) : \( location. presumedLine ) : \( location. column) : \( diagnosticDecorator. decorateDiagnosticMessage ( primaryDiag. diagMessage) ) \n "
211
211
212
212
// If the primary diagnostic source file is not the same as the root source file, we're pointing into a generated buffer.
213
213
// Provide a link back to the original source file where this generated buffer occurred, so it's easy to find if
Original file line number Diff line number Diff line change @@ -60,6 +60,31 @@ extension GroupedDiagnostics {
60
60
}
61
61
62
62
final class GroupedDiagnosticsFormatterTests : XCTestCase {
63
+ func testSourceLocations( ) {
64
+ var group = GroupedDiagnostics ( )
65
+
66
+ // Main source file.
67
+ _ = group. addTestFile (
68
+ """
69
+ #sourceLocation(file: " other.swift " , line: 123)
70
+ let pi = 3.14159 x
71
+ """ ,
72
+ displayName: " main.swift " ,
73
+ diagnosticDescriptors: [ ]
74
+ )
75
+ let annotated = DiagnosticsFormatter . annotateSources ( in: group)
76
+ assertStringsEqualWithDiff (
77
+ annotated,
78
+ """
79
+ other.swift:123:17: error: consecutive statements on a line must be separated by newline or ';'
80
+ 1 │ #sourceLocation(file: " other.swift " , line: 123)
81
+ 2 │ let pi = 3.14159 x
82
+ │ ╰─ error: consecutive statements on a line must be separated by newline or ';'
83
+
84
+ """
85
+ )
86
+ }
87
+
63
88
func testGroupingForMacroExpansion( ) {
64
89
var group = GroupedDiagnostics ( )
65
90
You can’t perform that action at this time.
0 commit comments