@@ -25,7 +25,8 @@ extension ReducerMacro: ExtensionMacro {
2525 {
2626 return [ ]
2727 }
28- let proto = declaration. isEnum
28+ let proto =
29+ declaration. isEnum
2930 ? " ComposableArchitecture.CaseReducer, ComposableArchitecture.Reducer "
3031 : " ComposableArchitecture.Reducer "
3132 let ext : DeclSyntax =
@@ -132,7 +133,8 @@ extension ReducerMacro: MemberAttributeMacro {
132133 !attributeName. starts ( with: " ComposableArchitecture.ReducerBuilder " )
133134 else { return [ ] }
134135 }
135- let genericArguments = genericArguments. count == 1
136+ let genericArguments =
137+ genericArguments. count == 1
136138 ? " \( genericArguments. description) .State, \( genericArguments. description) .Action "
137139 : " \( genericArguments) "
138140 return [
@@ -176,8 +178,8 @@ extension ReducerMacro: MemberAttributeMacro {
176178 }
177179}
178180
179- private extension IdentifierTypeSyntax {
180- var isEphemeral : Bool {
181+ extension IdentifierTypeSyntax {
182+ fileprivate var isEphemeral : Bool {
181183 self . name. text == " AlertState " || self . name. text == " ConfirmationDialogState "
182184 }
183185}
@@ -215,20 +217,23 @@ extension ReducerMacro: MemberMacro {
215217 }
216218 return true
217219 }
218- let hasExplicitReducerBody = bindings. contains {
219- guard $0. initializer == nil
220- else { return true }
221- guard let name = $0. typeAnnotation? . type. as ( SomeOrAnyTypeSyntax . self) ? . constraint
222- . as ( IdentifierTypeSyntax . self) ? . name. text
223- else {
224- return false
225- }
226- return [ " Reducer " , " ReducerOf " ] . withQualified. contains ( name)
227- } || hasReduceMethod
228- let hasBody = bindings. contains {
229- $0. as ( PatternBindingSyntax . self) ? . pattern
230- . as ( IdentifierPatternSyntax . self) ? . identifier. text == " body "
231- } || hasReduceMethod
220+ let hasExplicitReducerBody =
221+ bindings. contains {
222+ guard $0. initializer == nil
223+ else { return true }
224+ guard
225+ let name = $0. typeAnnotation? . type. as ( SomeOrAnyTypeSyntax . self) ? . constraint
226+ . as ( IdentifierTypeSyntax . self) ? . name. text
227+ else {
228+ return false
229+ }
230+ return [ " Reducer " , " ReducerOf " ] . withQualified. contains ( name)
231+ } || hasReduceMethod
232+ let hasBody =
233+ bindings. contains {
234+ $0. as ( PatternBindingSyntax . self) ? . pattern
235+ . as ( IdentifierPatternSyntax . self) ? . identifier. text == " body "
236+ } || hasReduceMethod
232237 var decls : [ DeclSyntax ] = [ ]
233238 if let enumDecl = declaration. as ( EnumDeclSyntax . self) {
234239 let enumCaseElements = enumDecl. memberBlock
@@ -257,7 +262,8 @@ extension ReducerMacro: MemberMacro {
257262 parameter. type. is ( IdentifierTypeSyntax . self) || parameter. type. is ( MemberTypeSyntax . self)
258263 {
259264 let type = parameter. type
260- let stateCase = enumCaseElement. attribute == . ephemeral
265+ let stateCase =
266+ enumCaseElement. attribute == . ephemeral
261267 ? element
262268 : element. suffixed ( " State " )
263269 stateCaseDecls. append ( " case \( stateCase. trimmedDescription) " )
@@ -311,7 +317,8 @@ extension ReducerMacro: MemberMacro {
311317 if case let . argumentList( arguments) = node. arguments,
312318 let startIndex = arguments. firstIndex ( where: { $0. label? . text == " state " } )
313319 {
314- let endIndex = arguments. firstIndex ( where: { $0. label? . text == " action " } )
320+ let endIndex =
321+ arguments. firstIndex ( where: { $0. label? . text == " action " } )
315322 ?? arguments. endIndex
316323 conformances. append (
317324 contentsOf: arguments [ startIndex..< endIndex] . compactMap {
@@ -400,7 +407,8 @@ extension ReducerMacro: MemberMacro {
400407 fixIt: . replace(
401408 message: MacroExpansionFixItMessage ( " Remove '( \( arguments) )' " ) ,
402409 oldNode: node,
403- newNode: node
410+ newNode:
411+ node
404412 . with ( \. leftParen, nil )
405413 . with ( \. arguments, nil )
406414 . with ( \. rightParen, nil )
@@ -487,8 +495,8 @@ private final class ReduceVisitor: SyntaxVisitor {
487495 }
488496}
489497
490- private extension EnumCaseDeclSyntax {
491- var attribute : ReducerCase . Attribute ? {
498+ extension EnumCaseDeclSyntax {
499+ fileprivate var attribute : ReducerCase . Attribute ? {
492500 if self . isIgnored {
493501 return . ignored
494502 } else if self . isEphemeral {
@@ -498,12 +506,12 @@ private extension EnumCaseDeclSyntax {
498506 }
499507 }
500508
501- var isIgnored : Bool {
509+ fileprivate var isIgnored : Bool {
502510 self . attributes. contains ( " ReducerCaseIgnored " )
503511 || self . elements. contains { $0. parameterClause? . parameters. count != 1 }
504512 }
505513
506- var isEphemeral : Bool {
514+ fileprivate var isEphemeral : Bool {
507515 self . attributes. contains ( " ReducerCaseEphemeral " )
508516 || self . elements. contains {
509517 guard
@@ -517,8 +525,8 @@ private extension EnumCaseDeclSyntax {
517525 }
518526}
519527
520- private extension EnumCaseElementSyntax {
521- func suffixed( _ suffix: TokenSyntax ) -> Self {
528+ extension EnumCaseElementSyntax {
529+ fileprivate func suffixed( _ suffix: TokenSyntax ) -> Self {
522530 var element = self
523531 if var parameterClause = element. parameterClause,
524532 let type = parameterClause. parameters. first? . type
@@ -531,8 +539,8 @@ private extension EnumCaseElementSyntax {
531539 }
532540}
533541
534- private extension AttributeListSyntax {
535- func contains( _ name: TokenSyntax ) -> Bool {
542+ extension AttributeListSyntax {
543+ fileprivate func contains( _ name: TokenSyntax ) -> Bool {
536544 self . contains {
537545 guard
538546 case let . attribute( attribute) = $0,
0 commit comments