diff --git a/Tests/MacroTestingTests/MacroExamples/DiagnosticsAndFixitsEmitterMacro.swift b/Tests/MacroTestingTests/MacroExamples/DiagnosticsAndFixitsEmitterMacro.swift index 6bf47f7..753f803 100644 --- a/Tests/MacroTestingTests/MacroExamples/DiagnosticsAndFixitsEmitterMacro.swift +++ b/Tests/MacroTestingTests/MacroExamples/DiagnosticsAndFixitsEmitterMacro.swift @@ -10,10 +10,10 @@ // //===----------------------------------------------------------------------===// +import SwiftDiagnostics import SwiftSyntax import SwiftSyntaxBuilder import SwiftSyntaxMacros -import SwiftDiagnostics /// Emits two diagnostics, the first of which is a warning and has two fix-its, and /// the second is a note and has no fix-its. @@ -23,28 +23,38 @@ public enum DiagnosticsAndFixitsEmitterMacro: MemberMacro { providingMembersOf declaration: some DeclGroupSyntax, in context: some MacroExpansionContext ) throws -> [DeclSyntax] { - let firstFixIt = FixIt(message: SimpleDiagnosticMessage(message: "This is the first fix-it.", - diagnosticID: MessageID(domain: "domain", id: "fixit1"), - severity: .error), - changes: [ - .replace(oldNode: Syntax(node), newNode: Syntax(node)) // no-op - ]) - let secondFixIt = FixIt(message: SimpleDiagnosticMessage(message: "This is the second fix-it.", - diagnosticID: MessageID(domain: "domain", id: "fixit2"), - severity: .error), - changes: [ - .replace(oldNode: Syntax(node), newNode: Syntax(node)) // no-op - ]) + let firstFixIt = FixIt( + message: SimpleDiagnosticMessage( + message: "This is the first fix-it.", + diagnosticID: MessageID(domain: "domain", id: "fixit1"), + severity: .error), + changes: [ + .replace(oldNode: Syntax(node), newNode: Syntax(node)) // no-op + ]) + let secondFixIt = FixIt( + message: SimpleDiagnosticMessage( + message: "This is the second fix-it.", + diagnosticID: MessageID(domain: "domain", id: "fixit2"), + severity: .error), + changes: [ + .replace(oldNode: Syntax(node), newNode: Syntax(node)) // no-op + ]) - context.diagnose(Diagnostic(node: node.attributeName, - message: SimpleDiagnosticMessage(message: "This is the first diagnostic.", - diagnosticID: MessageID(domain: "domain", id: "diagnostic2"), - severity: .warning), - fixIts: [firstFixIt, secondFixIt])) - context.diagnose(Diagnostic(node: node.attributeName, - message: SimpleDiagnosticMessage(message: "This is the second diagnostic, it's a note.", - diagnosticID: MessageID(domain: "domain", id: "diagnostic2"), - severity: .note))) + context.diagnose( + Diagnostic( + node: node.attributeName, + message: SimpleDiagnosticMessage( + message: "This is the first diagnostic.", + diagnosticID: MessageID(domain: "domain", id: "diagnostic2"), + severity: .warning), + fixIts: [firstFixIt, secondFixIt])) + context.diagnose( + Diagnostic( + node: node.attributeName, + message: SimpleDiagnosticMessage( + message: "This is the second diagnostic, it's a note.", + diagnosticID: MessageID(domain: "domain", id: "diagnostic2"), + severity: .note))) return [] }