From 69fdbd970768c8bbbc6d0ab40f3b0fcce877ba0f Mon Sep 17 00:00:00 2001 From: Nick Lockwood Date: Sat, 14 Oct 2023 08:50:16 +0100 Subject: [PATCH] Fix `docComments` rule for macros --- Sources/ParsingHelpers.swift | 2 +- Tests/RulesTests+Syntax.swift | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Sources/ParsingHelpers.swift b/Sources/ParsingHelpers.swift index 84dab491..03e78ec9 100644 --- a/Sources/ParsingHelpers.swift +++ b/Sources/ParsingHelpers.swift @@ -2491,7 +2491,7 @@ extension Token { "import", "let", "var", "typealias", "func", "enum", "case", "struct", "class", "actor", "protocol", "init", "deinit", "extension", "subscript", "operator", "precedencegroup", - "associatedtype", + "associatedtype", "macro", ]) for keywordToExclude in keywordsToExclude { diff --git a/Tests/RulesTests+Syntax.swift b/Tests/RulesTests+Syntax.swift index 2dde59b2..b60e58e6 100644 --- a/Tests/RulesTests+Syntax.swift +++ b/Tests/RulesTests+Syntax.swift @@ -3322,6 +3322,17 @@ class SyntaxTests: RulesTests { testFormatting(for: input, rule: FormatRules.docComments) } + func testDocCommentForMacro() { + let input = """ + /// Adds a static `logger` member to the type. + @attached(member, names: named(logger)) public macro StaticLogger( + subsystem: String? = nil, + category: String? = nil + ) = #externalMacro(module: "StaticLoggerMacros", type: "StaticLogger") + """ + testFormatting(for: input, rule: FormatRules.docComments) + } + // MARK: - conditionalAssignment func testDoesntConvertIfStatementAssignmentSwift5_8() {