Skip to content

Commit 3d220f8

Browse files
committed
Make some minor clean up changes
1 parent 4998c1e commit 3d220f8

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

Sources/MacroToolkitExamplePlugin/AddBlockerMacro.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import MacroToolkit
12
import SwiftDiagnostics
23
import SwiftOperators
34
import SwiftSyntax
45
import 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
}

Sources/MacroToolkitExamplePlugin/OptionSetMacro.swift

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)