1010//
1111//===----------------------------------------------------------------------===//
1212
13+ import SwiftDiagnostics
1314import SwiftSyntax
1415import SwiftSyntaxBuilder
1516import SwiftSyntaxMacros
16- import SwiftDiagnostics
1717
1818/// Emits two diagnostics, the first of which is a warning and has two fix-its, and
1919/// the second is a note and has no fix-its.
@@ -23,28 +23,38 @@ public enum DiagnosticsAndFixitsEmitterMacro: MemberMacro {
2323 providingMembersOf declaration: some DeclGroupSyntax ,
2424 in context: some MacroExpansionContext
2525 ) throws -> [ DeclSyntax ] {
26- let firstFixIt = FixIt ( message: SimpleDiagnosticMessage ( message: " This is the first fix-it. " ,
27- diagnosticID: MessageID ( domain: " domain " , id: " fixit1 " ) ,
28- severity: . error) ,
29- changes: [
30- . replace( oldNode: Syntax ( node) , newNode: Syntax ( node) ) // no-op
31- ] )
32- let secondFixIt = FixIt ( message: SimpleDiagnosticMessage ( message: " This is the second fix-it. " ,
33- diagnosticID: MessageID ( domain: " domain " , id: " fixit2 " ) ,
34- severity: . error) ,
35- changes: [
36- . replace( oldNode: Syntax ( node) , newNode: Syntax ( node) ) // no-op
37- ] )
26+ let firstFixIt = FixIt (
27+ message: SimpleDiagnosticMessage (
28+ message: " This is the first fix-it. " ,
29+ diagnosticID: MessageID ( domain: " domain " , id: " fixit1 " ) ,
30+ severity: . error) ,
31+ changes: [
32+ . replace( oldNode: Syntax ( node) , newNode: Syntax ( node) ) // no-op
33+ ] )
34+ let secondFixIt = FixIt (
35+ message: SimpleDiagnosticMessage (
36+ message: " This is the second fix-it. " ,
37+ diagnosticID: MessageID ( domain: " domain " , id: " fixit2 " ) ,
38+ severity: . error) ,
39+ changes: [
40+ . replace( oldNode: Syntax ( node) , newNode: Syntax ( node) ) // no-op
41+ ] )
3842
39- context. diagnose ( Diagnostic ( node: node. attributeName,
40- message: SimpleDiagnosticMessage ( message: " This is the first diagnostic. " ,
41- diagnosticID: MessageID ( domain: " domain " , id: " diagnostic2 " ) ,
42- severity: . warning) ,
43- fixIts: [ firstFixIt, secondFixIt] ) )
44- context. diagnose ( Diagnostic ( node: node. attributeName,
45- message: SimpleDiagnosticMessage ( message: " This is the second diagnostic, it's a note. " ,
46- diagnosticID: MessageID ( domain: " domain " , id: " diagnostic2 " ) ,
47- severity: . note) ) )
43+ context. diagnose (
44+ Diagnostic (
45+ node: node. attributeName,
46+ message: SimpleDiagnosticMessage (
47+ message: " This is the first diagnostic. " ,
48+ diagnosticID: MessageID ( domain: " domain " , id: " diagnostic2 " ) ,
49+ severity: . warning) ,
50+ fixIts: [ firstFixIt, secondFixIt] ) )
51+ context. diagnose (
52+ Diagnostic (
53+ node: node. attributeName,
54+ message: SimpleDiagnosticMessage (
55+ message: " This is the second diagnostic, it's a note. " ,
56+ diagnosticID: MessageID ( domain: " domain " , id: " diagnostic2 " ) ,
57+ severity: . note) ) )
4858
4959 return [ ]
5060 }
0 commit comments