Skip to content

Commit

Permalink
Run swift-format
Browse files Browse the repository at this point in the history
  • Loading branch information
stephencelis authored and github-actions[bot] committed Nov 14, 2023
1 parent d0a8c51 commit b2640f4
Showing 1 changed file with 32 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 []
}
Expand Down

0 comments on commit b2640f4

Please sign in to comment.