File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
Tests/SwiftDiagnosticsTest Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -207,7 +207,7 @@ extension GroupedDiagnostics {
207207
208208 // Display file/line/column and diagnostic text for the primary diagnostic.
209209 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 "
211211
212212 // If the primary diagnostic source file is not the same as the root source file, we're pointing into a generated buffer.
213213 // 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 {
6060}
6161
6262final 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+
6388 func testGroupingForMacroExpansion( ) {
6489 var group = GroupedDiagnostics ( )
6590
You can’t perform that action at this time.
0 commit comments