@@ -1503,6 +1503,7 @@ extension ClosureParamSyntax: CustomReflectable {
15031503
15041504public struct ClosureSignatureSyntax : SyntaxProtocol , SyntaxHashable {
15051505 enum Cursor : Int {
1506+ case attributes
15061507 case capture
15071508 case input
15081509 case asyncKeyword
@@ -1532,6 +1533,47 @@ public struct ClosureSignatureSyntax: SyntaxProtocol, SyntaxHashable {
15321533 return Swift . type ( of: self )
15331534 }
15341535
1536+ public var attributes : AttributeListSyntax ? {
1537+ get {
1538+ let childData = data. child ( at: Cursor . attributes,
1539+ parent: Syntax ( self ) )
1540+ if childData == nil { return nil }
1541+ return AttributeListSyntax ( childData!)
1542+ }
1543+ set ( value) {
1544+ self = withAttributes ( value)
1545+ }
1546+ }
1547+
1548+ /// Adds the provided `Attribute` to the node's `attributes`
1549+ /// collection.
1550+ /// - param element: The new `Attribute` to add to the node's
1551+ /// `attributes` collection.
1552+ /// - returns: A copy of the receiver with the provided `Attribute`
1553+ /// appended to its `attributes` collection.
1554+ public func addAttribute( _ element: Syntax ) -> ClosureSignatureSyntax {
1555+ var collection : RawSyntax
1556+ if let col = raw [ Cursor . attributes] {
1557+ collection = col. appending ( element. raw)
1558+ } else {
1559+ collection = RawSyntax . create ( kind: SyntaxKind . attributeList,
1560+ layout: [ element. raw] , length: element. raw. totalLength, presence: . present)
1561+ }
1562+ let newData = data. replacingChild ( collection,
1563+ at: Cursor . attributes)
1564+ return ClosureSignatureSyntax ( newData)
1565+ }
1566+
1567+ /// Returns a copy of the receiver with its `attributes` replaced.
1568+ /// - param newChild: The new `attributes` to replace the node's
1569+ /// current `attributes`, if present.
1570+ public func withAttributes(
1571+ _ newChild: AttributeListSyntax ? ) -> ClosureSignatureSyntax {
1572+ let raw = newChild? . raw
1573+ let newData = data. replacingChild ( raw, at: Cursor . attributes)
1574+ return ClosureSignatureSyntax ( newData)
1575+ }
1576+
15351577 public var capture : ClosureCaptureSignatureSyntax ? {
15361578 get {
15371579 let childData = data. child ( at: Cursor . capture,
@@ -1666,30 +1708,30 @@ public struct ClosureSignatureSyntax: SyntaxProtocol, SyntaxHashable {
16661708
16671709 public func _validateLayout( ) {
16681710 let rawChildren = Array ( RawSyntaxChildren ( Syntax ( self ) ) )
1669- assert ( rawChildren. count == 6 )
1670- // Check child #0 child is ClosureCaptureSignatureSyntax or missing
1711+ assert ( rawChildren. count == 7 )
1712+ // Check child #0 child is AttributeListSyntax or missing
16711713 if let raw = rawChildren [ 0 ] . raw {
16721714 let info = rawChildren [ 0 ] . syntaxInfo
16731715 let absoluteRaw = AbsoluteRawSyntax ( raw: raw, info: info)
16741716 let syntaxData = SyntaxData ( absoluteRaw, parent: Syntax ( self ) )
16751717 let syntaxChild = Syntax ( syntaxData)
1676- assert ( syntaxChild. is ( ClosureCaptureSignatureSyntax . self) )
1718+ assert ( syntaxChild. is ( AttributeListSyntax . self) )
16771719 }
1678- // Check child #1 child is Syntax or missing
1720+ // Check child #1 child is ClosureCaptureSignatureSyntax or missing
16791721 if let raw = rawChildren [ 1 ] . raw {
16801722 let info = rawChildren [ 1 ] . syntaxInfo
16811723 let absoluteRaw = AbsoluteRawSyntax ( raw: raw, info: info)
16821724 let syntaxData = SyntaxData ( absoluteRaw, parent: Syntax ( self ) )
16831725 let syntaxChild = Syntax ( syntaxData)
1684- assert ( syntaxChild. is ( Syntax . self) )
1726+ assert ( syntaxChild. is ( ClosureCaptureSignatureSyntax . self) )
16851727 }
1686- // Check child #2 child is TokenSyntax or missing
1728+ // Check child #2 child is Syntax or missing
16871729 if let raw = rawChildren [ 2 ] . raw {
16881730 let info = rawChildren [ 2 ] . syntaxInfo
16891731 let absoluteRaw = AbsoluteRawSyntax ( raw: raw, info: info)
16901732 let syntaxData = SyntaxData ( absoluteRaw, parent: Syntax ( self ) )
16911733 let syntaxChild = Syntax ( syntaxData)
1692- assert ( syntaxChild. is ( TokenSyntax . self) )
1734+ assert ( syntaxChild. is ( Syntax . self) )
16931735 }
16941736 // Check child #3 child is TokenSyntax or missing
16951737 if let raw = rawChildren [ 3 ] . raw {
@@ -1699,21 +1741,29 @@ public struct ClosureSignatureSyntax: SyntaxProtocol, SyntaxHashable {
16991741 let syntaxChild = Syntax ( syntaxData)
17001742 assert ( syntaxChild. is ( TokenSyntax . self) )
17011743 }
1702- // Check child #4 child is ReturnClauseSyntax or missing
1744+ // Check child #4 child is TokenSyntax or missing
17031745 if let raw = rawChildren [ 4 ] . raw {
17041746 let info = rawChildren [ 4 ] . syntaxInfo
17051747 let absoluteRaw = AbsoluteRawSyntax ( raw: raw, info: info)
17061748 let syntaxData = SyntaxData ( absoluteRaw, parent: Syntax ( self ) )
17071749 let syntaxChild = Syntax ( syntaxData)
1708- assert ( syntaxChild. is ( ReturnClauseSyntax . self) )
1750+ assert ( syntaxChild. is ( TokenSyntax . self) )
17091751 }
1710- // Check child #5 child is TokenSyntax
1711- assert ( rawChildren [ 5 ] . raw != nil )
1752+ // Check child #5 child is ReturnClauseSyntax or missing
17121753 if let raw = rawChildren [ 5 ] . raw {
17131754 let info = rawChildren [ 5 ] . syntaxInfo
17141755 let absoluteRaw = AbsoluteRawSyntax ( raw: raw, info: info)
17151756 let syntaxData = SyntaxData ( absoluteRaw, parent: Syntax ( self ) )
17161757 let syntaxChild = Syntax ( syntaxData)
1758+ assert ( syntaxChild. is ( ReturnClauseSyntax . self) )
1759+ }
1760+ // Check child #6 child is TokenSyntax
1761+ assert ( rawChildren [ 6 ] . raw != nil )
1762+ if let raw = rawChildren [ 6 ] . raw {
1763+ let info = rawChildren [ 6 ] . syntaxInfo
1764+ let absoluteRaw = AbsoluteRawSyntax ( raw: raw, info: info)
1765+ let syntaxData = SyntaxData ( absoluteRaw, parent: Syntax ( self ) )
1766+ let syntaxChild = Syntax ( syntaxData)
17171767 assert ( syntaxChild. is ( TokenSyntax . self) )
17181768 }
17191769 }
@@ -1722,6 +1772,7 @@ public struct ClosureSignatureSyntax: SyntaxProtocol, SyntaxHashable {
17221772extension ClosureSignatureSyntax : CustomReflectable {
17231773 public var customMirror : Mirror {
17241774 return Mirror ( self , children: [
1775+ " attributes " : attributes. map ( Syntax . init) ? . asProtocol ( SyntaxProtocol . self) as Any ,
17251776 " capture " : capture. map ( Syntax . init) ? . asProtocol ( SyntaxProtocol . self) as Any ,
17261777 " input " : input. map ( Syntax . init) ? . asProtocol ( SyntaxProtocol . self) as Any ,
17271778 " asyncKeyword " : asyncKeyword. map ( Syntax . init) ? . asProtocol ( SyntaxProtocol . self) as Any ,
0 commit comments