Skip to content
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

Use throwsClause #672

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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: 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
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?.throwsSpecifier == 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