Skip to content

Commit bb70edf

Browse files
authored
Feature/view model (#3)
* Add auto creating enum Action * Add handleAction * Format * Add class access check * Fix review * Fix * Fix * Fix * Fix * Fix * Fix * Fix * Fix
1 parent ba09af3 commit bb70edf

8 files changed

Lines changed: 2611 additions & 12 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ xcuserdata/
55
DerivedData/
66
.netrc
77
Package.resolved
8-
/.swiftpm
8+
/.swiftpm
9+
/AGENTS.md
10+
/CLAUDE.md

.swiftformat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
--swiftversion 6.1
22
--disable preferKeyPath
3+
--disable unusedArguments
4+
--disable trailingCommas
35
--ifdef no-indent
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1+
@attached(extension, names: named(Action))
2+
@attached(member, names: named(handleAction))
3+
public macro ViewModel() = #externalMacro(module: "OversizeMacroMacros", type: "ViewModelMacro")
4+
15
@attached(member, names: arbitrary)
26
public macro AutoRoutable() = #externalMacro(module: "OversizeMacroMacros", type: "AutoRoutableMacro")

Sources/OversizeMacroMacros/AutoRoutableMacro.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ import SwiftSyntax
22
import SwiftSyntaxMacros
33

44
public struct AutoRoutableMacro: MemberMacro {
5-
public static func expansion<Declaration: DeclGroupSyntax, Context: MacroExpansionContext>(
5+
public static func expansion(
66
of node: AttributeSyntax,
7-
providingMembersOf declaration: Declaration,
8-
conformingTo _: [TypeSyntax],
9-
in context: Context
7+
providingMembersOf declaration: some DeclGroupSyntax,
8+
conformingTo protocols: [TypeSyntax],
9+
in context: some MacroExpansionContext
1010
) throws -> [DeclSyntax] {
1111
try expansion(of: node, providingMembersOf: declaration, in: context)
1212
}
1313

14-
public static func expansion<Declaration: DeclGroupSyntax, Context: MacroExpansionContext>(
15-
of _: AttributeSyntax,
16-
providingMembersOf declaration: Declaration,
17-
in _: Context
14+
public static func expansion(
15+
of node: AttributeSyntax,
16+
providingMembersOf declaration: some DeclGroupSyntax,
17+
in context: some MacroExpansionContext
1818
) throws -> [DeclSyntax] {
1919
let caseNames: [String] = declaration.memberBlock.members
2020
.compactMap { $0.decl.as(EnumCaseDeclSyntax.self) }

Sources/OversizeMacroMacros/OversizeMacroPlugin.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import SwiftSyntaxMacros
44
@main
55
struct OversizeMacroPlugin: CompilerPlugin {
66
let providingMacros: [Macro.Type] = [
7-
AutoRoutableMacro.self,
7+
ViewModelMacro.self,
8+
AutoRoutableMacro.self
89
]
910
}

0 commit comments

Comments
 (0)