From 2e28829ead96d310a0a6047ac4020218c44f5d53 Mon Sep 17 00:00:00 2001 From: Daiki Matsudate Date: Wed, 6 Dec 2023 14:40:10 +0900 Subject: [PATCH] Use throwsClause --- Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift | 4 ++-- Sources/SwiftFormat/Rules/UseSynthesizedInitializer.swift | 2 +- Sources/SwiftFormat/Rules/ValidateDocumentationComments.swift | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift b/Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift index 070de11a..925bcc50 100644 --- a/Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift +++ b/Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift @@ -511,9 +511,9 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor { /// Arranges the `async` and `throws` effect specifiers of a function or accessor declaration. private func arrangeEffectSpecifiers(_ node: Node) { before(node.asyncSpecifier, tokens: .break) - before(node.throwsSpecifier, tokens: .break) + before(node.throwsClause?.throwsSpecifier, tokens: .break) // Keep them together if both `async` and `throws` are present. - if let asyncSpecifier = node.asyncSpecifier, let throwsSpecifier = node.throwsSpecifier { + if let asyncSpecifier = node.asyncSpecifier, let throwsSpecifier = node.throwsClause?.throwsSpecifier { before(asyncSpecifier, tokens: .open) after(throwsSpecifier, tokens: .close) } diff --git a/Sources/SwiftFormat/Rules/UseSynthesizedInitializer.swift b/Sources/SwiftFormat/Rules/UseSynthesizedInitializer.swift index e3d4e244..970e18ba 100644 --- a/Sources/SwiftFormat/Rules/UseSynthesizedInitializer.swift +++ b/Sources/SwiftFormat/Rules/UseSynthesizedInitializer.swift @@ -36,7 +36,7 @@ public final class UseSynthesizedInitializer: SyntaxLintRule { // Collect any possible redundant initializers into a list } else if let initDecl = member.as(InitializerDeclSyntax.self) { guard initDecl.optionalMark == nil else { continue } - guard initDecl.signature.effectSpecifiers?.throwsSpecifier == nil else { continue } + guard initDecl.signature.effectSpecifiers?.throwsClause?.throwsSpecifier == nil else { continue } initializers.append(initDecl) } } diff --git a/Sources/SwiftFormat/Rules/ValidateDocumentationComments.swift b/Sources/SwiftFormat/Rules/ValidateDocumentationComments.swift index 95c6c123..8bb5b117 100644 --- a/Sources/SwiftFormat/Rules/ValidateDocumentationComments.swift +++ b/Sources/SwiftFormat/Rules/ValidateDocumentationComments.swift @@ -62,7 +62,7 @@ public final class ValidateDocumentationComments: SyntaxLintRule { } validateThrows( - signature.effectSpecifiers?.throwsSpecifier, + signature.effectSpecifiers?.throwsClause?.throwsSpecifier, name: name, throwsDescription: docComment.throws, node: node)