diff --git a/Package.resolved b/Package.resolved index 7fcfb4b120..e302d010dc 100644 --- a/Package.resolved +++ b/Package.resolved @@ -33,7 +33,7 @@ "repositoryURL": "https://github.com/apple/swift-syntax.git", "state": { "branch": null, - "revision": "75492a3ea7498572a30beb1e3c5cfb073da8e753", + "revision": "0519e76999c9e548e58222e45a22f177c886d8c0", "version": null } }, diff --git a/Package.swift b/Package.swift index 28a6945e9e..238ae40124 100644 --- a/Package.swift +++ b/Package.swift @@ -27,7 +27,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/apple/swift-syntax.git", .revision("75492a3ea7498572a30beb1e3c5cfb073da8e753")), + .package(name: "SwiftSyntax", url: "https://github.com/apple/swift-syntax.git", .revision("0519e76999c9e548e58222e45a22f177c886d8c0")), .package(url: "https://github.com/jpsim/SourceKitten.git", .revision("a9e6df65d8e31e0fa6e8a05ffe40ecd54a645871")), .package(url: "https://github.com/jpsim/Yams.git", from: "5.0.1"), .package(url: "https://github.com/scottrhoyt/SwiftyTextTable.git", from: "0.9.0"), diff --git a/Source/SwiftLintFramework/Rules/Idiomatic/DiscouragedObjectLiteralRule.swift b/Source/SwiftLintFramework/Rules/Idiomatic/DiscouragedObjectLiteralRule.swift index 46295d3536..5c6edf20a3 100644 --- a/Source/SwiftLintFramework/Rules/Idiomatic/DiscouragedObjectLiteralRule.swift +++ b/Source/SwiftLintFramework/Rules/Idiomatic/DiscouragedObjectLiteralRule.swift @@ -38,12 +38,19 @@ private extension DiscouragedObjectLiteralRule { super.init(viewMode: .sourceAccurate) } - override func visitPost(_ node: ObjectLiteralExprSyntax) { - if !configuration.imageLiteral && node.identifier.text == "#imageLiteral" { + override func visitPost(_ node: MacroExpansionExprSyntax) { + guard + case let .identifier(identifierText) = node.macro.tokenKind, + ["colorLiteral", "imageLiteral"].contains(identifierText) + else { return } - if !configuration.colorLiteral && node.identifier.text == "#colorLiteral" { + if !configuration.imageLiteral && identifierText == "imageLiteral" { + return + } + + if !configuration.colorLiteral && identifierText == "colorLiteral" { return } diff --git a/Source/SwiftLintFramework/Rules/Idiomatic/TrailingSemicolonRule.swift b/Source/SwiftLintFramework/Rules/Idiomatic/TrailingSemicolonRule.swift index c5c993deab..f55a55ca34 100644 --- a/Source/SwiftLintFramework/Rules/Idiomatic/TrailingSemicolonRule.swift +++ b/Source/SwiftLintFramework/Rules/Idiomatic/TrailingSemicolonRule.swift @@ -55,7 +55,7 @@ private extension TrailingSemicolonRule { self.disabledRegions = disabledRegions } - override func visit(_ node: TokenSyntax) -> Syntax { + override func visit(_ node: TokenSyntax) -> TokenSyntax { guard node.isTrailingSemicolon, !node.isContainedIn(regions: disabledRegions, locationConverter: locationConverter) diff --git a/Source/SwiftLintFramework/Rules/Style/ClosingBraceRule.swift b/Source/SwiftLintFramework/Rules/Style/ClosingBraceRule.swift index 2024aff65b..baf77044fb 100644 --- a/Source/SwiftLintFramework/Rules/Style/ClosingBraceRule.swift +++ b/Source/SwiftLintFramework/Rules/Style/ClosingBraceRule.swift @@ -54,7 +54,7 @@ private extension ClosingBraceRule { self.disabledRegions = disabledRegions } - override func visit(_ node: TokenSyntax) -> Syntax { + override func visit(_ node: TokenSyntax) -> TokenSyntax { guard node.hasClosingBraceViolation, !node.isContainedIn(regions: disabledRegions, locationConverter: locationConverter) diff --git a/bazel/repos.bzl b/bazel/repos.bzl index 5c814b572c..b56f3eda7e 100644 --- a/bazel/repos.bzl +++ b/bazel/repos.bzl @@ -20,10 +20,10 @@ def swiftlint_repos(): http_archive( name = "com_github_apple_swift_syntax", - sha256 = "9b4c48e04408e89cf2d2219b85afcb983f230b57d21fa206223fd29fb8202843", + sha256 = "331d411773efcd924e3e91f0f9899715c2259bedd29277693baa5263ee588220", build_file = "@SwiftLint//bazel:SwiftSyntax.BUILD", - strip_prefix = "swift-syntax-75492a3ea7498572a30beb1e3c5cfb073da8e753", - url = "https://github.com/apple/swift-syntax/archive/75492a3ea7498572a30beb1e3c5cfb073da8e753.tar.gz", + strip_prefix = "swift-syntax-0519e76999c9e548e58222e45a22f177c886d8c0", + url = "https://github.com/apple/swift-syntax/archive/0519e76999c9e548e58222e45a22f177c886d8c0.tar.gz", ) http_archive(