Skip to content

Commit

Permalink
Add support for package access modifier to DependencyClient macro (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanlisovyi committed Apr 30, 2024
1 parent 9620f73 commit 7b139d8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Sources/DependenciesMacrosPlugin/DependencyClientMacro.swift
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ public enum DependencyClientMacro: MemberAttributeMacro, MemberMacro {
private enum Access: Comparable {
case `private`
case `internal`
case `package`
case `public`

init?(modifiers: DeclModifierListSyntax) {
Expand All @@ -224,6 +225,9 @@ private enum Access: Comparable {
case .keyword(.internal):
self = .internal
return
case .keyword(.package):
self = .package
return
case .keyword(.public):
self = .public
return
Expand All @@ -240,6 +244,8 @@ private enum Access: Comparable {
return .keyword(.private)
case .internal:
return nil
case .package:
return .keyword(.package)
case .public:
return .keyword(.public)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,33 @@ final class DependencyClientMacroTests: BaseTestCase {
}
}

func testPackage() {
assertMacro {
"""
@DependencyClient
package struct Client {
package var endpoint: () -> Void
}
"""
} expansion: {
"""
package struct Client {
@DependencyEndpoint
package var endpoint: () -> Void
package init(
endpoint: @escaping () -> Void
) {
self.endpoint = endpoint
}
package init() {
}
}
"""
}
}

func testSendable() {
assertMacro {
"""
Expand Down

0 comments on commit 7b139d8

Please sign in to comment.