Skip to content

Commit 3a46360

Browse files
committed
Improve syntax
1 parent f770749 commit 3a46360

File tree

3 files changed

+2
-6
lines changed

3 files changed

+2
-6
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ A practical collection of Swift Macros that help code correctly and smartly.
44

55
## Install
66

7-
.package(url: "https://github.com/ShenghaiWang/SwiftMacros.git", from: "0.1.0")
7+
.package(url: "https://github.com/ShenghaiWang/SwiftMacros.git", from: "1.0.0")
88

99
## Macros
1010

Sources/Macros/AddAssociatedValueVariable.swift

+1-5
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@ public struct AddAssociatedValueVariable: MemberMacro {
2222
} else {
2323
typeValue = "\(associatedValue)"
2424
}
25-
var isPublic = ""
26-
if declaration.modifiers?.compactMap(\.name.tokenKind.keyword).contains(.public) ?? false {
27-
isPublic = "public "
28-
}
29-
let varSyntax = try VariableDeclSyntax("\(raw: isPublic)var \(element.identifier)Value: \(raw: typeValue)?") {
25+
let varSyntax = try VariableDeclSyntax("\(declaration.modifiers ?? ModifierListSyntax())var \(element.identifier)Value: \(raw: typeValue)?") {
3026
try IfExprSyntax(
3127
"if case let .\(element.identifier)(\(raw: associatedValue.parameterList.toVariableNames)) = self",
3228
bodyBuilder: {

0 commit comments

Comments
 (0)