mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[SwiftSyntax] Publicize DiagnosticEngine.addConsumer and add hasErrors property (#14996)
* [SwiftSyntax] Publicize DiagnosticEngine.addConsumer and add hasErrors property * [Syntax] Make DiagnosticEngine.hasErrors public
This commit is contained in:
@@ -27,7 +27,7 @@ public class DiagnosticEngine {
|
||||
public private(set) var diagnostics = [Diagnostic]()
|
||||
|
||||
/// Adds the provided consumer to the consumers list.
|
||||
func addConsumer(_ consumer: DiagnosticConsumer) {
|
||||
public func addConsumer(_ consumer: DiagnosticConsumer) {
|
||||
consumers.append(consumer)
|
||||
|
||||
// Start the consumer with all previous diagnostics.
|
||||
@@ -44,7 +44,7 @@ public class DiagnosticEngine {
|
||||
public func diagnose(_ message: Diagnostic.Message,
|
||||
location: SourceLocation? = nil,
|
||||
actions: ((inout Diagnostic.Builder) -> Void)? = nil) {
|
||||
let diagnostic = Diagnostic(message: message, location: location,
|
||||
let diagnostic = Diagnostic(message: message, location: location,
|
||||
actions: actions)
|
||||
diagnostics.append(diagnostic)
|
||||
for consumer in consumers {
|
||||
@@ -52,6 +52,11 @@ public class DiagnosticEngine {
|
||||
}
|
||||
}
|
||||
|
||||
/// If any of the diagnostics in this engine have the `error` severity.
|
||||
public var hasErrors: Bool {
|
||||
return diagnostics.contains(where: { $0.message.severity == .error })
|
||||
}
|
||||
|
||||
/// Tells each consumer to finalize their diagnostic output.
|
||||
deinit {
|
||||
for consumer in consumers {
|
||||
|
||||
Reference in New Issue
Block a user