mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
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:
+1
-1
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user