11// Derived from
2- // https://github.com/pointfreeco/swift-composable-architecture/blob/1.12.1 /Sources/ComposableArchitectureMacros/Extensions.swift
2+ // https://github.com/pointfreeco/swift-composable-architecture/blob/1.22.3 /Sources/ComposableArchitectureMacros/Extensions.swift
33
44//===----------------------------------------------------------------------===//
55//
@@ -43,27 +43,15 @@ extension VariableDeclSyntax {
4343 }
4444
4545 func accessorsMatching( _ predicate: ( TokenKind ) -> Bool ) -> [ AccessorDeclSyntax ] {
46- let patternBindings = bindings. compactMap { binding in
47- binding. as ( PatternBindingSyntax . self)
48- }
49- let accessors : [ AccessorDeclListSyntax . Element ] = patternBindings. compactMap { patternBinding in
46+ let accessors : [ AccessorDeclListSyntax . Element ] = bindings. compactMap { patternBinding in
5047 switch patternBinding. accessorBlock? . accessors {
5148 case . accessors( let accessors) :
5249 accessors
5350 default :
5451 nil
5552 }
5653 } . flatMap { $0 }
57- return accessors. compactMap { accessor in
58- guard let decl = accessor. as ( AccessorDeclSyntax . self) else {
59- return nil
60- }
61- if predicate ( decl. accessorSpecifier. tokenKind) {
62- return decl
63- } else {
64- return nil
65- }
66- }
54+ return accessors. compactMap { predicate ( $0. accessorSpecifier. tokenKind) ? $0 : nil }
6755 }
6856
6957 var willSetAccessors : [ AccessorDeclSyntax ] {
@@ -152,7 +140,7 @@ extension TypeSyntax {
152140 genericParameters [ parameter. name. text] = parameter. inheritedType
153141 }
154142 }
155- var iterator = asProtocol ( TypeSyntaxProtocol . self) . tokens ( viewMode: . sourceAccurate)
143+ var iterator = asProtocol ( ( any TypeSyntaxProtocol ) . self) . tokens ( viewMode: . sourceAccurate)
156144 . makeIterator ( )
157145 guard let base = iterator. next ( ) else {
158146 return nil
@@ -233,7 +221,7 @@ extension DeclGroupSyntax {
233221 var memberFunctionStandins : [ FunctionDeclSyntax . SignatureStandin ] {
234222 var standins = [ FunctionDeclSyntax . SignatureStandin] ( )
235223 for member in memberBlock. members {
236- if let function = member. as ( MemberBlockItemSyntax . self ) ? . decl. as ( FunctionDeclSyntax . self) {
224+ if let function = member. decl. as ( FunctionDeclSyntax . self) {
237225 standins. append ( function. signatureStandin)
238226 }
239227 }
@@ -242,7 +230,7 @@ extension DeclGroupSyntax {
242230
243231 func hasMemberFunction( equvalentTo other: FunctionDeclSyntax ) -> Bool {
244232 for member in memberBlock. members {
245- if let function = member. as ( MemberBlockItemSyntax . self ) ? . decl. as ( FunctionDeclSyntax . self) {
233+ if let function = member. decl. as ( FunctionDeclSyntax . self) {
246234 if function. isEquivalent ( to: other) {
247235 return true
248236 }
@@ -253,7 +241,7 @@ extension DeclGroupSyntax {
253241
254242 func hasMemberProperty( equivalentTo other: VariableDeclSyntax ) -> Bool {
255243 for member in memberBlock. members {
256- if let variable = member. as ( MemberBlockItemSyntax . self ) ? . decl. as ( VariableDeclSyntax . self) {
244+ if let variable = member. decl. as ( VariableDeclSyntax . self) {
257245 if variable. isEquivalent ( to: other) {
258246 return true
259247 }
@@ -264,7 +252,7 @@ extension DeclGroupSyntax {
264252
265253 var definedVariables : [ VariableDeclSyntax ] {
266254 memberBlock. members. compactMap { member in
267- if let variableDecl = member. as ( MemberBlockItemSyntax . self ) ? . decl. as ( VariableDeclSyntax . self) {
255+ if let variableDecl = member. decl. as ( VariableDeclSyntax . self) {
268256 return variableDecl
269257 }
270258 return nil
@@ -300,3 +288,15 @@ extension DeclGroupSyntax {
300288 self . is ( StructDeclSyntax . self)
301289 }
302290}
291+
292+ extension AttributedTypeSyntax {
293+ var isInout : Bool {
294+ #if canImport(SwiftSyntax600)
295+ specifiers. contains (
296+ where: { $0. as ( SimpleTypeSpecifierSyntax . self) ? . specifier. tokenKind == . keyword( . inout) }
297+ ) == true
298+ #else
299+ specifier? . tokenKind == . keyword( . inout)
300+ #endif
301+ }
302+ }
0 commit comments