@@ -43,7 +43,7 @@ private enum Error: Swift.Error {
43
43
}
44
44
45
45
// FIXME: An abstraction for tests to work around missing memberwise initializers in `TSCUtility.SerializedDiagnostics`.
46
- protocol AnySourceLocation : Hashable {
46
+ protocol AnySourceLocation {
47
47
var filename : String { get }
48
48
var line : UInt64 { get }
49
49
var column : UInt64 { get }
@@ -76,11 +76,11 @@ protocol AnyDiagnostic {
76
76
77
77
extension AnyDiagnostic {
78
78
var isPrimary : Bool {
79
- self . level != . note
79
+ ! self . isNote
80
80
}
81
81
82
82
var isNote : Bool {
83
- ! self . isPrimary
83
+ self . level == . note
84
84
}
85
85
86
86
var isIgnored : Bool {
@@ -97,13 +97,7 @@ extension AnyDiagnostic {
97
97
}
98
98
99
99
extension SerializedDiagnostics . Diagnostic : AnyDiagnostic { }
100
- extension SerializedDiagnostics . SourceLocation : AnySourceLocation , @retroactive Hashable {
101
- public func hash( into hasher: inout Hasher ) {
102
- hasher. combine ( self . filename)
103
- hasher. combine ( self . line)
104
- hasher. combine ( self . column)
105
- }
106
- }
100
+ extension SerializedDiagnostics . SourceLocation : AnySourceLocation { }
107
101
108
102
extension SerializedDiagnostics . FixIt : AnyFixIt { }
109
103
@@ -112,16 +106,18 @@ private struct PrimaryDiagnosticFilter<Diagnostic: AnyDiagnostic>: ~Copyable {
112
106
/// A hashable type storing the minimum data necessary to uniquely identify
113
107
/// a diagnostic for our purposes.
114
108
private struct DiagnosticID : Hashable {
115
- private let location : Diagnostic . SourceLocation
116
109
private let message : String
110
+ private let filename : String
111
+ private let utf8Offset : UInt64
117
112
private let level : SerializedDiagnostics . Diagnostic . Level
118
113
119
114
init ( diagnostic: Diagnostic ) {
120
115
self . level = diagnostic. level
121
116
self . message = diagnostic. text
122
117
// Force the location. We should be filtering out diagnostics
123
118
// without a location.
124
- self . location = diagnostic. location!
119
+ self . filename = diagnostic. location!. filename
120
+ self . utf8Offset = diagnostic. location!. offset
125
121
}
126
122
}
127
123
@@ -379,17 +375,10 @@ private struct SourceFile {
379
375
throw Error . failedToResolveSourceLocation
380
376
}
381
377
382
- guard location. offset == 0 else {
383
- return AbsolutePosition ( utf8Offset: Int ( location. offset) )
384
- }
385
-
386
- return self . sourceLocationConverter. position (
387
- ofLine: Int ( location. line) ,
388
- column: Int ( location. column)
389
- )
378
+ return AbsolutePosition ( utf8Offset: Int ( location. offset) )
390
379
}
391
380
392
- func node( at location: some AnySourceLocation ) throws -> Syntax {
381
+ func node( at location: borrowing some AnySourceLocation ) throws -> Syntax {
393
382
let position = try position ( of: location)
394
383
395
384
if let token = syntax. token ( at: position) {
0 commit comments