Skip to content

Commit

Permalink
move/rename/add modules
Browse files Browse the repository at this point in the history
  • Loading branch information
MahdiBM committed Jul 10, 2024
1 parent a545b1b commit 0ddd246
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 23 deletions.
12 changes: 11 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,28 @@ let package = Package(
],
targets: [
.macro(
name: "EnumeratorMacro",
name: "EnumeratorMacroImpl",
dependencies: [
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
.product(name: "SwiftCompilerPlugin", package: "swift-syntax"),
.product(name: "Mustache", package: "swift-mustache"),
],
swiftSettings: swiftSettings
),
.target(
name: "EnumeratorMacro",
dependencies: [
"EnumeratorMacroImpl",
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
.product(name: "SwiftCompilerPlugin", package: "swift-syntax"),
],
swiftSettings: swiftSettings
),
.testTarget(
name: "EnumeratorMacroTests",
dependencies: [
"EnumeratorMacro",
"EnumeratorMacroImpl",
.product(name: "Testing", package: "swift-testing"),
.product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax"),
.product(name: "SwiftSyntax", package: "swift-syntax"),
Expand Down
7 changes: 7 additions & 0 deletions Sources/EnumeratorMacro/Enumerator.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import EnumeratorMacroImpl

@attached(member, names: arbitrary)
public macro Enumerator(_ templates: String...) = #externalMacro(
module: "EnumeratorMacro",
type: "EnumeratorMacroType"
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
23 changes: 1 addition & 22 deletions Tests/EnumeratorMacroTests/EnumeratorMacroTests.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import EnumeratorMacro
import EnumeratorMacroImpl
import SwiftSyntaxMacros
import SwiftSyntaxMacrosTestSupport
import Testing
Expand Down Expand Up @@ -194,12 +195,6 @@ import Testing
}
}

@attached(member, names: arbitrary)
macro Enumerator(_ templates: String...) = #externalMacro(
module: "EnumeratorMacro",
type: "EnumeratorMacroType"
)

@Enumerator("""
enum Subtype: String {
{{#cases}}
Expand Down Expand Up @@ -255,19 +250,3 @@ enum TestEnum {
self.subtype == other.subtype
}
}

@Enumerator("""
{{#cases}}
var is{{capitalized(name)}}: Bool {
switch self {
case .{{name}}: true
default: false
}
}
{{/cases}}
""")
enum TestEnum3 {
case a(value: String)
case b
case testCase(testValue: String)
}

0 comments on commit 0ddd246

Please sign in to comment.