@@ -27,9 +27,9 @@ enum ModifiedCopyDiagnostic: DiagnosticMessage {
27
27
var diagnosticID : MessageID {
28
28
switch self {
29
29
case . notAStruct:
30
- . init( domain: " ModifiedCopyMacros " , id: " notAStruct " )
30
+ . init( domain: " ModifiedCopyMacros " , id: " notAStruct " )
31
31
case . propertyTypeProblem( let binding) :
32
- . init( domain: " ModifiedCopyMacros " , id: " propertyTypeProblem( \( binding. pattern) ) " )
32
+ . init( domain: " ModifiedCopyMacros " , id: " propertyTypeProblem( \( binding. pattern) ) " )
33
33
}
34
34
}
35
35
}
@@ -41,26 +41,26 @@ public struct ModifiedCopyMacro: MemberMacro {
41
41
in context: some MacroExpansionContext
42
42
) throws -> [ DeclSyntax ] {
43
43
guard let structDeclSyntax = declaration as? StructDeclSyntax else {
44
- let diagnostic = Diagnostic ( node: node, message: ModifiedCopyDiagnostic . notAStruct
45
- )
44
+ let diagnostic = Diagnostic ( node: Syntax ( node) , message: ModifiedCopyDiagnostic . notAStruct)
46
45
context. diagnose ( diagnostic)
47
46
return [ ]
48
47
}
49
- let structVisibility = structDeclSyntax. modifiers. visibilityText ( ) ?? " internal "
48
+
49
+ let structVisibility = structDeclSyntax. modifiers? . visibilityText ( ) ?? " internal "
50
50
51
51
let variables = structDeclSyntax. memberBlock. members. compactMap { $0. decl. as ( VariableDeclSyntax . self) }
52
52
53
- let bindings = variables. flatMap ( \. bindings) . filter { accessorIsAllowed ( $0. accessorBlock ) }
53
+ let bindings = variables. flatMap ( \. bindings) . filter { accessorIsAllowed ( $0. accessor ) }
54
54
55
55
return variables. flatMap { variable in
56
- let variableVisibility = variable. modifiers. visibilityText ( ) ?? structVisibility
56
+ let variableVisibility = variable. modifiers? . visibilityText ( ) ?? structVisibility
57
57
58
58
return variable. bindings
59
- . filter { accessorIsAllowed ( $0. accessorBlock ) }
59
+ . filter { accessorIsAllowed ( $0. accessor ) }
60
60
. compactMap { binding -> DeclSyntax ? in
61
61
let propertyName = binding. pattern
62
62
guard let typeName = binding. typeAnnotation? . type else {
63
- let diagnostic = Diagnostic ( node: node, message: ModifiedCopyDiagnostic . propertyTypeProblem ( binding) )
63
+ let diagnostic = Diagnostic ( node: Syntax ( node) , message: ModifiedCopyDiagnostic . propertyTypeProblem ( binding) )
64
64
context. diagnose ( diagnostic)
65
65
return nil
66
66
}
@@ -75,20 +75,20 @@ public struct ModifiedCopyMacro: MemberMacro {
75
75
}
76
76
}
77
77
78
- private static func accessorIsAllowed( _ accessorsBlock : AccessorBlockSyntax ? ) -> Bool {
79
- guard let accessorsBlock else { return true }
80
- switch accessorsBlock . accessors {
78
+ private static func accessorIsAllowed( _ accessor : PatternBindingSyntax . Accessor ? ) -> Bool {
79
+ guard let accessor else { return true }
80
+ return switch accessor {
81
81
case . accessors( let accessorDeclListSyntax) :
82
- return !accessorDeclListSyntax. contains ( where : {
83
- $0. accessorSpecifier . text == " get " || $0. accessorSpecifier . text == " set "
84
- } )
82
+ !accessorDeclListSyntax. accessors . contains {
83
+ $0. accessorKind . text == " get " || $0. accessorKind . text == " set "
84
+ }
85
85
case . getter:
86
- return false
86
+ false
87
87
}
88
88
}
89
89
}
90
90
91
- extension DeclModifierListSyntax {
91
+ extension ModifierListSyntax {
92
92
private static let visibilityModifiers : Set = [ " private " , " fileprivate " , " internal " , " package " , " public " , " open " ]
93
93
94
94
func visibilityText( ) -> String ? {
0 commit comments