Skip to content

Fix build warnings #796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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: EffectSpecifiersSyntax>(_ 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)
}
Expand Down Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public final class ValidateDocumentationComments: SyntaxLintRule {
}

validateThrows(
signature.effectSpecifiers?.throwsSpecifier,
signature.effectSpecifiers?.throwsClause?.throwsSpecifier,
name: name,
throwsDescription: docComment.throws,
node: node)
Expand Down
2 changes: 1 addition & 1 deletion Sources/generate-swift-format/FileGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down