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