@@ -281,18 +281,43 @@ public struct UnknownDirectiveError: ParserError {
281
281
282
282
// MARK: - Fix-Its (please sort alphabetically)
283
283
284
- public enum StaticParserFixIt : String , FixItMessage {
285
- case insertSemicolon = " insert ';' "
286
- case insertAttributeArguments = " insert attribute argument "
287
- case joinIdentifiers = " join the identifiers together "
288
- case joinIdentifiersWithCamelCase = " join the identifiers together with camel-case "
289
- case removeOperatorBody = " remove operator body "
290
- case wrapKeywordInBackticks = " if this name is unavoidable, use backticks to escape it "
284
+ /// A parser fix-it with a static message.
285
+ public struct StaticParserFixIt : FixItMessage {
286
+ public let message : String
287
+ private let messageID : String
291
288
292
- public var message : String { self . rawValue }
289
+ /// This should only be called within a static var on FixItMessage, such
290
+ /// as the examples below. This allows us to pick up the messageID from the
291
+ /// var name.
292
+ fileprivate init ( _ message: String , messageID: String = #function) {
293
+ self . message = message
294
+ self . messageID = messageID
295
+ }
293
296
294
297
public var fixItID : MessageID {
295
- MessageID ( domain: diagnosticDomain, id: " \( type ( of: self ) ) . \( self ) " )
298
+ MessageID ( domain: diagnosticDomain, id: " \( type ( of: self ) ) . \( messageID) " )
299
+ }
300
+ }
301
+
302
+ extension FixItMessage where Self == StaticParserFixIt {
303
+ /// Please order alphabetically by property name.
304
+ public static var insertSemicolon : Self {
305
+ . init( " insert ';' " )
306
+ }
307
+ public static var insertAttributeArguments : Self {
308
+ . init( " insert attribute argument " )
309
+ }
310
+ public static var joinIdentifiers : Self {
311
+ . init( " join the identifiers together " )
312
+ }
313
+ public static var joinIdentifiersWithCamelCase : Self {
314
+ . init( " join the identifiers together with camel-case " )
315
+ }
316
+ public static var removeOperatorBody : Self {
317
+ . init( " remove operator body " )
318
+ }
319
+ public static var wrapKeywordInBackticks : Self {
320
+ . init( " if this name is unavoidable, use backticks to escape it " )
296
321
}
297
322
}
298
323
0 commit comments