Skip to content

Commit 0e6e974

Browse files
authored
Merge pull request #2330 from stephencelis/patch-3
Add MacroExpansionNoteMessage
2 parents a1ecf4a + e8190f9 commit 0e6e974

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Sources/SwiftSyntaxMacros/MacroExpansionDiagnosticMessages.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,20 @@ public struct MacroExpansionFixItMessage: FixItMessage {
6868
self.message = message
6969
}
7070
}
71+
72+
/// The message of a note that is specified by a string literal
73+
///
74+
/// This type allows macro authors to quickly generate note messages based on
75+
/// a string. For any non-trivial note messages, it is encouraged to define a
76+
/// custom type that conforms to `NoteMessage`.
77+
public struct MacroExpansionNoteMessage: NoteMessage {
78+
public var message: String
79+
80+
public var noteID: SwiftDiagnostics.MessageID {
81+
.init(domain: diagnosticDomain, id: "\(Self.self)")
82+
}
83+
84+
public init(_ message: String) {
85+
self.message = message
86+
}
87+
}

0 commit comments

Comments
 (0)