Skip to content

Commit

Permalink
fix(): fix ComposableObject macro to be applied correctly to access…
Browse files Browse the repository at this point in the history
… modifiers

- rename the macro test target to ComposableMacroTest due to a duplicated target name
  • Loading branch information
wlsdms0122 committed Jun 3, 2024
1 parent a89fd16 commit 9024eaf
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
15 changes: 15 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"originHash" : "451a4227a52c5d76284cb42d2af427b33622a8db10ee88a856dc3a76ddb4d6cd",
"pins" : [
{
"identity" : "swift-syntax",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-syntax.git",
"state" : {
"revision" : "64889f0c732f210a935a0ad7cda38f77f876262d",
"version" : "509.1.1"
}
}
],
"version" : 3
}
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ let package = Package(
dependencies: ["Compose"]
),
.testTarget(
name: "MacroTests",
name: "ComposeMacroTests",
dependencies: [
"ComposeMacro",
.product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax"),
Expand Down
2 changes: 1 addition & 1 deletion Sources/ComposeMacro/ComposableObjectMacro.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private extension VariableDeclSyntax {
}

var isPrivateProperty: Bool {
modifier?.name.text == "private"
modifier?.name.text == "private" && modifier?.detail?.detail.text != "set"
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// MacroTests.swift
// ComposeMacroTests.swift
//
//
// Created by jsilver on 6/2/24.
Expand All @@ -14,7 +14,7 @@ let testMacros: [String: Macro.Type] = [
"ComposableObject": ComposableObjectMacro.self,
]

final class MacroTests: XCTestCase {
final class ComposeMacroTests: XCTestCase {
// MARK: - Property

// MARK: - Lifecycle
Expand All @@ -32,15 +32,21 @@ final class MacroTests: XCTestCase {
"""
@ComposableObject
class Environment {
var a: Int = 0
private var b: Int = 0
public var a: Int = 0
var b: Int = 0
private(set) var c: Int = 0
private var d: Int = 0
}
""",
expandedSource: """
class Environment {
@Published
var a: Int = 0
private var b: Int = 0
public var a: Int = 0
@Published
var b: Int = 0
@Published
private(set) var c: Int = 0
private var d: Int = 0
}
extension Environment: ObservableObject {
Expand Down

0 comments on commit 9024eaf

Please sign in to comment.