Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tvos-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
run: |
set -o pipefail && \
NSUnbufferedIO=YES \
xcrun xcodebuild build -workspace . -scheme Vexil-Package -skipMacroValidation -destination "platform=tvOS Simulator,name=Apple TV 4K (3rd generation)" \
xcrun xcodebuild build -workspace . -scheme Vexil-Package -skipMacroValidation -destination "generic/platform=tvOS Simulator" \
| xcbeautify --renderer github-actions

build-tvos:
Expand Down
6 changes: 3 additions & 3 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/apple/swift-async-algorithms.git", from: "1.0.0"),
.package(url: "https://github.com/nicklockwood/SwiftFormat.git", from: "0.60.1"),
.package(url: "https://github.com/swiftlang/swift-syntax.git", "600.0.0" ..< "604.0.0"),
.package(url: "https://github.com/swiftlang/swift-syntax.git", "600.0.0" ..< "605.0.0"),
],

targets: [
Expand Down
19 changes: 2 additions & 17 deletions Sources/VexilMacros/FlagContainerMacro.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ extension FlagContainerMacro: ExtensionMacro {
conformingTo protocols: [TypeSyntax],
in context: some MacroExpansionContext,
) throws -> [ExtensionDeclSyntax] {
var shouldGenerateConformance = protocols.isEmpty && ProcessInfo.processInfo.environment["XCTestConfigurationFilePath"] != nil
? node.shouldGenerateConformance
: protocols.shouldGenerateConformance
var shouldGenerateConformance = protocols.shouldGenerateConformance

// Check if the user has disabled Equatable conformance manually
if
Expand All @@ -79,8 +77,7 @@ extension FlagContainerMacro: ExtensionMacro {
shouldGenerateConformance.equatable = false
}

// Check that conformance doesn't already exist, or that we are inside a unit test.
// The latter is a workaround for https://github.com/apple/swift-syntax/issues/2031
// Check that conformance doesn't already exist
guard shouldGenerateConformance.flagContainer else {
return []
}
Expand Down Expand Up @@ -239,15 +236,3 @@ private extension [TypeSyntax] {
}

}

private extension AttributeSyntax {

var shouldGenerateConformance: (flagContainer: Bool, equatable: Bool, sendable: Bool) {
if attributeName.identifier == "FlagContainer" {
(true, true, true)
} else {
(false, false, false)
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import Vexil
extension FlagTextField where Value.BoxedValueType: BinaryFloatingPoint {

init(configuration: FlagControlConfiguration<Value>) {
self = Self(
self.init(
configuration: configuration,
formatted: \.asString,
editingFormat: { $0 },
)
#if os(iOS) || os(tvOS)
.keyboardType(.decimalPad)
keyboardType = .decimalPad
#endif
}

Expand Down Expand Up @@ -56,13 +56,13 @@ extension FlagControlConfiguration: FloatingPointTextFieldRepresentable where Va
extension FlagTextField {

init<Wrapped>(configuration: FlagControlConfiguration<Wrapped?>) where Value == Wrapped?, Wrapped.BoxedValueType: BinaryFloatingPoint {
self = Self(
self.init(
configuration: configuration,
formatted: \.asStringOrEmpty,
editingFormat: { $0 },
)
#if os(iOS) || os(tvOS)
.keyboardType(.decimalPad)
keyboardType = .decimalPad
#endif

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import Vexil
extension FlagTextField where Value.BoxedValueType: BinaryInteger {

init(configuration: FlagControlConfiguration<Value>) {
self = Self(
self.init(
configuration: configuration,
formatted: \.asString,
editingFormat: { $0.filter(\.isNumber) },
)
#if os(iOS) || os(tvOS)
.keyboardType(.numberPad)
keyboardType = .numberPad
#endif
}

Expand Down Expand Up @@ -56,13 +56,13 @@ extension FlagControlConfiguration: IntegerFlagTextFieldRepresentable where Valu
extension FlagTextField {

init<Wrapped>(configuration: FlagControlConfiguration<Wrapped?>) where Value == Wrapped?, Wrapped.BoxedValueType: BinaryInteger {
self = Self(
self.init(
configuration: configuration,
formatted: \.asStringOrEmpty,
editingFormat: { $0.filter(\.isNumber) },
)
#if os(iOS) || os(tvOS)
.keyboardType(.numberPad)
keyboardType = .numberPad
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Vexillographer/FlagControl/FlagTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
private var format: (String) -> String
private var editingFormat: (String) -> String
#if os(iOS) || os(tvOS)
private var keyboardType = UIKeyboardType.default
var keyboardType = UIKeyboardType.default
#endif

@State
Expand Down Expand Up @@ -65,16 +65,16 @@
.keyboardType(keyboardType)
#endif
}
.onChange(of: value.boxedFlagValue) { _ in

Check warning on line 68 in Sources/Vexillographer/FlagControl/FlagTextField.swift

View workflow job for this annotation

GitHub Actions / visionOS Matrix (26.4, macos-26)

'onChange(of:perform:)' was deprecated in visionOS 1.0: Use `onChange` with a two or zero parameter action closure instead.

Check warning on line 68 in Sources/Vexillographer/FlagControl/FlagTextField.swift

View workflow job for this annotation

GitHub Actions / visionOS Matrix (26.4, macos-26)

'onChange(of:perform:)' was deprecated in visionOS 1.0: Use `onChange` with a two or zero parameter action closure instead.

Check warning on line 68 in Sources/Vexillographer/FlagControl/FlagTextField.swift

View workflow job for this annotation

GitHub Actions / visionOS Matrix (26.3, macos-26)

'onChange(of:perform:)' was deprecated in visionOS 1.0: Use `onChange` with a two or zero parameter action closure instead.

Check warning on line 68 in Sources/Vexillographer/FlagControl/FlagTextField.swift

View workflow job for this annotation

GitHub Actions / visionOS Matrix (26.3, macos-26)

'onChange(of:perform:)' was deprecated in visionOS 1.0: Use `onChange` with a two or zero parameter action closure instead.

Check warning on line 68 in Sources/Vexillographer/FlagControl/FlagTextField.swift

View workflow job for this annotation

GitHub Actions / visionOS Matrix (26.2, macos-26)

'onChange(of:perform:)' was deprecated in visionOS 1.0: Use `onChange` with a two or zero parameter action closure instead.

Check warning on line 68 in Sources/Vexillographer/FlagControl/FlagTextField.swift

View workflow job for this annotation

GitHub Actions / visionOS Matrix (26.2, macos-26)

'onChange(of:perform:)' was deprecated in visionOS 1.0: Use `onChange` with a two or zero parameter action closure instead.
cachedText = nil
}
.onChange(of: cachedText) { newText in

Check warning on line 71 in Sources/Vexillographer/FlagControl/FlagTextField.swift

View workflow job for this annotation

GitHub Actions / visionOS Matrix (26.4, macos-26)

'onChange(of:perform:)' was deprecated in visionOS 1.0: Use `onChange` with a two or zero parameter action closure instead.

Check warning on line 71 in Sources/Vexillographer/FlagControl/FlagTextField.swift

View workflow job for this annotation

GitHub Actions / visionOS Matrix (26.4, macos-26)

'onChange(of:perform:)' was deprecated in visionOS 1.0: Use `onChange` with a two or zero parameter action closure instead.

Check warning on line 71 in Sources/Vexillographer/FlagControl/FlagTextField.swift

View workflow job for this annotation

GitHub Actions / visionOS Matrix (26.3, macos-26)

'onChange(of:perform:)' was deprecated in visionOS 1.0: Use `onChange` with a two or zero parameter action closure instead.

Check warning on line 71 in Sources/Vexillographer/FlagControl/FlagTextField.swift

View workflow job for this annotation

GitHub Actions / visionOS Matrix (26.3, macos-26)

'onChange(of:perform:)' was deprecated in visionOS 1.0: Use `onChange` with a two or zero parameter action closure instead.

Check warning on line 71 in Sources/Vexillographer/FlagControl/FlagTextField.swift

View workflow job for this annotation

GitHub Actions / visionOS Matrix (26.2, macos-26)

'onChange(of:perform:)' was deprecated in visionOS 1.0: Use `onChange` with a two or zero parameter action closure instead.

Check warning on line 71 in Sources/Vexillographer/FlagControl/FlagTextField.swift

View workflow job for this annotation

GitHub Actions / visionOS Matrix (26.2, macos-26)

'onChange(of:perform:)' was deprecated in visionOS 1.0: Use `onChange` with a two or zero parameter action closure instead.
guard let newText else {
return
}
cachedText = editingFormat(newText)
}
.onChange(of: isFocused) { isFocused in

Check warning on line 77 in Sources/Vexillographer/FlagControl/FlagTextField.swift

View workflow job for this annotation

GitHub Actions / visionOS Matrix (26.4, macos-26)

'onChange(of:perform:)' was deprecated in visionOS 1.0: Use `onChange` with a two or zero parameter action closure instead.

Check warning on line 77 in Sources/Vexillographer/FlagControl/FlagTextField.swift

View workflow job for this annotation

GitHub Actions / visionOS Matrix (26.4, macos-26)

'onChange(of:perform:)' was deprecated in visionOS 1.0: Use `onChange` with a two or zero parameter action closure instead.

Check warning on line 77 in Sources/Vexillographer/FlagControl/FlagTextField.swift

View workflow job for this annotation

GitHub Actions / visionOS Matrix (26.3, macos-26)

'onChange(of:perform:)' was deprecated in visionOS 1.0: Use `onChange` with a two or zero parameter action closure instead.

Check warning on line 77 in Sources/Vexillographer/FlagControl/FlagTextField.swift

View workflow job for this annotation

GitHub Actions / visionOS Matrix (26.3, macos-26)

'onChange(of:perform:)' was deprecated in visionOS 1.0: Use `onChange` with a two or zero parameter action closure instead.

Check warning on line 77 in Sources/Vexillographer/FlagControl/FlagTextField.swift

View workflow job for this annotation

GitHub Actions / visionOS Matrix (26.2, macos-26)

'onChange(of:perform:)' was deprecated in visionOS 1.0: Use `onChange` with a two or zero parameter action closure instead.

Check warning on line 77 in Sources/Vexillographer/FlagControl/FlagTextField.swift

View workflow job for this annotation

GitHub Actions / visionOS Matrix (26.2, macos-26)

'onChange(of:perform:)' was deprecated in visionOS 1.0: Use `onChange` with a two or zero parameter action closure instead.
guard isFocused == false, let cachedText else {
return
}
Expand Down
37 changes: 19 additions & 18 deletions Tests/VexilMacroTests/EquatableFlagContainerMacroTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#if canImport(VexilMacros)

import SwiftSyntaxMacroExpansion
import SwiftSyntaxMacros
import SwiftSyntaxMacrosTestSupport
import VexilMacros
Expand Down Expand Up @@ -60,8 +61,8 @@ final class EquatableFlagContainerMacroTests: XCTestCase {
extension TestFlags: Sendable {
}
""",
macros: [
"FlagContainer": FlagContainerMacro.self,
macroSpecs: [
"FlagContainer": MacroSpec(type: FlagContainerMacro.self, conformances: ["FlagContainer", "Equatable", "Sendable"]),
],
)
}
Expand Down Expand Up @@ -163,9 +164,9 @@ final class EquatableFlagContainerMacroTests: XCTestCase {
extension TestFlags: Sendable {
}
""",
macros: [
"FlagContainer": FlagContainerMacro.self,
"Flag": FlagMacro.self,
macroSpecs: [
"FlagContainer": MacroSpec(type: FlagContainerMacro.self, conformances: ["FlagContainer", "Equatable", "Sendable"]),
"Flag": MacroSpec(type: FlagMacro.self),
],
)
}
Expand Down Expand Up @@ -241,9 +242,9 @@ final class EquatableFlagContainerMacroTests: XCTestCase {
extension TestFlags: Sendable {
}
""",
macros: [
"FlagContainer": FlagContainerMacro.self,
"Flag": FlagMacro.self,
macroSpecs: [
"FlagContainer": MacroSpec(type: FlagContainerMacro.self, conformances: ["FlagContainer", "Equatable", "Sendable"]),
"Flag": MacroSpec(type: FlagMacro.self),
],
)
}
Expand Down Expand Up @@ -322,9 +323,9 @@ final class EquatableFlagContainerMacroTests: XCTestCase {
extension SomeContainer.TestFlags: Sendable {
}
""",
macros: [
"FlagContainer": FlagContainerMacro.self,
"Flag": FlagMacro.self,
macroSpecs: [
"FlagContainer": MacroSpec(type: FlagContainerMacro.self, conformances: ["FlagContainer", "Equatable", "Sendable"]),
"Flag": MacroSpec(type: FlagMacro.self),
],
)
}
Expand Down Expand Up @@ -399,9 +400,9 @@ final class EquatableFlagContainerMacroTests: XCTestCase {
extension TestFlags: Sendable {
}
""",
macros: [
"FlagContainer": FlagContainerMacro.self,
"Flag": FlagMacro.self,
macroSpecs: [
"FlagContainer": MacroSpec(type: FlagContainerMacro.self, conformances: ["FlagContainer", "Equatable", "Sendable"]),
"Flag": MacroSpec(type: FlagMacro.self),
],
)
}
Expand Down Expand Up @@ -497,8 +498,8 @@ final class EquatableFlagContainerMacroTests: XCTestCase {
extension TestFlags: Sendable {
}
""",
macros: [
"FlagContainer": FlagContainerMacro.self,
macroSpecs: [
"FlagContainer": MacroSpec(type: FlagContainerMacro.self, conformances: ["FlagContainer", "Equatable", "Sendable"]),
],
)
}
Expand Down Expand Up @@ -594,8 +595,8 @@ final class EquatableFlagContainerMacroTests: XCTestCase {
extension TestFlags: Sendable {
}
""",
macros: [
"FlagContainer": FlagContainerMacro.self,
macroSpecs: [
"FlagContainer": MacroSpec(type: FlagContainerMacro.self, conformances: ["FlagContainer", "Equatable", "Sendable"]),
],
)
}
Expand Down
17 changes: 9 additions & 8 deletions Tests/VexilMacroTests/FlagContainerMacroTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#if canImport(VexilMacros)

import SwiftSyntaxMacroExpansion
import SwiftSyntaxMacros
import SwiftSyntaxMacrosTestSupport
import VexilMacros
Expand Down Expand Up @@ -60,8 +61,8 @@ final class FlagContainerMacroTests: XCTestCase {
extension TestFlags: Sendable {
}
""",
macros: [
"FlagContainer": FlagContainerMacro.self,
macroSpecs: [
"FlagContainer": MacroSpec(type: FlagContainerMacro.self, conformances: ["FlagContainer", "Equatable", "Sendable"]),
],
)
}
Expand Down Expand Up @@ -106,8 +107,8 @@ final class FlagContainerMacroTests: XCTestCase {
extension TestFlags: Sendable {
}
""",
macros: [
"FlagContainer": FlagContainerMacro.self,
macroSpecs: [
"FlagContainer": MacroSpec(type: FlagContainerMacro.self, conformances: ["FlagContainer", "Equatable", "Sendable"]),
],
)
}
Expand Down Expand Up @@ -152,8 +153,8 @@ final class FlagContainerMacroTests: XCTestCase {
extension TestFlags: Sendable {
}
""",
macros: [
"FlagContainer": FlagContainerMacro.self,
macroSpecs: [
"FlagContainer": MacroSpec(type: FlagContainerMacro.self, conformances: ["FlagContainer", "Equatable", "Sendable"]),
],
)
}
Expand Down Expand Up @@ -251,8 +252,8 @@ final class FlagContainerMacroTests: XCTestCase {
extension TestFlags: Sendable {
}
""",
macros: [
"FlagContainer": FlagContainerMacro.self,
macroSpecs: [
"FlagContainer": MacroSpec(type: FlagContainerMacro.self, conformances: ["FlagContainer", "Equatable", "Sendable"]),
],
)
}
Expand Down
Loading