@@ -1503,6 +1503,7 @@ extension ClosureParamSyntax: CustomReflectable {
1503
1503
1504
1504
public struct ClosureSignatureSyntax : SyntaxProtocol , SyntaxHashable {
1505
1505
enum Cursor : Int {
1506
+ case attributes
1506
1507
case capture
1507
1508
case input
1508
1509
case asyncKeyword
@@ -1532,6 +1533,47 @@ public struct ClosureSignatureSyntax: SyntaxProtocol, SyntaxHashable {
1532
1533
return Swift . type ( of: self )
1533
1534
}
1534
1535
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
+
1535
1577
public var capture : ClosureCaptureSignatureSyntax ? {
1536
1578
get {
1537
1579
let childData = data. child ( at: Cursor . capture,
@@ -1666,30 +1708,30 @@ public struct ClosureSignatureSyntax: SyntaxProtocol, SyntaxHashable {
1666
1708
1667
1709
public func _validateLayout( ) {
1668
1710
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
1671
1713
if let raw = rawChildren [ 0 ] . raw {
1672
1714
let info = rawChildren [ 0 ] . syntaxInfo
1673
1715
let absoluteRaw = AbsoluteRawSyntax ( raw: raw, info: info)
1674
1716
let syntaxData = SyntaxData ( absoluteRaw, parent: Syntax ( self ) )
1675
1717
let syntaxChild = Syntax ( syntaxData)
1676
- assert ( syntaxChild. is ( ClosureCaptureSignatureSyntax . self) )
1718
+ assert ( syntaxChild. is ( AttributeListSyntax . self) )
1677
1719
}
1678
- // Check child #1 child is Syntax or missing
1720
+ // Check child #1 child is ClosureCaptureSignatureSyntax or missing
1679
1721
if let raw = rawChildren [ 1 ] . raw {
1680
1722
let info = rawChildren [ 1 ] . syntaxInfo
1681
1723
let absoluteRaw = AbsoluteRawSyntax ( raw: raw, info: info)
1682
1724
let syntaxData = SyntaxData ( absoluteRaw, parent: Syntax ( self ) )
1683
1725
let syntaxChild = Syntax ( syntaxData)
1684
- assert ( syntaxChild. is ( Syntax . self) )
1726
+ assert ( syntaxChild. is ( ClosureCaptureSignatureSyntax . self) )
1685
1727
}
1686
- // Check child #2 child is TokenSyntax or missing
1728
+ // Check child #2 child is Syntax or missing
1687
1729
if let raw = rawChildren [ 2 ] . raw {
1688
1730
let info = rawChildren [ 2 ] . syntaxInfo
1689
1731
let absoluteRaw = AbsoluteRawSyntax ( raw: raw, info: info)
1690
1732
let syntaxData = SyntaxData ( absoluteRaw, parent: Syntax ( self ) )
1691
1733
let syntaxChild = Syntax ( syntaxData)
1692
- assert ( syntaxChild. is ( TokenSyntax . self) )
1734
+ assert ( syntaxChild. is ( Syntax . self) )
1693
1735
}
1694
1736
// Check child #3 child is TokenSyntax or missing
1695
1737
if let raw = rawChildren [ 3 ] . raw {
@@ -1699,21 +1741,29 @@ public struct ClosureSignatureSyntax: SyntaxProtocol, SyntaxHashable {
1699
1741
let syntaxChild = Syntax ( syntaxData)
1700
1742
assert ( syntaxChild. is ( TokenSyntax . self) )
1701
1743
}
1702
- // Check child #4 child is ReturnClauseSyntax or missing
1744
+ // Check child #4 child is TokenSyntax or missing
1703
1745
if let raw = rawChildren [ 4 ] . raw {
1704
1746
let info = rawChildren [ 4 ] . syntaxInfo
1705
1747
let absoluteRaw = AbsoluteRawSyntax ( raw: raw, info: info)
1706
1748
let syntaxData = SyntaxData ( absoluteRaw, parent: Syntax ( self ) )
1707
1749
let syntaxChild = Syntax ( syntaxData)
1708
- assert ( syntaxChild. is ( ReturnClauseSyntax . self) )
1750
+ assert ( syntaxChild. is ( TokenSyntax . self) )
1709
1751
}
1710
- // Check child #5 child is TokenSyntax
1711
- assert ( rawChildren [ 5 ] . raw != nil )
1752
+ // Check child #5 child is ReturnClauseSyntax or missing
1712
1753
if let raw = rawChildren [ 5 ] . raw {
1713
1754
let info = rawChildren [ 5 ] . syntaxInfo
1714
1755
let absoluteRaw = AbsoluteRawSyntax ( raw: raw, info: info)
1715
1756
let syntaxData = SyntaxData ( absoluteRaw, parent: Syntax ( self ) )
1716
1757
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)
1717
1767
assert ( syntaxChild. is ( TokenSyntax . self) )
1718
1768
}
1719
1769
}
@@ -1722,6 +1772,7 @@ public struct ClosureSignatureSyntax: SyntaxProtocol, SyntaxHashable {
1722
1772
extension ClosureSignatureSyntax : CustomReflectable {
1723
1773
public var customMirror : Mirror {
1724
1774
return Mirror ( self , children: [
1775
+ " attributes " : attributes. map ( Syntax . init) ? . asProtocol ( SyntaxProtocol . self) as Any ,
1725
1776
" capture " : capture. map ( Syntax . init) ? . asProtocol ( SyntaxProtocol . self) as Any ,
1726
1777
" input " : input. map ( Syntax . init) ? . asProtocol ( SyntaxProtocol . self) as Any ,
1727
1778
" asyncKeyword " : asyncKeyword. map ( Syntax . init) ? . asProtocol ( SyntaxProtocol . self) as Any ,
0 commit comments