Update SwiftSyntax (#4639)
* `ObjcKeyPathExprSyntax` -> `MacroExpansionExprSyntax` * Fix `#selector()` and add a regression test Co-authored-by: JP Simard <jp@jpsim.com>
This commit is contained in:
parent
53ee4a955d
commit
25c3fb161d
|
@ -32,7 +32,7 @@
|
||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://github.com/apple/swift-syntax.git",
|
"location" : "https://github.com/apple/swift-syntax.git",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "76d01195182593ff34f5ada1ab0910fae190fc9c"
|
"revision" : "6fcc5a4b897351766da9dca9d14e26897ca17dc7"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,7 +30,7 @@ let package = Package(
|
||||||
],
|
],
|
||||||
dependencies: [
|
dependencies: [
|
||||||
.package(url: "https://github.com/apple/swift-argument-parser.git", .upToNextMinor(from: "1.2.0")),
|
.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/SourceKitten.git", .upToNextMinor(from: "0.33.1")),
|
||||||
.package(url: "https://github.com/jpsim/Yams.git", from: "5.0.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"),
|
.package(url: "https://github.com/scottrhoyt/SwiftyTextTable.git", from: "0.9.0"),
|
||||||
|
|
|
@ -83,6 +83,17 @@ struct PreferSelfInStaticReferencesRule: SwiftSyntaxRule, CorrectableRule, Confi
|
||||||
""", excludeFromDocumentation: true)
|
""", excludeFromDocumentation: true)
|
||||||
],
|
],
|
||||||
triggeringExamples: [
|
triggeringExamples: [
|
||||||
|
Example("""
|
||||||
|
final class CheckCellView: NSTableCellView {
|
||||||
|
@IBOutlet var checkButton: NSButton!
|
||||||
|
|
||||||
|
override func awakeFromNib() {
|
||||||
|
checkButton.action = #selector(↓CheckCellView.check(_:))
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func check(_ button: AnyObject?) {}
|
||||||
|
}
|
||||||
|
"""),
|
||||||
Example("""
|
Example("""
|
||||||
class C {
|
class C {
|
||||||
struct S {
|
struct S {
|
||||||
|
@ -146,6 +157,28 @@ struct PreferSelfInStaticReferencesRule: SwiftSyntaxRule, CorrectableRule, Confi
|
||||||
""", excludeFromDocumentation: true)
|
""", excludeFromDocumentation: true)
|
||||||
],
|
],
|
||||||
corrections: [
|
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("""
|
Example("""
|
||||||
struct S {
|
struct S {
|
||||||
static let i = 1
|
static let i = 1
|
||||||
|
@ -296,8 +329,8 @@ private class Visitor: ViolationsSyntaxVisitor {
|
||||||
_ = variableDeclScopes.popLast()
|
_ = variableDeclScopes.popLast()
|
||||||
}
|
}
|
||||||
|
|
||||||
override func visit(_ node: ObjcKeyPathExprSyntax) -> SyntaxVisitorContinueKind {
|
override func visit(_ node: MacroExpansionExprSyntax) -> SyntaxVisitorContinueKind {
|
||||||
if case .likeStruct = parentDeclScopes.last {
|
if case .likeClass = parentDeclScopes.last, case .identifier("selector") = node.macro.tokenKind {
|
||||||
return .visitChildren
|
return .visitChildren
|
||||||
}
|
}
|
||||||
return .skipChildren
|
return .skipChildren
|
||||||
|
|
|
@ -19,10 +19,10 @@ def swiftlint_repos():
|
||||||
|
|
||||||
http_archive(
|
http_archive(
|
||||||
name = "com_github_apple_swift_syntax",
|
name = "com_github_apple_swift_syntax",
|
||||||
sha256 = "4f244c3acac972817579517d8799c702e5c36d223ab8ab596d9b63010e35e1c6", # SwiftSyntax sha256
|
sha256 = "17bdf4c9c87bac4f7160be1ca2e4e0101f97f7b75181e18df62b3e425ea753d8", # SwiftSyntax sha256
|
||||||
build_file = "@SwiftLint//bazel:SwiftSyntax.BUILD",
|
build_file = "@SwiftLint//bazel:SwiftSyntax.BUILD",
|
||||||
strip_prefix = "swift-syntax-76d01195182593ff34f5ada1ab0910fae190fc9c",
|
strip_prefix = "swift-syntax-6fcc5a4b897351766da9dca9d14e26897ca17dc7",
|
||||||
url = "https://github.com/apple/swift-syntax/archive/76d01195182593ff34f5ada1ab0910fae190fc9c.tar.gz",
|
url = "https://github.com/apple/swift-syntax/archive/6fcc5a4b897351766da9dca9d14e26897ca17dc7.tar.gz",
|
||||||
)
|
)
|
||||||
|
|
||||||
http_archive(
|
http_archive(
|
||||||
|
|
Loading…
Reference in New Issue