From 6e0e645e1aa7ec342af98a6403833bfbe2fb6db0 Mon Sep 17 00:00:00 2001 From: Alex Hoppen Date: Wed, 14 Aug 2024 18:05:33 -0700 Subject: [PATCH] Fix build warnings --- .../SwiftFormat/PrettyPrint/TokenStreamCreator.swift | 12 +++++++----- .../Rules/UseSynthesizedInitializer.swift | 2 +- .../Rules/ValidateDocumentationComments.swift | 2 +- Sources/generate-swift-format/FileGenerator.swift | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift b/Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift index e88f1dccb..ce0dbe8c8 100644 --- a/Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift +++ b/Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift @@ -527,9 +527,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) } @@ -2302,9 +2302,11 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor { override func visit(_ node: AttributedTypeSyntax) -> SyntaxVisitorContinueKind { arrangeAttributeList(node.attributes) - after( - node.specifier, - tokens: .break(.continue, newlines: .elective(ignoresDiscretionary: true))) + for specifier in node.specifiers { + after( + specifier.firstToken(viewMode: .sourceAccurate), + tokens: .break(.continue, newlines: .elective(ignoresDiscretionary: true))) + } return .visitChildren } diff --git a/Sources/SwiftFormat/Rules/UseSynthesizedInitializer.swift b/Sources/SwiftFormat/Rules/UseSynthesizedInitializer.swift index 43ba2d67d..80614b64a 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 == nil else { continue } initializers.append(initDecl) } } diff --git a/Sources/SwiftFormat/Rules/ValidateDocumentationComments.swift b/Sources/SwiftFormat/Rules/ValidateDocumentationComments.swift index 95c6c1238..8bb5b117b 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) diff --git a/Sources/generate-swift-format/FileGenerator.swift b/Sources/generate-swift-format/FileGenerator.swift index bd4c8b32a..85a8861bc 100644 --- a/Sources/generate-swift-format/FileGenerator.swift +++ b/Sources/generate-swift-format/FileGenerator.swift @@ -35,7 +35,7 @@ extension FileGenerator { } } -extension FileHandle: TextOutputStream { +extension FileHandle { /// Writes the provided string as data to a file output stream. public func write(_ string: String) { guard let data = string.data(using: .utf8) else { return }