Use SwiftSyntax version 600.0.0-prerelease-2024-03-11 (#5527)

We can also switch back to an exact SwiftSyntax version now with the
plugins in a separate repository. In fact, using the plugin, no direct
dependency to SwiftSyntax is required whatsoever.
This commit is contained in:
Danny Mösch
2024-06-22 11:14:14 +02:00
committed by GitHub
parent 72069bf5c0
commit 914fa02e4e
8 changed files with 21 additions and 28 deletions
@@ -234,7 +234,7 @@ private extension StructDeclSyntax {
private extension InitializerDeclSyntax {
var hasThrowsOrRethrowsKeyword: Bool {
signature.effectSpecifiers?.throwsSpecifier != nil
signature.effectSpecifiers?.throwsClause?.throwsSpecifier != nil
}
var isInlinable: Bool {
attributes.contains(attributeNamed: "inlinable")
@@ -1,4 +1,3 @@
@_spi(SyntaxTransformVisitor)
import SwiftSyntax
@SwiftSyntaxRule(explicitRewriter: true)
@@ -166,27 +165,23 @@ private extension ControlStatementRule {
}
}
private class TrailingClosureFinder: SyntaxTransformVisitor {
func visitAny(_ node: Syntax) -> Bool {
false
}
func visit(_ node: FunctionCallExprSyntax) -> Bool {
node.trailingClosure != nil
}
func visit(_ node: SequenceExprSyntax) -> Bool {
node.elements.contains(where: visit)
}
}
private extension ExprSyntax {
var unwrapped: ExprSyntax? {
if let expr = self.as(TupleExprSyntax.self)?.elements.onlyElement?.expression {
return TrailingClosureFinder().visit(expr) ? nil : expr
return containsTrailingClosure(Syntax(expr)) ? nil : expr
}
return nil
}
private func containsTrailingClosure(_ node: Syntax) -> Bool {
switch node.as(SyntaxEnum.self) {
case .functionCallExpr(let node):
node.trailingClosure != nil
case .sequenceExpr(let node):
node.elements.contains { containsTrailingClosure(Syntax($0)) }
default: false
}
}
}
private extension ConditionElementListSyntax {