@@ -8978,6 +8978,255 @@ extension GenericParameterListSyntax: BidirectionalCollection {
89788978 }
89798979}
89808980
8981+ /// `PrimaryAssociatedTypeListSyntax` represents a collection of one or more
8982+ /// `PrimaryAssociatedTypeSyntax` nodes. PrimaryAssociatedTypeListSyntax behaves
8983+ /// as a regular Swift collection, and has accessors that return new
8984+ /// versions of the collection with different children.
8985+ public struct PrimaryAssociatedTypeListSyntax : SyntaxCollection , SyntaxHashable {
8986+ public let _syntaxNode : Syntax
8987+
8988+ /// Converts the given `Syntax` node to a `PrimaryAssociatedTypeListSyntax` if possible. Returns
8989+ /// `nil` if the conversion is not possible.
8990+ public init ? ( _ syntax: Syntax ) {
8991+ guard syntax. raw. kind == . primaryAssociatedTypeList else { return nil }
8992+ self . _syntaxNode = syntax
8993+ }
8994+
8995+ /// Creates a Syntax node from the provided root and data. This assumes
8996+ /// that the `SyntaxData` is of the correct kind. If it is not, the behaviour
8997+ /// is undefined.
8998+ internal init ( _ data: SyntaxData ) {
8999+ assert ( data. raw. kind == . primaryAssociatedTypeList)
9000+ self . _syntaxNode = Syntax ( data)
9001+ }
9002+
9003+ public var syntaxNodeType : SyntaxProtocol . Type {
9004+ return Swift . type ( of: self )
9005+ }
9006+
9007+ /// The number of elements, `present` or `missing`, in this collection.
9008+ public var count : Int { return raw. numberOfChildren }
9009+
9010+ /// Creates a new `PrimaryAssociatedTypeListSyntax` by replacing the underlying layout with
9011+ /// a different set of raw syntax nodes.
9012+ ///
9013+ /// - Parameter layout: The new list of raw syntax nodes underlying this
9014+ /// collection.
9015+ /// - Returns: A new `PrimaryAssociatedTypeListSyntax` with the new layout underlying it.
9016+ internal func replacingLayout(
9017+ _ layout: [ RawSyntax ? ] ) -> PrimaryAssociatedTypeListSyntax {
9018+ let newRaw = data. raw. replacingLayout ( layout)
9019+ let newData = data. replacingSelf ( newRaw)
9020+ return PrimaryAssociatedTypeListSyntax ( newData)
9021+ }
9022+
9023+ /// Creates a new `PrimaryAssociatedTypeListSyntax` by appending the provided syntax element
9024+ /// to the children.
9025+ ///
9026+ /// - Parameter syntax: The element to append.
9027+ /// - Returns: A new `PrimaryAssociatedTypeListSyntax` with that element appended to the end.
9028+ public func appending(
9029+ _ syntax: PrimaryAssociatedTypeSyntax ) -> PrimaryAssociatedTypeListSyntax {
9030+ var newLayout = data. raw. formLayoutArray ( )
9031+ newLayout. append ( syntax. raw)
9032+ return replacingLayout ( newLayout)
9033+ }
9034+
9035+ /// Creates a new `PrimaryAssociatedTypeListSyntax` by prepending the provided syntax element
9036+ /// to the children.
9037+ ///
9038+ /// - Parameter syntax: The element to prepend.
9039+ /// - Returns: A new `PrimaryAssociatedTypeListSyntax` with that element prepended to the
9040+ /// beginning.
9041+ public func prepending(
9042+ _ syntax: PrimaryAssociatedTypeSyntax ) -> PrimaryAssociatedTypeListSyntax {
9043+ return inserting ( syntax, at: 0 )
9044+ }
9045+
9046+ /// Creates a new `PrimaryAssociatedTypeListSyntax` by inserting the provided syntax element
9047+ /// at the provided index in the children.
9048+ ///
9049+ /// - Parameters:
9050+ /// - syntax: The element to insert.
9051+ /// - index: The index at which to insert the element in the collection.
9052+ ///
9053+ /// - Returns: A new `PrimaryAssociatedTypeListSyntax` with that element appended to the end.
9054+ public func inserting( _ syntax: PrimaryAssociatedTypeSyntax ,
9055+ at index: Int ) -> PrimaryAssociatedTypeListSyntax {
9056+ var newLayout = data. raw. formLayoutArray ( )
9057+ /// Make sure the index is a valid insertion index (0 to 1 past the end)
9058+ precondition ( ( newLayout. startIndex... newLayout. endIndex) . contains ( index) ,
9059+ " inserting node at invalid index \( index) " )
9060+ newLayout. insert ( syntax. raw, at: index)
9061+ return replacingLayout ( newLayout)
9062+ }
9063+
9064+ /// Creates a new `PrimaryAssociatedTypeListSyntax` by replacing the syntax element
9065+ /// at the provided index.
9066+ ///
9067+ /// - Parameters:
9068+ /// - index: The index at which to replace the element in the collection.
9069+ /// - syntax: The element to replace with.
9070+ ///
9071+ /// - Returns: A new `PrimaryAssociatedTypeListSyntax` with the new element at the provided index.
9072+ public func replacing( childAt index: Int ,
9073+ with syntax: PrimaryAssociatedTypeSyntax ) -> PrimaryAssociatedTypeListSyntax {
9074+ var newLayout = data. raw. formLayoutArray ( )
9075+ /// Make sure the index is a valid index for replacing
9076+ precondition ( ( newLayout. startIndex..< newLayout. endIndex) . contains ( index) ,
9077+ " replacing node at invalid index \( index) " )
9078+ newLayout [ index] = syntax. raw
9079+ return replacingLayout ( newLayout)
9080+ }
9081+
9082+ /// Creates a new `PrimaryAssociatedTypeListSyntax` by removing the syntax element at the
9083+ /// provided index.
9084+ ///
9085+ /// - Parameter index: The index of the element to remove from the collection.
9086+ /// - Returns: A new `PrimaryAssociatedTypeListSyntax` with the element at the provided index
9087+ /// removed.
9088+ public func removing( childAt index: Int ) -> PrimaryAssociatedTypeListSyntax {
9089+ var newLayout = data. raw. formLayoutArray ( )
9090+ newLayout. remove ( at: index)
9091+ return replacingLayout ( newLayout)
9092+ }
9093+
9094+ /// Creates a new `PrimaryAssociatedTypeListSyntax` by removing the first element.
9095+ ///
9096+ /// - Returns: A new `PrimaryAssociatedTypeListSyntax` with the first element removed.
9097+ public func removingFirst( ) -> PrimaryAssociatedTypeListSyntax {
9098+ var newLayout = data. raw. formLayoutArray ( )
9099+ newLayout. removeFirst ( )
9100+ return replacingLayout ( newLayout)
9101+ }
9102+
9103+ /// Creates a new `PrimaryAssociatedTypeListSyntax` by removing the last element.
9104+ ///
9105+ /// - Returns: A new `PrimaryAssociatedTypeListSyntax` with the last element removed.
9106+ public func removingLast( ) -> PrimaryAssociatedTypeListSyntax {
9107+ var newLayout = data. raw. formLayoutArray ( )
9108+ newLayout. removeLast ( )
9109+ return replacingLayout ( newLayout)
9110+ }
9111+
9112+ /// Returns a new `PrimaryAssociatedTypeListSyntax` with its leading trivia replaced
9113+ /// by the provided trivia.
9114+ public func withLeadingTrivia( _ leadingTrivia: Trivia ) -> PrimaryAssociatedTypeListSyntax {
9115+ return PrimaryAssociatedTypeListSyntax ( data. withLeadingTrivia ( leadingTrivia) )
9116+ }
9117+
9118+ /// Returns a new `PrimaryAssociatedTypeListSyntax` with its trailing trivia replaced
9119+ /// by the provided trivia.
9120+ public func withTrailingTrivia( _ trailingTrivia: Trivia ) -> PrimaryAssociatedTypeListSyntax {
9121+ return PrimaryAssociatedTypeListSyntax ( data. withTrailingTrivia ( trailingTrivia) )
9122+ }
9123+
9124+ /// Returns a new `PrimaryAssociatedTypeListSyntax` with its leading trivia removed.
9125+ public func withoutLeadingTrivia( ) -> PrimaryAssociatedTypeListSyntax {
9126+ return withLeadingTrivia ( [ ] )
9127+ }
9128+
9129+ /// Returns a new `PrimaryAssociatedTypeListSyntax` with its trailing trivia removed.
9130+ public func withoutTrailingTrivia( ) -> PrimaryAssociatedTypeListSyntax {
9131+ return withTrailingTrivia ( [ ] )
9132+ }
9133+
9134+ /// Returns a new `PrimaryAssociatedTypeListSyntax` with all trivia removed.
9135+ public func withoutTrivia( ) -> PrimaryAssociatedTypeListSyntax {
9136+ return withoutLeadingTrivia ( ) . withoutTrailingTrivia ( )
9137+ }
9138+
9139+ /// The leading trivia (spaces, newlines, etc.) associated with this `PrimaryAssociatedTypeListSyntax`.
9140+ public var leadingTrivia : Trivia ? {
9141+ get {
9142+ return raw. formLeadingTrivia ( )
9143+ }
9144+ set {
9145+ self = withLeadingTrivia ( newValue ?? [ ] )
9146+ }
9147+ }
9148+
9149+ /// The trailing trivia (spaces, newlines, etc.) associated with this `PrimaryAssociatedTypeListSyntax`.
9150+ public var trailingTrivia : Trivia ? {
9151+ get {
9152+ return raw. formTrailingTrivia ( )
9153+ }
9154+ set {
9155+ self = withTrailingTrivia ( newValue ?? [ ] )
9156+ }
9157+ }
9158+
9159+ public func _validateLayout( ) {
9160+ // Check that all children match the expected element type
9161+ assert ( self . allSatisfy { node in
9162+ return Syntax ( node) . is ( PrimaryAssociatedTypeSyntax . self)
9163+ } )
9164+ }
9165+ }
9166+
9167+ /// Conformance for `PrimaryAssociatedTypeListSyntax` to the `BidirectionalCollection` protocol.
9168+ extension PrimaryAssociatedTypeListSyntax : BidirectionalCollection {
9169+ public typealias Element = PrimaryAssociatedTypeSyntax
9170+ public typealias Index = SyntaxChildrenIndex
9171+
9172+ public struct Iterator : IteratorProtocol {
9173+ private let parent : Syntax
9174+ private var iterator : RawSyntaxChildren . Iterator
9175+
9176+ init ( parent: Syntax , rawChildren: RawSyntaxChildren ) {
9177+ self . parent = parent
9178+ self . iterator = rawChildren. makeIterator ( )
9179+ }
9180+
9181+ public mutating func next( ) -> PrimaryAssociatedTypeSyntax ? {
9182+ guard let ( raw, info) = self . iterator. next ( ) else {
9183+ return nil
9184+ }
9185+ let absoluteRaw = AbsoluteRawSyntax ( raw: raw!, info: info)
9186+ let data = SyntaxData ( absoluteRaw, parent: parent)
9187+ return PrimaryAssociatedTypeSyntax ( data)
9188+ }
9189+ }
9190+
9191+ public func makeIterator( ) -> Iterator {
9192+ return Iterator ( parent: Syntax ( self ) , rawChildren: rawChildren)
9193+ }
9194+
9195+ private var rawChildren : RawSyntaxChildren {
9196+ // We know children in a syntax collection cannot be missing. So we can
9197+ // use the low-level and faster RawSyntaxChildren collection instead of
9198+ // PresentRawSyntaxChildren.
9199+ return RawSyntaxChildren ( self . data. absoluteRaw)
9200+ }
9201+
9202+ public var startIndex : SyntaxChildrenIndex {
9203+ return rawChildren. startIndex
9204+ }
9205+ public var endIndex : SyntaxChildrenIndex {
9206+ return rawChildren. endIndex
9207+ }
9208+
9209+ public func index( after index: SyntaxChildrenIndex ) -> SyntaxChildrenIndex {
9210+ return rawChildren. index ( after: index)
9211+ }
9212+
9213+ public func index( before index: SyntaxChildrenIndex ) -> SyntaxChildrenIndex {
9214+ return rawChildren. index ( before: index)
9215+ }
9216+
9217+ public func distance( from start: SyntaxChildrenIndex , to end: SyntaxChildrenIndex )
9218+ -> Int {
9219+ return rawChildren. distance ( from: start, to: end)
9220+ }
9221+
9222+ public subscript( position: SyntaxChildrenIndex ) -> PrimaryAssociatedTypeSyntax {
9223+ let ( raw, info) = rawChildren [ position]
9224+ let absoluteRaw = AbsoluteRawSyntax ( raw: raw!, info: info)
9225+ let data = SyntaxData ( absoluteRaw, parent: Syntax ( self ) )
9226+ return PrimaryAssociatedTypeSyntax ( data)
9227+ }
9228+ }
9229+
89819230/// `CompositionTypeElementListSyntax` represents a collection of one or more
89829231/// `CompositionTypeElementSyntax` nodes. CompositionTypeElementListSyntax behaves
89839232/// as a regular Swift collection, and has accessors that return new
@@ -10403,6 +10652,11 @@ extension GenericParameterListSyntax: CustomReflectable {
1040310652 return Mirror ( self , unlabeledChildren: self . map { $0 } )
1040410653 }
1040510654}
10655+ extension PrimaryAssociatedTypeListSyntax : CustomReflectable {
10656+ public var customMirror : Mirror {
10657+ return Mirror ( self , unlabeledChildren: self . map { $0 } )
10658+ }
10659+ }
1040610660extension CompositionTypeElementListSyntax : CustomReflectable {
1040710661 public var customMirror : Mirror {
1040810662 return Mirror ( self , unlabeledChildren: self . map { $0 } )
0 commit comments