@@ -71,7 +71,7 @@ public enum SyntaxParser {
71
71
source: String ,
72
72
file: String = " " ,
73
73
parseTransition: IncrementalParseTransition ? = nil ,
74
- diagConsumer : DiagnosticConsumer ? = nil
74
+ diagnosticEngine : DiagnosticEngine ? = nil
75
75
) throws -> SourceFileSyntax {
76
76
guard nodeHashVerifyResult else {
77
77
throw ParserError . parserCompatibilityCheckFailed
@@ -82,7 +82,7 @@ public enum SyntaxParser {
82
82
var utf8Source = source
83
83
utf8Source. makeNativeUTF8IfNeeded ( )
84
84
85
- let rawSyntax = parseRaw ( file, utf8Source, parseTransition, diagConsumer )
85
+ let rawSyntax = parseRaw ( file, utf8Source, parseTransition, diagnosticEngine )
86
86
87
87
guard let file = makeSyntax ( . forRoot( rawSyntax) ) as? SourceFileSyntax else {
88
88
throw ParserError . invalidSyntaxData
@@ -98,22 +98,22 @@ public enum SyntaxParser {
98
98
/// if the parse was successful.
99
99
/// - Throws: `ParserError`
100
100
public static func parse( _ url: URL ,
101
- diagConsumer : DiagnosticConsumer ? = nil ) throws -> SourceFileSyntax {
101
+ diagnosticEngine : DiagnosticEngine ? = nil ) throws -> SourceFileSyntax {
102
102
// Avoid using `String(contentsOf:)` because it creates a wrapped NSString.
103
103
var fileData = try Data ( contentsOf: url)
104
104
fileData. append ( 0 ) // null terminate.
105
105
let source = fileData. withUnsafeBytes { ( ptr: UnsafePointer < CChar > ) in
106
106
return String ( cString: ptr)
107
107
}
108
108
return try parse ( source: source, file: url. absoluteString,
109
- diagConsumer : diagConsumer )
109
+ diagnosticEngine : diagnosticEngine )
110
110
}
111
111
112
112
private static func parseRaw(
113
113
_ file: String ,
114
114
_ source: String ,
115
115
_ parseTransition: IncrementalParseTransition ? ,
116
- _ diagConsumer : DiagnosticConsumer ?
116
+ _ diagnosticEngine : DiagnosticEngine ?
117
117
) -> RawSyntax {
118
118
assert ( source. isNativeUTF8)
119
119
let c_parser = swiftparse_parser_create ( )
@@ -148,17 +148,17 @@ public enum SyntaxParser {
148
148
var pendingNotes : [ Note ] = [ ]
149
149
defer {
150
150
// Consume the pending diagnostic if present
151
- if let diagConsumer = diagConsumer {
151
+ if let diagnosticEngine = diagnosticEngine {
152
152
if let pendingDiag = pendingDiag {
153
- diagConsumer . handle ( Diagnostic ( pendingDiag, pendingNotes) )
153
+ diagnosticEngine . diagnose ( Diagnostic ( pendingDiag, pendingNotes) )
154
154
}
155
155
}
156
156
}
157
157
// Set up diagnostics consumer if requested by the caller.
158
- if let diagConsumer = diagConsumer {
158
+ if let diagnosticEngine = diagnosticEngine {
159
159
// If requested, we should set up a source location converter to calculate
160
160
// line and column.
161
- let converter = diagConsumer . calculateLineColumn ?
161
+ let converter = diagnosticEngine . needsLineColumn ?
162
162
SourceLocationConverter ( file: file, source: source) : nil
163
163
let diagHandler = { ( diag: CDiagnostic!) in
164
164
// If the coming diagnostic is a note, we cache the pending note
@@ -168,7 +168,7 @@ public enum SyntaxParser {
168
168
} else {
169
169
// Cosume the pending diagnostic
170
170
if let pendingDiag = pendingDiag {
171
- diagConsumer . handle ( Diagnostic ( pendingDiag, pendingNotes) )
171
+ diagnosticEngine . diagnose ( Diagnostic ( pendingDiag, pendingNotes) )
172
172
// Clear pending notes
173
173
pendingNotes = [ ]
174
174
}
@@ -239,7 +239,7 @@ extension Note {
239
239
extension Diagnostic {
240
240
init ( diag: CDiagnostic , using converter: SourceLocationConverter ? ) {
241
241
// Collect highlighted ranges
242
- let hightlights = ( 0 ..< swiftparse_diagnostic_get_range_count ( diag) ) . map {
242
+ let highlights = ( 0 ..< swiftparse_diagnostic_get_range_count ( diag) ) . map {
243
243
return SourceRange ( swiftparse_diagnostic_get_range ( diag, $0) , converter)
244
244
}
245
245
// Collect fixits
@@ -249,7 +249,7 @@ extension Diagnostic {
249
249
self . init ( message: Diagnostic . Message ( diag) ,
250
250
location: SourceLocation ( offset: Int ( swiftparse_diagnostic_get_source_loc ( diag) ) ,
251
251
converter: converter) ,
252
- notes: [ ] , highlights: hightlights , fixIts: fixits)
252
+ notes: [ ] , highlights: highlights , fixIts: fixits)
253
253
}
254
254
255
255
init ( _ diag: Diagnostic , _ notes: [ Note ] ) {
0 commit comments