Skip to content

Commit 851c8b6

Browse files
authored
Support swift-syntax from 600.0.0-latest (#22)
* Support swift-syntax from 600.0.0-latest The Xcode 16 beta generates macro projects using these swift-syntax snapshots. Luckily things seem to be backwards compatible, so we can expand our supported range. * Fix warnings
1 parent 5c4a1b9 commit 851c8b6

File tree

3 files changed

+31
-15
lines changed

3 files changed

+31
-15
lines changed

Package.resolved

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ let package = Package(
1717
)
1818
],
1919
dependencies: [
20-
.package(url: "https://github.com/apple/swift-syntax", "509.0.0"..<"511.0.0"),
20+
.package(url: "https://github.com/apple/swift-syntax", "509.0.0"..<"601.0.0"),
2121
.package(url: "https://github.com/pointfreeco/swift-snapshot-testing", from: "1.16.0"),
2222
],
2323
targets: [

Sources/MacroTesting/AssertMacro.swift

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,19 @@ public func assertMacro(
177177
origSourceFile: .init(moduleName: "TestModule", fullFilePath: "Test.swift")
178178
]
179179
)
180-
var expandedSourceFile = origSourceFile.expand(
181-
macros: macros,
182-
in: context,
183-
indentationWidth: indentationWidth
184-
)
180+
#if canImport(SwiftSyntax600)
181+
var expandedSourceFile = origSourceFile.expand(
182+
macros: macros,
183+
contextGenerator: { _ in context },
184+
indentationWidth: indentationWidth
185+
)
186+
#else
187+
var expandedSourceFile = origSourceFile.expand(
188+
macros: macros,
189+
in: context,
190+
indentationWidth: indentationWidth
191+
)
192+
#endif
185193

186194
var offset = 0
187195

@@ -300,11 +308,19 @@ public func assertMacro(
300308
fixedSourceFile: .init(moduleName: "TestModule", fullFilePath: "Test.swift")
301309
]
302310
)
303-
expandedSourceFile = fixedSourceFile.expand(
304-
macros: macros,
305-
in: context,
306-
indentationWidth: indentationWidth
307-
)
311+
#if canImport(SwiftSyntax600)
312+
expandedSourceFile = fixedSourceFile.expand(
313+
macros: macros,
314+
contextGenerator: { _ in context },
315+
indentationWidth: indentationWidth
316+
)
317+
#else
318+
expandedSourceFile = fixedSourceFile.expand(
319+
macros: macros,
320+
in: context,
321+
indentationWidth: indentationWidth
322+
)
323+
#endif
308324
} else if fixedSource != nil {
309325
offset += 1
310326
assertInlineSnapshot(

0 commit comments

Comments
 (0)