Skip to content

Commit

Permalink
Update SwiftSyntax (realm#4639)
Browse files Browse the repository at this point in the history
* `ObjcKeyPathExprSyntax` -> `MacroExpansionExprSyntax`
* Fix `#selector()` and add a regression test

Co-authored-by: JP Simard <[email protected]>
  • Loading branch information
github-actions[bot] and jpsim authored Dec 14, 2022
1 parent 53ee4a9 commit 25c3fb1
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-syntax.git",
"state" : {
"revision" : "76d01195182593ff34f5ada1ab0910fae190fc9c"
"revision" : "6fcc5a4b897351766da9dca9d14e26897ca17dc7"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser.git", .upToNextMinor(from: "1.2.0")),
.package(url: "https://github.com/apple/swift-syntax.git", revision: "76d01195182593ff34f5ada1ab0910fae190fc9c"),
.package(url: "https://github.com/apple/swift-syntax.git", revision: "6fcc5a4b897351766da9dca9d14e26897ca17dc7"),
.package(url: "https://github.com/jpsim/SourceKitten.git", .upToNextMinor(from: "0.33.1")),
.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 @@ -83,6 +83,17 @@ struct PreferSelfInStaticReferencesRule: SwiftSyntaxRule, CorrectableRule, Confi
""", excludeFromDocumentation: true)
],
triggeringExamples: [
Example("""
final class CheckCellView: NSTableCellView {
@IBOutlet var checkButton: NSButton!
override func awakeFromNib() {
checkButton.action = #selector(↓CheckCellView.check(_:))
}
@objc func check(_ button: AnyObject?) {}
}
"""),
Example("""
class C {
struct S {
Expand Down Expand Up @@ -146,6 +157,28 @@ struct PreferSelfInStaticReferencesRule: SwiftSyntaxRule, CorrectableRule, Confi
""", excludeFromDocumentation: true)
],
corrections: [
Example("""
final class CheckCellView: NSTableCellView {
@IBOutlet var checkButton: NSButton!
override func awakeFromNib() {
checkButton.action = #selector(↓CheckCellView.check(_:))
}
@objc func check(_ button: AnyObject?) {}
}
"""):
Example("""
final class CheckCellView: NSTableCellView {
@IBOutlet var checkButton: NSButton!
override func awakeFromNib() {
checkButton.action = #selector(Self.check(_:))
}
@objc func check(_ button: AnyObject?) {}
}
"""),
Example("""
struct S {
static let i = 1
Expand Down Expand Up @@ -296,8 +329,8 @@ private class Visitor: ViolationsSyntaxVisitor {
_ = variableDeclScopes.popLast()
}

override func visit(_ node: ObjcKeyPathExprSyntax) -> SyntaxVisitorContinueKind {
if case .likeStruct = parentDeclScopes.last {
override func visit(_ node: MacroExpansionExprSyntax) -> SyntaxVisitorContinueKind {
if case .likeClass = parentDeclScopes.last, case .identifier("selector") = node.macro.tokenKind {
return .visitChildren
}
return .skipChildren
Expand Down
6 changes: 3 additions & 3 deletions bazel/repos.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ def swiftlint_repos():

http_archive(
name = "com_github_apple_swift_syntax",
sha256 = "4f244c3acac972817579517d8799c702e5c36d223ab8ab596d9b63010e35e1c6", # SwiftSyntax sha256
sha256 = "17bdf4c9c87bac4f7160be1ca2e4e0101f97f7b75181e18df62b3e425ea753d8", # SwiftSyntax sha256
build_file = "@SwiftLint//bazel:SwiftSyntax.BUILD",
strip_prefix = "swift-syntax-76d01195182593ff34f5ada1ab0910fae190fc9c",
url = "https://github.com/apple/swift-syntax/archive/76d01195182593ff34f5ada1ab0910fae190fc9c.tar.gz",
strip_prefix = "swift-syntax-6fcc5a4b897351766da9dca9d14e26897ca17dc7",
url = "https://github.com/apple/swift-syntax/archive/6fcc5a4b897351766da9dca9d14e26897ca17dc7.tar.gz",
)

http_archive(
Expand Down

0 comments on commit 25c3fb1

Please sign in to comment.