File tree Expand file tree Collapse file tree 2 files changed +7
-15
lines changed
Sources/MacroToolkitExamplePlugin Expand file tree Collapse file tree 2 files changed +7
-15
lines changed Original file line number Diff line number Diff line change
1
+ import MacroToolkit
1
2
import SwiftDiagnostics
2
3
import SwiftOperators
3
4
import SwiftSyntax
4
5
import SwiftSyntaxMacros
5
- import MacroToolkit
6
6
7
7
// Modified from: https://github.com/DougGregor/swift-macro-examples/blob/f61ac7cdca8dc3557e53f86e7e03df1353908d3e/MacroExamplesPlugin/AddBlocker.swift
8
8
/// Implementation of the `addBlocker` macro, which demonstrates how to
@@ -34,7 +34,7 @@ public struct AddBlockerMacro: ExpressionMacro {
34
34
return ExprSyntax (
35
35
node. with (
36
36
\. operator,
37
- node. operator. with ( \. tokenKind, . binaryOperator( " - " ) )
37
+ node. operator. with ( \. tokenKind, . binaryOperator( " - " ) )
38
38
)
39
39
)
40
40
}
Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ extension OptionSetMacro: ExtensionMacro {
109
109
// OptionSet already, don't add one.
110
110
guard
111
111
let ( structDecl, _, _) = decodeExpansion (
112
- of: node,
112
+ of: node,
113
113
attachedTo: declaration,
114
114
in: context
115
115
) ,
@@ -120,19 +120,11 @@ extension OptionSetMacro: ExtensionMacro {
120
120
return [ ]
121
121
}
122
122
123
- // Since it creates an extension there is no need to add
124
- // types already inherited by struct declaration
125
123
return [
126
- ExtensionDeclSyntax (
127
- extendedType: type,
128
- inheritanceClause: InheritanceClauseSyntax {
129
- InheritedTypeSyntax (
130
- type: IdentifierTypeSyntax (
131
- name: " OptionSet "
132
- )
133
- )
134
- } ,
135
- memberBlockBuilder: { }
124
+ try ExtensionDeclSyntax (
125
+ """
126
+ extension \( type) : OptionSet {}
127
+ """
136
128
)
137
129
]
138
130
}
You can’t perform that action at this time.
0 commit comments