Skip to content

Commit

Permalink
Use SwiftSyntax version 600.0.0-prerelease-2024-03-11
Browse files Browse the repository at this point in the history
  • Loading branch information
SimplyDanny committed Apr 5, 2024
1 parent dd8789b commit b002f65
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 27 deletions.
6 changes: 3 additions & 3 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ module(
repo_name = "SwiftLint",
)

bazel_dep(name = "apple_support", version = "1.11.1", repo_name = "build_bazel_apple_support")
bazel_dep(name = "apple_support", version = "1.13.0", repo_name = "build_bazel_apple_support")
bazel_dep(name = "bazel_skylib", version = "1.5.0")
bazel_dep(name = "platforms", version = "0.0.8")
bazel_dep(name = "rules_apple", version = "3.1.1", repo_name = "build_bazel_rules_apple")
bazel_dep(name = "rules_apple", version = "3.3.0", repo_name = "build_bazel_rules_apple")
bazel_dep(name = "rules_swift", version = "1.16.0", repo_name = "build_bazel_rules_swift")
bazel_dep(name = "sourcekitten", version = "0.34.1", repo_name = "com_github_jpsim_sourcekitten")
bazel_dep(name = "swift-syntax", version = "510.0.0", repo_name = "SwiftSyntax")
bazel_dep(name = "swift-syntax", version = "600.0.0-prerelease-2024-04-02", repo_name = "SwiftSyntax")
bazel_dep(name = "swift_argument_parser", version = "1.2.1", repo_name = "sourcekitten_com_github_apple_swift_argument_parser")
bazel_dep(name = "yams", version = "5.0.6", repo_name = "sourcekitten_com_github_jpsim_yams")

Expand Down
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-syntax.git",
"state" : {
"revision" : "08a2f0a9a30e0f705f79c9cfaca1f68b71bdc775",
"version" : "510.0.0"
"revision" : "55c4e4669c031d697e1924022b8ba250cfde0f2f",
"version" : "600.0.0-prerelease-2024-04-02"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser.git", .upToNextMinor(from: "1.2.1")),
.package(url: "https://github.com/apple/swift-syntax.git", exact: "510.0.0"),
.package(url: "https://github.com/apple/swift-syntax.git", exact: "600.0.0-prerelease-2024-04-02"),
.package(url: "https://github.com/jpsim/SourceKitten.git", .upToNextMinor(from: "0.34.1")),
.package(url: "https://github.com/jpsim/Yams.git", from: "5.0.6"),
.package(url: "https://github.com/scottrhoyt/SwiftyTextTable.git", from: "0.9.0"),
Expand Down
27 changes: 11 additions & 16 deletions Source/SwiftLintBuiltInRules/Rules/Style/ControlStatementRule.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@_spi(SyntaxTransformVisitor)
import SwiftSyntax

@SwiftSyntaxRule(explicitRewriter: true)
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions Source/SwiftLintCore/Extensions/SwiftSyntax+SwiftLint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,6 @@ public extension ClosureCaptureSyntax {
}
}

extension PrecedenceGroupDeclSyntax: BracedSyntax {}

private extension String {
var isZero: Bool {
if self == "0" { // fast path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public extension SyntaxClassification {
switch self {
case .lineComment, .docLineComment, .blockComment, .docBlockComment:
return true
case .none, .keyword, .identifier, .type, .operator, .dollarIdentifier, .integerLiteral,
case .none, .keyword, .identifier, .type, .operator, .dollarIdentifier, .integerLiteral, .argumentLabel,
.floatLiteral, .stringLiteral, .ifConfigDirective, .attribute, .editorPlaceholder, .regexLiteral:
return false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ final class MakeAcceptableByConfigurationElementTests: XCTestCase {
.symbol(rawValue)
}
private init(fromAny value: Any, context ruleID: String) throws {
if let value = value as? String, let newSelf = Self (rawValue: value) {
if let value = value as? String, let newSelf = Self(rawValue: value) {
self = newSelf
} else {
throw Issue.invalidConfiguration(ruleID: ruleID)
Expand Down Expand Up @@ -89,7 +89,7 @@ final class MakeAcceptableByConfigurationElementTests: XCTestCase {
.symbol(rawValue)
}
public init(fromAny value: Any, context ruleID: String) throws {
if let value = value as? String, let newSelf = Self (rawValue: value) {
if let value = value as? String, let newSelf = Self(rawValue: value) {
self = newSelf
} else {
throw Issue.invalidConfiguration(ruleID: ruleID)
Expand Down

0 comments on commit b002f65

Please sign in to comment.