diff --git a/CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift b/CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift index 4920cc7af98..8b3d8e0277d 100644 --- a/CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift +++ b/CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift @@ -168,14 +168,23 @@ public let EXPR_NODES: [Node] = [ kind: .awaitExpr, base: .expr, nameForDiagnostics: "'await' expression", + documentation: """ + An expression prefixed with `await` to suspend execution until an asynchronous operation completes. + + ```swift + let data = await fetchData() + ``` + """, children: [ Child( name: "awaitKeyword", - kind: .token(choices: [.keyword(.await)]) + kind: .token(choices: [.keyword(.await)]), + documentation: "The `await` keyword." ), Child( name: "expression", - kind: .node(kind: .expr) + kind: .node(kind: .expr), + documentation: "The expression that is being awaited." ), ] ), @@ -347,24 +356,38 @@ public let EXPR_NODES: [Node] = [ kind: .closureCaptureSpecifier, base: .syntax, nameForDiagnostics: "closure capture specifier", + documentation: """ + The specifier that indicates the capture semantics of a closure capture item. + + ```swift + { [weak self] in print(self) } + ``` + + In this example, `weak` is the capture specifier for `self`. \ + The specifier can also include a detail such as `unowned(unsafe)`. + """, children: [ Child( name: "specifier", - kind: .token(choices: [.keyword(.weak), .keyword(.unowned)]) + kind: .token(choices: [.keyword(.weak), .keyword(.unowned)]), + documentation: "The capture specifier, either `weak` or `unowned`." ), Child( name: "leftParen", kind: .token(choices: [.token(.leftParen)]), + documentation: "The opening parenthesis for the detail, if present.", isOptional: true ), Child( name: "detail", kind: .token(choices: [.keyword(.safe), .keyword(.unsafe)]), + documentation: "The detail of the capture specifier, either `safe` or `unsafe`.", isOptional: true ), Child( name: "rightParen", kind: .token(choices: [.token(.rightParen)]), + documentation: "The closing parenthesis for the detail, if present.", isOptional: true ), ] @@ -374,6 +397,15 @@ public let EXPR_NODES: [Node] = [ kind: .closureCapture, base: .syntax, nameForDiagnostics: "closure capture", + documentation: """ + A single captured value in a closure's capture list. + + ```swift + { [weak self, x = 42] in } + ``` + + In this example, `weak self` and `x = 42` are each a closure capture. + """, traits: [ "WithTrailingComma" ], @@ -381,20 +413,24 @@ public let EXPR_NODES: [Node] = [ Child( name: "specifier", kind: .node(kind: .closureCaptureSpecifier), + documentation: "The specifier that indicates the capture semantics, if any.", isOptional: true ), Child( name: "name", - kind: .token(choices: [.token(.identifier), .keyword(.self)]) + kind: .token(choices: [.token(.identifier), .keyword(.self)]), + documentation: "The name of the captured variable." ), Child( name: "initializer", kind: .node(kind: .initializerClause), + documentation: "The initializer for the captured value, if any.", isOptional: true ), Child( name: "trailingComma", kind: .token(choices: [.token(.comma)]), + documentation: "A trailing comma if this capture is followed by another capture.", isOptional: true ), ] @@ -404,18 +440,28 @@ public let EXPR_NODES: [Node] = [ kind: .closureCaptureClause, base: .syntax, nameForDiagnostics: "closure capture clause", + documentation: """ + The capture clause of a closure, containing a list of captured values enclosed in square brackets. + + ```swift + { [weak self, unowned delegate] in } + ``` + """, children: [ Child( name: "leftSquare", - kind: .token(choices: [.token(.leftSquare)]) + kind: .token(choices: [.token(.leftSquare)]), + documentation: "The `[` token that opens the capture list." ), Child( name: "items", - kind: .collection(kind: .closureCaptureList, collectionElementName: "Item") + kind: .collection(kind: .closureCaptureList, collectionElementName: "Item"), + documentation: "The list of capture items." ), Child( name: "rightSquare", - kind: .token(choices: [.token(.rightSquare)]) + kind: .token(choices: [.token(.rightSquare)]), + documentation: "The `]` token that closes the capture list." ), ] ), @@ -424,6 +470,18 @@ public let EXPR_NODES: [Node] = [ kind: .closureParameter, base: .syntax, nameForDiagnostics: "parameter", + documentation: """ + A parameter in a closure's parenthesized parameter list, which can include type annotations. + + For example, in: + ```swift + { (x: Int, y: Int) -> Int in + return x + y + } + ``` + + `x: Int` and `y: Int` are each represented by a `ClosureParameterSyntax`. + """, parserFunction: "parseClosureParameter", traits: ["WithTrailingComma", "WithAttributes", "WithModifiers"], children: [ @@ -488,6 +546,16 @@ public let EXPR_NODES: [Node] = [ kind: .closureParameterClause, base: .syntax, nameForDiagnostics: "parameter clause", + documentation: """ + The parenthesized parameter clause of a closure, enclosing typed parameters. + + For example, in: + ```swift + { (x: Int, y: Int) in x + y } + ``` + + `(x: Int, y: Int)` is represented by `ClosureParameterClauseSyntax`. + """, traits: [ "Parenthesized" ], @@ -520,6 +588,18 @@ public let EXPR_NODES: [Node] = [ kind: .closureExpr, base: .expr, nameForDiagnostics: "closure", + documentation: """ + A closure expression. + + For example, in: + ```swift + let doubled = numbers.map { [weak self] x -> Int in + return x * 2 + } + ``` + + `{ [weak self] x -> Int in return x * 2 }` is represented by `ClosureExprSyntax.` + """, traits: [ "Braced", "WithStatements", @@ -527,20 +607,24 @@ public let EXPR_NODES: [Node] = [ children: [ Child( name: "leftBrace", - kind: .token(choices: [.token(.leftBrace)]) + kind: .token(choices: [.token(.leftBrace)]), + documentation: "The `{` that opens the closure body." ), Child( name: "signature", kind: .node(kind: .closureSignature), + documentation: "The signature of the closure, including capture list, parameters, and return type.", isOptional: true ), Child( name: "statements", - kind: .collection(kind: .codeBlockItemList, collectionElementName: "Statement") + kind: .collection(kind: .codeBlockItemList, collectionElementName: "Statement"), + documentation: "The statements that make up the body of the closure." ), Child( name: "rightBrace", - kind: .token(choices: [.token(.rightBrace)]) + kind: .token(choices: [.token(.rightBrace)]), + documentation: "The `}` that closes the closure body." ), ] ), @@ -570,6 +654,15 @@ public let EXPR_NODES: [Node] = [ kind: .closureShorthandParameter, base: .syntax, nameForDiagnostics: "closure parameter", + documentation: """ + A shorthand closure parameter without a type annotation or parentheses. + + ```swift + let sum = numbers.reduce(0) { total, value in total + value } + ``` + + In this example, `total` and `value` are each a shorthand closure parameter. + """, traits: [ "WithTrailingComma" ], @@ -577,11 +670,13 @@ public let EXPR_NODES: [Node] = [ Child( name: "name", kind: .token(choices: [.token(.identifier), .token(.wildcard)]), - nameForDiagnostics: "name" + nameForDiagnostics: "name", + documentation: "The name of the parameter." ), Child( name: "trailingComma", kind: .token(choices: [.token(.comma)]), + documentation: "A trailing comma if this parameter is followed by another parameter.", isOptional: true ), ] @@ -591,6 +686,17 @@ public let EXPR_NODES: [Node] = [ kind: .closureSignature, base: .syntax, nameForDiagnostics: "closure signature", + documentation: """ + The signature of a closure, which specifies its capture list, parameters, and return type. + + ```swift + { [weak self] (x: Int) async throws -> Int in + return x * 2 + } + ``` + + Everything after `{` and up to `in` keyword is part of the closure signature. + """, traits: [ "WithAttributes" ], @@ -598,11 +704,13 @@ public let EXPR_NODES: [Node] = [ Child( name: "attributes", kind: .collection(kind: .attributeList, collectionElementName: "Attribute", defaultsToEmpty: true), - nameForDiagnostics: "attributes" + nameForDiagnostics: "attributes", + documentation: "Attributes attached to the closure signature." ), Child( name: "capture", kind: .node(kind: .closureCaptureClause), + documentation: "The capture list specifying how variables from the surrounding scope are captured.", isOptional: true ), Child( @@ -624,21 +732,25 @@ public let EXPR_NODES: [Node] = [ ] ] ), + documentation: "The parameters of the closure, either shorthand names or a full parameter clause.", isOptional: true ), Child( name: "effectSpecifiers", kind: .node(kind: .typeEffectSpecifiers), + documentation: "The `async` and/or `throws` specifiers of the closure.", isOptional: true ), Child( name: "returnClause", kind: .node(kind: .returnClause), + documentation: "The return type of the closure, if specified.", isOptional: true ), Child( name: "inKeyword", - kind: .token(choices: [.keyword(.in)]) + kind: .token(choices: [.keyword(.in)]), + documentation: "The `in` keyword that separates the signature from the closure body." ), ], childHistory: [ diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesAB.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesAB.swift index acfbe85c452..0e3a63add51 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesAB.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesAB.swift @@ -4923,6 +4923,12 @@ public struct AvailabilityMacroDefinitionFileSyntax: SyntaxProtocol, SyntaxHasha // MARK: - AwaitExprSyntax +/// An expression prefixed with `await` to suspend execution until an asynchronous operation completes. +/// +/// ```swift +/// let data = await fetchData() +/// ``` +/// /// ### Children /// /// - `awaitKeyword`: `await` @@ -4944,6 +4950,8 @@ public struct AwaitExprSyntax: ExprSyntaxProtocol, SyntaxHashable, _LeafExprSynt /// - Parameters: /// - leadingTrivia: Trivia to be prepended to the leading trivia of the node’s first token. If the node is empty, there is no token to attach the trivia to and the parameter is ignored. + /// - awaitKeyword: The `await` keyword. + /// - expression: The expression that is being awaited. /// - trailingTrivia: Trivia to be appended to the trailing trivia of the node’s last token. If the node is empty, there is no token to attach the trivia to and the parameter is ignored. public init( leadingTrivia: Trivia? = nil, @@ -4990,6 +4998,8 @@ public struct AwaitExprSyntax: ExprSyntaxProtocol, SyntaxHashable, _LeafExprSynt } } + /// The `await` keyword. + /// /// ### Tokens /// /// For syntax trees generated by the parser, this is guaranteed to be `await`. @@ -5011,6 +5021,7 @@ public struct AwaitExprSyntax: ExprSyntaxProtocol, SyntaxHashable, _LeafExprSynt } } + /// The expression that is being awaited. public var expression: ExprSyntax { get { return Syntax(self).child(at: 3)!.cast(ExprSyntax.self) diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesC.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesC.swift index 0c1de3f319e..4542a2e19fa 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesC.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesC.swift @@ -1184,6 +1184,12 @@ public struct ClassRestrictionTypeSyntax: TypeSyntaxProtocol, SyntaxHashable, _L // MARK: - ClosureCaptureClauseSyntax +/// The capture clause of a closure, containing a list of captured values enclosed in square brackets. +/// +/// ```swift +/// { [weak self, unowned delegate] in } +/// ``` +/// /// ### Children /// /// - `leftSquare`: `[` @@ -1210,6 +1216,9 @@ public struct ClosureCaptureClauseSyntax: SyntaxProtocol, SyntaxHashable, _LeafS /// - Parameters: /// - leadingTrivia: Trivia to be prepended to the leading trivia of the node’s first token. If the node is empty, there is no token to attach the trivia to and the parameter is ignored. + /// - leftSquare: The `[` token that opens the capture list. + /// - items: The list of capture items. + /// - rightSquare: The `]` token that closes the capture list. /// - trailingTrivia: Trivia to be appended to the trailing trivia of the node’s last token. If the node is empty, there is no token to attach the trivia to and the parameter is ignored. public init( leadingTrivia: Trivia? = nil, @@ -1262,6 +1271,8 @@ public struct ClosureCaptureClauseSyntax: SyntaxProtocol, SyntaxHashable, _LeafS } } + /// The `[` token that opens the capture list. + /// /// ### Tokens /// /// For syntax trees generated by the parser, this is guaranteed to be `[`. @@ -1283,6 +1294,7 @@ public struct ClosureCaptureClauseSyntax: SyntaxProtocol, SyntaxHashable, _LeafS } } + /// The list of capture items. public var items: ClosureCaptureListSyntax { get { return Syntax(self).child(at: 3)!.cast(ClosureCaptureListSyntax.self) @@ -1328,6 +1340,8 @@ public struct ClosureCaptureClauseSyntax: SyntaxProtocol, SyntaxHashable, _LeafS } } + /// The `]` token that closes the capture list. + /// /// ### Tokens /// /// For syntax trees generated by the parser, this is guaranteed to be `]`. @@ -1362,6 +1376,14 @@ public struct ClosureCaptureClauseSyntax: SyntaxProtocol, SyntaxHashable, _LeafS // MARK: - ClosureCaptureSpecifierSyntax +/// The specifier that indicates the capture semantics of a closure capture item. +/// +/// ```swift +/// { [weak self] in print(self) } +/// ``` +/// +/// In this example, `weak` is the capture specifier for `self`. The specifier can also include a detail such as `unowned(unsafe)`. +/// /// ### Children /// /// - `specifier`: (`weak` | `unowned`) @@ -1389,6 +1411,10 @@ public struct ClosureCaptureSpecifierSyntax: SyntaxProtocol, SyntaxHashable, _Le /// - Parameters: /// - leadingTrivia: Trivia to be prepended to the leading trivia of the node’s first token. If the node is empty, there is no token to attach the trivia to and the parameter is ignored. + /// - specifier: The capture specifier, either `weak` or `unowned`. + /// - leftParen: The opening parenthesis for the detail, if present. + /// - detail: The detail of the capture specifier, either `safe` or `unsafe`. + /// - rightParen: The closing parenthesis for the detail, if present. /// - trailingTrivia: Trivia to be appended to the trailing trivia of the node’s last token. If the node is empty, there is no token to attach the trivia to and the parameter is ignored. public init( leadingTrivia: Trivia? = nil, @@ -1447,6 +1473,8 @@ public struct ClosureCaptureSpecifierSyntax: SyntaxProtocol, SyntaxHashable, _Le } } + /// The capture specifier, either `weak` or `unowned`. + /// /// ### Tokens /// /// For syntax trees generated by the parser, this is guaranteed to be one of the following kinds: @@ -1470,6 +1498,8 @@ public struct ClosureCaptureSpecifierSyntax: SyntaxProtocol, SyntaxHashable, _Le } } + /// The opening parenthesis for the detail, if present. + /// /// ### Tokens /// /// For syntax trees generated by the parser, this is guaranteed to be `(`. @@ -1491,6 +1521,8 @@ public struct ClosureCaptureSpecifierSyntax: SyntaxProtocol, SyntaxHashable, _Le } } + /// The detail of the capture specifier, either `safe` or `unsafe`. + /// /// ### Tokens /// /// For syntax trees generated by the parser, this is guaranteed to be one of the following kinds: @@ -1514,6 +1546,8 @@ public struct ClosureCaptureSpecifierSyntax: SyntaxProtocol, SyntaxHashable, _Le } } + /// The closing parenthesis for the detail, if present. + /// /// ### Tokens /// /// For syntax trees generated by the parser, this is guaranteed to be `)`. @@ -1550,6 +1584,14 @@ public struct ClosureCaptureSpecifierSyntax: SyntaxProtocol, SyntaxHashable, _Le // MARK: - ClosureCaptureSyntax +/// A single captured value in a closure's capture list. +/// +/// ```swift +/// { [weak self, x = 42] in } +/// ``` +/// +/// In this example, `weak self` and `x = 42` are each a closure capture. +/// /// ### Children /// /// - `specifier`: ``ClosureCaptureSpecifierSyntax``? @@ -1577,6 +1619,10 @@ public struct ClosureCaptureSyntax: SyntaxProtocol, SyntaxHashable, _LeafSyntaxN /// - Parameters: /// - leadingTrivia: Trivia to be prepended to the leading trivia of the node’s first token. If the node is empty, there is no token to attach the trivia to and the parameter is ignored. + /// - specifier: The specifier that indicates the capture semantics, if any. + /// - name: The name of the captured variable. + /// - initializer: The initializer for the captured value, if any. + /// - trailingComma: A trailing comma if this capture is followed by another capture. /// - trailingTrivia: Trivia to be appended to the trailing trivia of the node’s last token. If the node is empty, there is no token to attach the trivia to and the parameter is ignored. public init( leadingTrivia: Trivia? = nil, @@ -1635,6 +1681,7 @@ public struct ClosureCaptureSyntax: SyntaxProtocol, SyntaxHashable, _LeafSyntaxN } } + /// The specifier that indicates the capture semantics, if any. public var specifier: ClosureCaptureSpecifierSyntax? { get { return Syntax(self).child(at: 1)?.cast(ClosureCaptureSpecifierSyntax.self) @@ -1653,6 +1700,8 @@ public struct ClosureCaptureSyntax: SyntaxProtocol, SyntaxHashable, _LeafSyntaxN } } + /// The name of the captured variable. + /// /// ### Tokens /// /// For syntax trees generated by the parser, this is guaranteed to be one of the following kinds: @@ -1676,6 +1725,7 @@ public struct ClosureCaptureSyntax: SyntaxProtocol, SyntaxHashable, _LeafSyntaxN } } + /// The initializer for the captured value, if any. public var initializer: InitializerClauseSyntax? { get { return Syntax(self).child(at: 5)?.cast(InitializerClauseSyntax.self) @@ -1694,6 +1744,8 @@ public struct ClosureCaptureSyntax: SyntaxProtocol, SyntaxHashable, _LeafSyntaxN } } + /// A trailing comma if this capture is followed by another capture. + /// /// ### Tokens /// /// For syntax trees generated by the parser, this is guaranteed to be `,`. @@ -1730,6 +1782,14 @@ public struct ClosureCaptureSyntax: SyntaxProtocol, SyntaxHashable, _LeafSyntaxN // MARK: - ClosureExprSyntax +/// A closure expression. +/// +/// ```swift +/// let doubled = numbers.map { [weak self] x -> Int in +/// return x * 2 +/// } +/// ``` +/// /// ### Children /// /// - `leftBrace`: `{` @@ -1761,6 +1821,10 @@ public struct ClosureExprSyntax: ExprSyntaxProtocol, SyntaxHashable, _LeafExprSy /// - Parameters: /// - leadingTrivia: Trivia to be prepended to the leading trivia of the node’s first token. If the node is empty, there is no token to attach the trivia to and the parameter is ignored. + /// - leftBrace: The `{` that opens the closure body. + /// - signature: The signature of the closure, including capture list, parameters, and return type. + /// - statements: The statements that make up the body of the closure. + /// - rightBrace: The `}` that closes the closure body. /// - trailingTrivia: Trivia to be appended to the trailing trivia of the node’s last token. If the node is empty, there is no token to attach the trivia to and the parameter is ignored. public init( leadingTrivia: Trivia? = nil, @@ -1819,6 +1883,8 @@ public struct ClosureExprSyntax: ExprSyntaxProtocol, SyntaxHashable, _LeafExprSy } } + /// The `{` that opens the closure body. + /// /// ### Tokens /// /// For syntax trees generated by the parser, this is guaranteed to be `{`. @@ -1840,6 +1906,7 @@ public struct ClosureExprSyntax: ExprSyntaxProtocol, SyntaxHashable, _LeafExprSy } } + /// The signature of the closure, including capture list, parameters, and return type. public var signature: ClosureSignatureSyntax? { get { return Syntax(self).child(at: 3)?.cast(ClosureSignatureSyntax.self) @@ -1858,6 +1925,7 @@ public struct ClosureExprSyntax: ExprSyntaxProtocol, SyntaxHashable, _LeafExprSy } } + /// The statements that make up the body of the closure. public var statements: CodeBlockItemListSyntax { get { return Syntax(self).child(at: 5)!.cast(CodeBlockItemListSyntax.self) @@ -1903,6 +1971,8 @@ public struct ClosureExprSyntax: ExprSyntaxProtocol, SyntaxHashable, _LeafExprSy } } + /// The `}` that closes the closure body. + /// /// ### Tokens /// /// For syntax trees generated by the parser, this is guaranteed to be `}`. @@ -1939,6 +2009,12 @@ public struct ClosureExprSyntax: ExprSyntaxProtocol, SyntaxHashable, _LeafExprSy // MARK: - ClosureParameterClauseSyntax +/// The parenthesized parameter clause of a closure, enclosing typed parameters. +/// +/// ```swift +/// { (x: Int, y: Int) in x + y } +/// ``` +/// /// ### Children /// /// - `leftParen`: `(` @@ -2125,6 +2201,14 @@ public struct ClosureParameterClauseSyntax: SyntaxProtocol, SyntaxHashable, _Lea // MARK: - ClosureParameterSyntax +/// A parameter in a closure's parenthesized parameter list, which can include type annotations. +/// +/// ```swift +/// { (x: Int, y: Int) -> Int in +/// return x + y +/// } +/// ``` +/// /// ### Children /// /// - `attributes`: ``AttributeListSyntax`` @@ -2495,6 +2579,14 @@ public struct ClosureParameterSyntax: SyntaxProtocol, SyntaxHashable, _LeafSynta // MARK: - ClosureShorthandParameterSyntax +/// A shorthand closure parameter without a type annotation or parentheses. +/// +/// ```swift +/// let sum = numbers.reduce(0) { total, value in total + value } +/// ``` +/// +/// In this example, `total` and `value` are each a shorthand closure parameter. +/// /// ### Children /// /// - `name`: (`` | `_`) @@ -2520,6 +2612,8 @@ public struct ClosureShorthandParameterSyntax: SyntaxProtocol, SyntaxHashable, _ /// - Parameters: /// - leadingTrivia: Trivia to be prepended to the leading trivia of the node’s first token. If the node is empty, there is no token to attach the trivia to and the parameter is ignored. + /// - name: The name of the parameter. + /// - trailingComma: A trailing comma if this parameter is followed by another parameter. /// - trailingTrivia: Trivia to be appended to the trailing trivia of the node’s last token. If the node is empty, there is no token to attach the trivia to and the parameter is ignored. public init( leadingTrivia: Trivia? = nil, @@ -2566,6 +2660,8 @@ public struct ClosureShorthandParameterSyntax: SyntaxProtocol, SyntaxHashable, _ } } + /// The name of the parameter. + /// /// ### Tokens /// /// For syntax trees generated by the parser, this is guaranteed to be one of the following kinds: @@ -2589,6 +2685,8 @@ public struct ClosureShorthandParameterSyntax: SyntaxProtocol, SyntaxHashable, _ } } + /// A trailing comma if this parameter is followed by another parameter. + /// /// ### Tokens /// /// For syntax trees generated by the parser, this is guaranteed to be `,`. @@ -2621,6 +2719,16 @@ public struct ClosureShorthandParameterSyntax: SyntaxProtocol, SyntaxHashable, _ // MARK: - ClosureSignatureSyntax +/// The signature of a closure, which specifies its capture list, parameters, and return type. +/// +/// ```swift +/// { [weak self] (x: Int) async throws -> Int in +/// return x * 2 +/// } +/// ``` +/// +/// Everything before the `in` keyword is part of the closure signature. +/// /// ### Children /// /// - `attributes`: ``AttributeListSyntax`` @@ -2730,6 +2838,12 @@ public struct ClosureSignatureSyntax: SyntaxProtocol, SyntaxHashable, _LeafSynta /// - Parameters: /// - leadingTrivia: Trivia to be prepended to the leading trivia of the node’s first token. If the node is empty, there is no token to attach the trivia to and the parameter is ignored. + /// - attributes: Attributes attached to the closure signature. + /// - capture: The capture list specifying how variables from the surrounding scope are captured. + /// - parameterClause: The parameters of the closure, either shorthand names or a full parameter clause. + /// - effectSpecifiers: The `async` and/or `throws` specifiers of the closure. + /// - returnClause: The return type of the closure, if specified. + /// - inKeyword: The `in` keyword that separates the signature from the closure body. /// - trailingTrivia: Trivia to be appended to the trailing trivia of the node’s last token. If the node is empty, there is no token to attach the trivia to and the parameter is ignored. public init( leadingTrivia: Trivia? = nil, @@ -2800,6 +2914,7 @@ public struct ClosureSignatureSyntax: SyntaxProtocol, SyntaxHashable, _LeafSynta } } + /// Attributes attached to the closure signature. public var attributes: AttributeListSyntax { get { return Syntax(self).child(at: 1)!.cast(AttributeListSyntax.self) @@ -2845,6 +2960,7 @@ public struct ClosureSignatureSyntax: SyntaxProtocol, SyntaxHashable, _LeafSynta } } + /// The capture list specifying how variables from the surrounding scope are captured. public var capture: ClosureCaptureClauseSyntax? { get { return Syntax(self).child(at: 3)?.cast(ClosureCaptureClauseSyntax.self) @@ -2863,6 +2979,7 @@ public struct ClosureSignatureSyntax: SyntaxProtocol, SyntaxHashable, _LeafSynta } } + /// The parameters of the closure, either shorthand names or a full parameter clause. public var parameterClause: ParameterClause? { get { return Syntax(self).child(at: 5)?.cast(ParameterClause.self) @@ -2881,6 +2998,7 @@ public struct ClosureSignatureSyntax: SyntaxProtocol, SyntaxHashable, _LeafSynta } } + /// The `async` and/or `throws` specifiers of the closure. public var effectSpecifiers: TypeEffectSpecifiersSyntax? { get { return Syntax(self).child(at: 7)?.cast(TypeEffectSpecifiersSyntax.self) @@ -2899,6 +3017,7 @@ public struct ClosureSignatureSyntax: SyntaxProtocol, SyntaxHashable, _LeafSynta } } + /// The return type of the closure, if specified. public var returnClause: ReturnClauseSyntax? { get { return Syntax(self).child(at: 9)?.cast(ReturnClauseSyntax.self) @@ -2917,6 +3036,8 @@ public struct ClosureSignatureSyntax: SyntaxProtocol, SyntaxHashable, _LeafSynta } } + /// The `in` keyword that separates the signature from the closure body. + /// /// ### Tokens /// /// For syntax trees generated by the parser, this is guaranteed to be `in`.