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
12import SwiftDiagnostics
23import SwiftOperators
34import SwiftSyntax
45import SwiftSyntaxMacros
5- import MacroToolkit
66
77// Modified from: https://github.com/DougGregor/swift-macro-examples/blob/f61ac7cdca8dc3557e53f86e7e03df1353908d3e/MacroExamplesPlugin/AddBlocker.swift
88/// Implementation of the `addBlocker` macro, which demonstrates how to
@@ -34,7 +34,7 @@ public struct AddBlockerMacro: ExpressionMacro {
3434 return ExprSyntax (
3535 node. with (
3636 \. operator,
37- node. operator. with ( \. tokenKind, . binaryOperator( " - " ) )
37+ node. operator. with ( \. tokenKind, . binaryOperator( " - " ) )
3838 )
3939 )
4040 }
Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ extension OptionSetMacro: ExtensionMacro {
109109 // OptionSet already, don't add one.
110110 guard
111111 let ( structDecl, _, _) = decodeExpansion (
112- of: node,
112+ of: node,
113113 attachedTo: declaration,
114114 in: context
115115 ) ,
@@ -120,19 +120,11 @@ extension OptionSetMacro: ExtensionMacro {
120120 return [ ]
121121 }
122122
123- // Since it creates an extension there is no need to add
124- // types already inherited by struct declaration
125123 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+ """
136128 )
137129 ]
138130 }
You can’t perform that action at this time.
0 commit comments