File tree 1 file changed +7
-12
lines changed
Source/SwiftLintCore/Models
1 file changed +7
-12
lines changed Original file line number Diff line number Diff line change @@ -79,11 +79,9 @@ public enum Issue: LocalizedError, Equatable {
79
79
case baselineNotReadable( path: String )
80
80
81
81
/// Flag to enable warnings for deprecations being printed to the console. Printing is enabled by default.
82
- #if compiler(>=6.0)
83
82
package nonisolated ( unsafe) static var printDeprecationWarnings = true
84
- #else
85
- package static var printDeprecationWarnings = true
86
- #endif
83
+
84
+ @TaskLocal private static var messageConsumer : ( @Sendable ( String ) -> Void ) ?
87
85
88
86
/// Hook used to capture all messages normally printed to stdout and return them back to the caller.
89
87
///
@@ -97,20 +95,17 @@ public enum Issue: LocalizedError, Equatable {
97
95
actor Console {
98
96
static var content = " "
99
97
}
100
- messageConsumer = {
101
- Console . content += ( Console . content. isEmpty ? " " : " \n " ) + $0
102
- }
103
98
defer {
104
- messageConsumer = nil
105
99
Console . content = " "
106
100
}
107
- try runner ( )
101
+ try $messageConsumer. withValue (
102
+ { Console . content += ( Console . content. isEmpty ? " " : " \n " ) + $0 } ,
103
+ operation: runner
104
+ )
108
105
await Task . yield ( )
109
106
return Console . content
110
107
}
111
108
112
- @MainActor private static var messageConsumer : ( @Sendable ( String ) -> Void ) ?
113
-
114
109
/// Wraps any `Error` into a `SwiftLintError.genericWarning` if it is not already a `SwiftLintError`.
115
110
///
116
111
/// - parameter error: Any `Error`.
@@ -142,7 +137,7 @@ public enum Issue: LocalizedError, Equatable {
142
137
if case . ruleDeprecated = self , !Self. printDeprecationWarnings {
143
138
return
144
139
}
145
- Task { @MainActor in
140
+ Task ( priority : . high ) { @MainActor in
146
141
if let consumer = Self . messageConsumer {
147
142
consumer ( errorDescription)
148
143
} else {
You can’t perform that action at this time.
0 commit comments