Skip to content

Commit

Permalink
minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
JARMourato committed Jun 26, 2024
1 parent f85a2cf commit 789ff09
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
6 changes: 3 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ let package = Package(
],
targets: [
.macro(
name: "InjectionMacrosImpl",
name: "InjectionMacros",
dependencies: [
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
.product(name: "SwiftCompilerPlugin", package: "swift-syntax"),
]
),

.target(name: "Injection", dependencies: ["InjectionMacrosImpl"]),
.target(name: "Injection", dependencies: ["InjectionMacros"]),

.testTarget(
name: "InjectionTests",
dependencies: [
"Injection",
"InjectionMacrosImpl",
"InjectionMacros",
.product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax"),
],
path: "Tests"
Expand Down
6 changes: 2 additions & 4 deletions Sources/Injection/Macros.swift
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
// Copyright © 2024 JARMourato All rights reserved.

import InjectionMacrosImpl

// MARK: - Macros

/// Creates an unique `DependencyKey` for the variable and adds getters and setters.
/// The initial value of the variable becomes the default value of the `DependencyKey`.
@attached(peer, names: prefixed(___))
@attached(accessor, names: named(get), named(set))
public macro DependencyKey() = #externalMacro(module: "InjectionMacrosImpl", type: "DependencyKeyMacro")
public macro DependencyKey() = #externalMacro(module: "InjectionMacros", type: "DependencyKeyMacro")

/// Applies the @DependencyKey macro to each child in the scope.
/// This should only be applied on an `EnvironmentValues` or `DependencyValues` extensions.
@attached(memberAttribute)
public macro Inject() = #externalMacro(module: "InjectionMacrosImpl", type: "InjectValuesMacro")
public macro Inject() = #externalMacro(module: "InjectionMacros", type: "InjectValuesMacro")
File renamed without changes.

0 comments on commit 789ff09

Please sign in to comment.