Skip to content

Commit

Permalink
Update to latest SwiftSyntax
Browse files Browse the repository at this point in the history
  • Loading branch information
jpsim committed Sep 28, 2022
1 parent f8f5d19 commit acfa674
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
},
{
"package": "SwiftSyntax",
"repositoryURL": "https://github.com/rintaro/swift-syntax.git",
"repositoryURL": "https://github.com/jpsim/swift-syntax.git",
"state": {
"branch": null,
"revision": "322559c794d7d4ed4d3053c6fac4890941abb0b4",
"revision": "dd44b5f8998018e7fcb199fbd370187dc4986364",
"version": null
}
},
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let package = Package(
],
dependencies: [
.package(name: "swift-argument-parser", url: "https://github.com/apple/swift-argument-parser.git", .upToNextMinor(from: "1.1.3")),
.package(name: "SwiftSyntax", url: "https://github.com/rintaro/swift-syntax.git", .revision("322559c794d7d4ed4d3053c6fac4890941abb0b4")),
.package(name: "SwiftSyntax", url: "https://github.com/jpsim/swift-syntax.git", .revision("dd44b5f8998018e7fcb199fbd370187dc4986364")),
.package(url: "https://github.com/jpsim/SourceKitten.git", from: "0.33.0"),
.package(url: "https://github.com/jpsim/Yams.git", from: "5.0.1"),
.package(url: "https://github.com/scottrhoyt/SwiftyTextTable.git", from: "0.9.0"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ extension Configuration {

switch rulesMode {
case .allEnabled:
break
return

case .only(let onlyRules):
if Set(onlyRules).isDisjoint(with: rule.description.allIdentifiers) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private final class ReturnValueFromVoidFunctionVisitor: SyntaxVisitor, Violation
override func visitPost(_ node: ReturnStmtSyntax) {
if node.expression != nil,
let functionNode = Syntax(node).enclosingFunction(),
functionNode.returnsVoid {
functionNode.returnsVoid {
violationPositions.append(node.positionAfterSkippingLeadingTrivia)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,41 @@ internal struct ReturnValueFromVoidFunctionRuleExamples {
var foo: Int {
return 0
}
""")
"""),
Example(#"""
final class SearchMessagesDataSource: ValueCellDataSource {
internal enum Section: Int {
case emptyState
case messageThreads
}
internal func load(messageThreads: [MessageThread]) {
self.set(
values: messageThreads,
cellClass: MessageThreadCell.self,
inSection: Section.messageThreads.rawValue
)
}
internal func emptyState(isVisible: Bool) {
self.set(
cellIdentifiers: isVisible ? ["SearchMessagesEmptyState"] : [],
inSection: Section.emptyState.rawValue
)
}
internal override func configureCell(tableCell cell: UITableViewCell, withValue value: Any) {
switch (cell, value) {
case let (cell as MessageThreadCell, value as MessageThread):
cell.configureWith(value: value)
case (is StaticTableViewCell, is Void):
return
default:
assertionFailure("Unrecognized combo: \(cell), \(value).")
}
}
}
"""#, excludeFromDocumentation: true)
]

static let triggeringExamples = [
Expand Down
12 changes: 10 additions & 2 deletions bazel/SwiftSyntax.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ swift_library(
visibility = ["//visibility:public"],
)

swift_library(
name = "SwiftBasicFormat",
srcs = glob(["Sources/SwiftBasicFormat/**/*.swift"]),
module_name = "SwiftBasicFormat",
visibility = ["//visibility:public"],
deps = [":SwiftSyntax"],
)

swift_library(
name = "SwiftDiagnostics",
srcs = glob(["Sources/SwiftDiagnostics/**/*.swift"]),
Expand All @@ -29,13 +37,13 @@ swift_library(
srcs = glob(["Sources/SwiftParser/**/*.swift"]),
module_name = "SwiftParser",
visibility = ["//visibility:public"],
deps = [":SwiftSyntax", ":SwiftDiagnostics"],
deps = [":SwiftSyntax", ":SwiftDiagnostics", ":SwiftBasicFormat"],
)

swift_library(
name = "SwiftSyntaxBuilder",
srcs = glob(["Sources/SwiftSyntaxBuilder/**/*.swift"]),
module_name = "SwiftSyntaxBuilder",
visibility = ["//visibility:public"],
deps = [":SwiftSyntax"],
deps = [":SwiftSyntax", ":SwiftBasicFormat"],
)
6 changes: 3 additions & 3 deletions bazel/repos.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ def swiftlint_repos():
# https://github.com/apple/swift-syntax/pull/807
http_archive(
name = "com_github_apple_swift_syntax",
sha256 = "d1171203ae646323a3b9878356ff183744122ec5e1fb452974e7ecfffc9f5220",
sha256 = "4523782ffe237ef841083ca14986bc7a6b151dfaeb64cca045cc0ab3dc2702fc",
build_file = "@SwiftLint//bazel:SwiftSyntax.BUILD",
strip_prefix = "swift-syntax-322559c794d7d4ed4d3053c6fac4890941abb0b4",
url = "https://github.com/rintaro/swift-syntax/archive/322559c794d7d4ed4d3053c6fac4890941abb0b4.tar.gz",
strip_prefix = "swift-syntax-dd44b5f8998018e7fcb199fbd370187dc4986364",
url = "https://github.com/jpsim/swift-syntax/archive/dd44b5f8998018e7fcb199fbd370187dc4986364.tar.gz",
)

http_archive(
Expand Down

0 comments on commit acfa674

Please sign in to comment.