@@ -8,20 +8,20 @@ public struct Access: AccessorMacro {
8
8
Declaration: DeclSyntaxProtocol > ( of node: AttributeSyntax ,
9
9
providingAccessorsOf declaration: Declaration ,
10
10
in context: Context ) throws -> [ AccessorDeclSyntax ] {
11
- guard let firstArg = node. argument ? . as ( TupleExprElementListSyntax . self) ? . first,
11
+ guard let firstArg = node. arguments ? . as ( LabeledExprListSyntax . self) ? . first,
12
12
let type = firstArg. type else {
13
13
throw MacroDiagnostics . errorMacroUsage ( message: " Must specify a content type " )
14
14
}
15
15
if type == " userDefaults " ,
16
- let dataType = node. attributeName. as ( SimpleTypeIdentifierSyntax . self) ? . type {
16
+ let dataType = node. attributeName. as ( IdentifierTypeSyntax . self) ? . type {
17
17
return processUserDefaults ( for: declaration,
18
18
userDefaults: firstArg. userDefaults,
19
19
type: " \( dataType) " )
20
20
} else if [ " nsCache " , " nsMapTable " ] . contains ( type) ,
21
21
let object = firstArg. object,
22
- let dataType = node. attributeName. as ( SimpleTypeIdentifierSyntax . self) ? . type {
23
- let isOptionalType = node. attributeName. as ( SimpleTypeIdentifierSyntax . self) ? . genericArgumentClause? . arguments
24
- . first? . as ( GenericArgumentSyntax . self) ? . argumentType . is ( OptionalTypeSyntax . self) ?? false
22
+ let dataType = node. attributeName. as ( IdentifierTypeSyntax . self) ? . type {
23
+ let isOptionalType = node. attributeName. as ( IdentifierTypeSyntax . self) ? . genericArgumentClause? . arguments
24
+ . first? . as ( GenericArgumentSyntax . self) ? . argument . is ( OptionalTypeSyntax . self) ?? false
25
25
return processNSCacheAndNSMapTable ( for: declaration,
26
26
object: object,
27
27
type: " \( dataType) " ,
@@ -36,7 +36,7 @@ public struct Access: AccessorMacro {
36
36
private static func processKeychain( for declaration: DeclSyntaxProtocol ) -> [ AccessorDeclSyntax ] {
37
37
guard let binding = declaration. as ( VariableDeclSyntax . self) ? . bindings. first,
38
38
let identifier = binding. pattern. as ( IdentifierPatternSyntax . self) ? . identifier. text,
39
- binding. accessor == nil else { return [ ] }
39
+ binding. accessorBlock == nil else { return [ ] }
40
40
let getAccessor : AccessorDeclSyntax =
41
41
"""
42
42
get {
@@ -63,7 +63,7 @@ public struct Access: AccessorMacro {
63
63
type: String ) -> [ AccessorDeclSyntax ] {
64
64
guard let binding = declaration. as ( VariableDeclSyntax . self) ? . bindings. first,
65
65
let identifier = binding. pattern. as ( IdentifierPatternSyntax . self) ? . identifier. text,
66
- binding. accessor == nil else { return [ ] }
66
+ binding. accessorBlock == nil else { return [ ] }
67
67
var defaultValue = " "
68
68
if let value = binding. initializer? . value {
69
69
defaultValue = " ?? \( value) "
@@ -90,7 +90,7 @@ public struct Access: AccessorMacro {
90
90
isOptionalType: Bool ) -> [ AccessorDeclSyntax ] {
91
91
guard let binding = declaration. as ( VariableDeclSyntax . self) ? . bindings. first,
92
92
let identifier = binding. pattern. as ( IdentifierPatternSyntax . self) ? . identifier. text,
93
- binding. accessor == nil else { return [ ] }
93
+ binding. accessorBlock == nil else { return [ ] }
94
94
var defaultValue = " "
95
95
if let value = binding. initializer? . value {
96
96
defaultValue = " ?? \( value) "
0 commit comments