Skip to content

Commit ee68391

Browse files
Support SwiftSyntax v601 (#93)
* Support SwiftSyntax v601. * Run swiftformat --------- Co-authored-by: Ian Wagner <[email protected]>
1 parent 0747609 commit ee68391

File tree

3 files changed

+30
-15
lines changed

3 files changed

+30
-15
lines changed

Package.resolved

Lines changed: 14 additions & 14 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
@@ -27,7 +27,7 @@ let package = Package(
2727
dependencies: [
2828
.package(url: "https://github.com/maplibre/maplibre-gl-native-distribution.git", from: "6.10.0"),
2929
// Macros
30-
.package(url: "https://github.com/swiftlang/swift-syntax.git", "509.0.0" ..< "601.0.0"),
30+
.package(url: "https://github.com/swiftlang/swift-syntax.git", "509.0.0" ..< "602.0.0"),
3131
// Testing
3232
.package(url: "https://github.com/Kolos65/Mockable.git", from: "0.3.1"),
3333
.package(url: "https://github.com/pointfreeco/swift-snapshot-testing", from: "1.18.3"),

Sources/MapLibreSwiftMacrosImpl/StyleExpressionMacro.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,21 @@ private func generateFunctionDeclSyntax(identifier: TokenSyntax, valueType: Type
9393
}
9494
}
9595

96+
#if canImport(SwiftSyntax601)
97+
// This provides compatibility for the new SwiftSyntax API, returning an empty result if the argument has
98+
// been parsed as an expression.
99+
private func generateStyleProperty(for attributes: AttributeSyntax, valueType: GenericArgumentSyntax.Argument,
100+
isRawRepresentable: Bool) throws -> [DeclSyntax]
101+
{
102+
switch valueType {
103+
case let .type(type):
104+
try generateStyleProperty(for: attributes, valueType: type, isRawRepresentable: isRawRepresentable)
105+
default:
106+
[]
107+
}
108+
}
109+
#endif
110+
96111
public struct MLNStylePropertyMacro: MemberMacro {
97112
public static func expansion(
98113
of node: AttributeSyntax,

0 commit comments

Comments
 (0)