Skip to content

Commit 9810c8d

Browse files
mbrandonwgithub-actions[bot]
authored andcommitted
Run swift-format
1 parent 5a99c24 commit 9810c8d

File tree

2 files changed

+84
-84
lines changed

2 files changed

+84
-84
lines changed

Sources/CasePathsMacros/CasePathableMacro.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,13 +435,13 @@ extension EnumCaseElementListSyntax.Element {
435435
associatedValue.parameters[index].secondName = nil
436436
}
437437
}
438-
438+
439439
// Remove trailing comma from the last parameter for tuple type generation
440440
if let lastIndex = associatedValue.parameters.indices.last {
441441
associatedValue.parameters[lastIndex] = associatedValue.parameters[lastIndex]
442442
.with(\.trailingComma, nil)
443443
}
444-
444+
445445
return "(\(associatedValue.parameters.trimmed))"
446446
}
447447
} else {

Tests/CasePathsMacrosTests/CasePathableMacroTests.swift

Lines changed: 82 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,98 +1294,98 @@
12941294
"""#
12951295
}
12961296
}
1297-
1297+
12981298
func testTrailingCommas() {
12991299
assertMacro {
1300-
"""
1301-
@CasePathable enum Action {
1302-
case exampleAction(
1303-
param1: String,
1304-
param2: String,
1305-
param3: String,
1306-
)
1307-
case singleParam(
1308-
value: Int,
1309-
)
1310-
case multipleWithLabels(
1311-
first: String,
1312-
second: Bool,
1313-
third: Double,
1314-
)
1315-
}
1316-
"""
1317-
} expansion: {
1318-
#"""
1319-
enum Action {
1320-
case exampleAction(
1321-
param1: String,
1322-
param2: String,
1323-
param3: String,
1324-
)
1325-
case singleParam(
1326-
value: Int,
1327-
)
1328-
case multipleWithLabels(
1329-
first: String,
1330-
second: Bool,
1331-
third: Double,
1332-
)
1333-
1334-
public struct AllCasePaths: CasePaths.CasePathReflectable, Swift.Sendable, Swift.Sequence {
1335-
public subscript(root: Action) -> CasePaths.PartialCaseKeyPath<Action> {
1336-
if root.is(\.exampleAction) {
1337-
return \.exampleAction
1338-
}
1339-
if root.is(\.singleParam) {
1340-
return \.singleParam
1341-
}
1342-
if root.is(\.multipleWithLabels) {
1343-
return \.multipleWithLabels
1344-
}
1345-
return \.never
1300+
"""
1301+
@CasePathable enum Action {
1302+
case exampleAction(
1303+
param1: String,
1304+
param2: String,
1305+
param3: String,
1306+
)
1307+
case singleParam(
1308+
value: Int,
1309+
)
1310+
case multipleWithLabels(
1311+
first: String,
1312+
second: Bool,
1313+
third: Double,
1314+
)
13461315
}
1347-
public var exampleAction: CasePaths.AnyCasePath<Action, (param1: String,
1316+
"""
1317+
} expansion: {
1318+
#"""
1319+
enum Action {
1320+
case exampleAction(
1321+
param1: String,
13481322
param2: String,
1349-
param3: String)> {
1350-
._$embed(Action.exampleAction) {
1351-
guard case let .exampleAction(v0, v1, v2) = $0 else {
1352-
return nil
1323+
param3: String,
1324+
)
1325+
case singleParam(
1326+
value: Int,
1327+
)
1328+
case multipleWithLabels(
1329+
first: String,
1330+
second: Bool,
1331+
third: Double,
1332+
)
1333+
1334+
public struct AllCasePaths: CasePaths.CasePathReflectable, Swift.Sendable, Swift.Sequence {
1335+
public subscript(root: Action) -> CasePaths.PartialCaseKeyPath<Action> {
1336+
if root.is(\.exampleAction) {
1337+
return \.exampleAction
1338+
}
1339+
if root.is(\.singleParam) {
1340+
return \.singleParam
1341+
}
1342+
if root.is(\.multipleWithLabels) {
1343+
return \.multipleWithLabels
1344+
}
1345+
return \.never
13531346
}
1354-
return (v0, v1, v2)
1355-
}
1356-
}
1357-
public var singleParam: CasePaths.AnyCasePath<Action, Int> {
1358-
._$embed(Action.singleParam) {
1359-
guard case let .singleParam(v0) = $0 else {
1360-
return nil
1347+
public var exampleAction: CasePaths.AnyCasePath<Action, (param1: String,
1348+
param2: String,
1349+
param3: String)> {
1350+
._$embed(Action.exampleAction) {
1351+
guard case let .exampleAction(v0, v1, v2) = $0 else {
1352+
return nil
1353+
}
1354+
return (v0, v1, v2)
1355+
}
13611356
}
1362-
return v0
1363-
}
1364-
}
1365-
public var multipleWithLabels: CasePaths.AnyCasePath<Action, (first: String,
1366-
second: Bool,
1367-
third: Double)> {
1368-
._$embed(Action.multipleWithLabels) {
1369-
guard case let .multipleWithLabels(v0, v1, v2) = $0 else {
1370-
return nil
1357+
public var singleParam: CasePaths.AnyCasePath<Action, Int> {
1358+
._$embed(Action.singleParam) {
1359+
guard case let .singleParam(v0) = $0 else {
1360+
return nil
1361+
}
1362+
return v0
1363+
}
1364+
}
1365+
public var multipleWithLabels: CasePaths.AnyCasePath<Action, (first: String,
1366+
second: Bool,
1367+
third: Double)> {
1368+
._$embed(Action.multipleWithLabels) {
1369+
guard case let .multipleWithLabels(v0, v1, v2) = $0 else {
1370+
return nil
1371+
}
1372+
return (v0, v1, v2)
1373+
}
1374+
}
1375+
public func makeIterator() -> Swift.IndexingIterator<[CasePaths.PartialCaseKeyPath<Action>]> {
1376+
var allCasePaths: [CasePaths.PartialCaseKeyPath<Action>] = []
1377+
allCasePaths.append(\.exampleAction)
1378+
allCasePaths.append(\.singleParam)
1379+
allCasePaths.append(\.multipleWithLabels)
1380+
return allCasePaths.makeIterator()
13711381
}
1372-
return (v0, v1, v2)
13731382
}
1383+
public static var allCasePaths: AllCasePaths { AllCasePaths() }
13741384
}
1375-
public func makeIterator() -> Swift.IndexingIterator<[CasePaths.PartialCaseKeyPath<Action>]> {
1376-
var allCasePaths: [CasePaths.PartialCaseKeyPath<Action>] = []
1377-
allCasePaths.append(\.exampleAction)
1378-
allCasePaths.append(\.singleParam)
1379-
allCasePaths.append(\.multipleWithLabels)
1380-
return allCasePaths.makeIterator()
1385+
1386+
extension Action: CasePaths.CasePathable, CasePaths.CasePathIterable {
13811387
}
1382-
}
1383-
public static var allCasePaths: AllCasePaths { AllCasePaths() }
1384-
}
1385-
1386-
extension Action: CasePaths.CasePathable, CasePaths.CasePathIterable {
1387-
}
1388-
"""#
1388+
"""#
13891389
}
13901390
}
13911391

0 commit comments

Comments
 (0)