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