From e4a3090b4fc1a971d60f4f76b18fe2eda1fe37f3 Mon Sep 17 00:00:00 2001 From: omochimetaru Date: Sat, 14 Jun 2025 12:48:07 +0900 Subject: [PATCH 1/4] support SwiftSyntax601 --- Package.resolved | 8 +++---- Package.swift | 2 +- Sources/MacroTesting/AssertMacro.swift | 23 +++++++++++++------ .../MacroExamples/AddAsyncMacro.swift | 2 +- .../MacroExamples/OptionSetMacro.swift | 2 +- .../SwiftSyntaxCompatibilityHelpers.swift | 11 +++++++++ 6 files changed, 34 insertions(+), 14 deletions(-) create mode 100644 Tests/MacroTestingTests/SwiftSyntaxCompatibilityHelpers.swift diff --git a/Package.resolved b/Package.resolved index 80436bf..41575b3 100644 --- a/Package.resolved +++ b/Package.resolved @@ -14,8 +14,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-snapshot-testing", "state" : { - "revision" : "b2d4cb30735f4fbc3a01963a9c658336dd21e9ba", - "version" : "1.18.1" + "revision" : "37230a37e83f1b7023be08e1b1a2603fcb1567fb", + "version" : "1.18.4" } }, { @@ -23,8 +23,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/swiftlang/swift-syntax", "state" : { - "revision" : "0687f71944021d616d34d922343dcef086855920", - "version" : "600.0.1" + "revision" : "f99ae8aa18f0cf0d53481901f88a0991dc3bd4a2", + "version" : "601.0.1" } }, { diff --git a/Package.swift b/Package.swift index 7914132..222709c 100644 --- a/Package.swift +++ b/Package.swift @@ -30,7 +30,7 @@ let package = Package( .conditionalPackage( url: "https://github.com/swiftlang/swift-syntax", envVar: "SWIFT_SYNTAX_VERSION", - default: "509.0.0..<601.0.0" + default: "509.0.0..<602.0.0" ), ], targets: [ diff --git a/Sources/MacroTesting/AssertMacro.swift b/Sources/MacroTesting/AssertMacro.swift index 6dc5f86..04dc830 100644 --- a/Sources/MacroTesting/AssertMacro.swift +++ b/Sources/MacroTesting/AssertMacro.swift @@ -549,14 +549,14 @@ public func assertMacro( } } -// From: https://github.com/apple/swift-syntax/blob/d647052/Sources/SwiftSyntaxMacrosTestSupport/Assertions.swift -extension FixIt.Change { +// From: https://github.com/swiftlang/swift-syntax/blob/601.0.1/Sources/SwiftSyntaxMacrosGenericTestSupport/Assertions.swift +fileprivate extension FixIt.Change { /// Returns the edit for this change, translating positions from detached nodes /// to the corresponding locations in the original source file based on /// `expansionContext`. /// /// - SeeAlso: `FixIt.Change.edit` - fileprivate func edit(in expansionContext: BasicMacroExpansionContext) -> SourceEdit { + func edit(in expansionContext: BasicMacroExpansionContext) -> SourceEdit { switch self { case .replace(let oldNode, let newNode): let start = expansionContext.position(of: oldNode.position, anchoredAt: oldNode) @@ -568,21 +568,30 @@ extension FixIt.Change { case .replaceLeadingTrivia(let token, let newTrivia): let start = expansionContext.position(of: token.position, anchoredAt: token) - let end = expansionContext.position( - of: token.positionAfterSkippingLeadingTrivia, anchoredAt: token) + let end = expansionContext.position(of: token.positionAfterSkippingLeadingTrivia, anchoredAt: token) return SourceEdit( range: start.. Date: Sat, 14 Jun 2025 12:55:52 +0900 Subject: [PATCH 2/4] add 601 to CI --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ce21c7d..386c826 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,6 +27,7 @@ jobs: "509.0.0..<510.0.0", "510.0.0..<511.0.0", "511.0.0..<601.0.0", + "601.0.0..<602.0.0", ] steps: From d3bb67e008879ac956a99e0ccdd3c1e10fea8991 Mon Sep 17 00:00:00 2001 From: omochimetaru Date: Fri, 12 Sep 2025 13:20:07 +0900 Subject: [PATCH 3/4] add explicit dependencies --- Package.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Package.swift b/Package.swift index 222709c..9e54f77 100644 --- a/Package.swift +++ b/Package.swift @@ -37,7 +37,13 @@ let package = Package( .macro( name: "MemberwiseInitMacros", dependencies: [ + .product(name: "SwiftBasicFormat", package: "swift-syntax"), .product(name: "SwiftCompilerPlugin", package: "swift-syntax"), + .product(name: "SwiftDiagnostics", package: "swift-syntax"), + .product(name: "SwiftParser", package: "swift-syntax"), + .product(name: "SwiftParserDiagnostics", package: "swift-syntax"), + .product(name: "SwiftSyntax", package: "swift-syntax"), + .product(name: "SwiftSyntaxBuilder", package: "swift-syntax"), .product(name: "SwiftSyntaxMacros", package: "swift-syntax"), ] ), From a9d504a795a4ef0151c45779797a12859c74e50b Mon Sep 17 00:00:00 2001 From: omochimetaru Date: Fri, 12 Sep 2025 13:25:50 +0900 Subject: [PATCH 4/4] revert add deps --- Package.swift | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Package.swift b/Package.swift index 9e54f77..222709c 100644 --- a/Package.swift +++ b/Package.swift @@ -37,13 +37,7 @@ let package = Package( .macro( name: "MemberwiseInitMacros", dependencies: [ - .product(name: "SwiftBasicFormat", package: "swift-syntax"), .product(name: "SwiftCompilerPlugin", package: "swift-syntax"), - .product(name: "SwiftDiagnostics", package: "swift-syntax"), - .product(name: "SwiftParser", package: "swift-syntax"), - .product(name: "SwiftParserDiagnostics", package: "swift-syntax"), - .product(name: "SwiftSyntax", package: "swift-syntax"), - .product(name: "SwiftSyntaxBuilder", package: "swift-syntax"), .product(name: "SwiftSyntaxMacros", package: "swift-syntax"), ] ),