diff --git a/CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift b/CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift index 23f131e8b06..e3bdf05527d 100644 --- a/CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift +++ b/CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift @@ -2171,6 +2171,14 @@ public let DECL_NODES: [Node] = [ kind: .returnClause, base: .syntax, nameForDiagnostics: nil, + documentation: """ + A clause that specifies the return type, typically of a function or subscript. + + For example, the `-> Int` part in + ```swift + func f() -> Int { } + ``` + """, children: [ Child( name: "arrow", @@ -2437,6 +2445,14 @@ public let DECL_NODES: [Node] = [ kind: .typeInitializerClause, base: .syntax, nameForDiagnostics: nil, + documentation: """ + A clause that specifies the underlying type of `typealias` or `associatedtype` declaration. + + For example, the `= Int` part in + ```swift + typealias MyInt = Int + ``` + """, children: [ Child( name: "equal", diff --git a/CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift b/CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift index 4920cc7af98..ed5bf4e5b75 100644 --- a/CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift +++ b/CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift @@ -1903,6 +1903,24 @@ public let EXPR_NODES: [Node] = [ kind: .switchCaseLabel, base: .syntax, nameForDiagnostics: nil, + documentation: """ + A label that introduces one or more cases in a switch statement. + + Written as: + ```swift + case : + ``` + + ### Examples + + ```swift + case 1: + ``` + + ```swift + case 1, 2, 3: + ``` + """, children: [ Child( name: "caseKeyword", @@ -1930,6 +1948,25 @@ public let EXPR_NODES: [Node] = [ kind: .switchCase, base: .syntax, nameForDiagnostics: "switch case", + documentation: """ + A single case within a `switch` statement. + + A switch case consists of a label (`case` or `default`), + an optional `@unknown` attribute, and the statements + that are executed when the case is matched. + + ### Examples + + ```swift + case 1: + print("one") + ``` + + ```swift + default: + print("other") + ``` + """, parserFunction: "parseSwitchCase", traits: ["WithStatements"], children: [ @@ -1969,6 +2006,15 @@ public let EXPR_NODES: [Node] = [ kind: .switchDefaultLabel, base: .syntax, nameForDiagnostics: nil, + documentation: """ + The default label is executed when none of the `case` patterns + match the value being switched over. + + Written as: + ```swift + default: + ``` + """, children: [ Child( name: "defaultKeyword", diff --git a/CodeGeneration/Sources/SyntaxSupport/PatternNodes.swift b/CodeGeneration/Sources/SyntaxSupport/PatternNodes.swift index dbb019dfebb..8c1967cfb0c 100644 --- a/CodeGeneration/Sources/SyntaxSupport/PatternNodes.swift +++ b/CodeGeneration/Sources/SyntaxSupport/PatternNodes.swift @@ -181,6 +181,23 @@ public let PATTERN_NODES: [Node] = [ kind: .typeAnnotation, base: .syntax, nameForDiagnostics: "type annotation", + documentation: """ + A type annotation that explicitly specifies the type of a value or pattern. + + Written as a colon followed by a type: + ```swift + : + ``` + + ### Examples + + ```swift + let count: Int + ``` + ```swift + let point: (x: Int, y: Int) + ``` + """, children: [ Child( name: "colon", diff --git a/CodeGeneration/Sources/SyntaxSupport/StmtNodes.swift b/CodeGeneration/Sources/SyntaxSupport/StmtNodes.swift index 3ac5bab1109..703150bc0e1 100644 --- a/CodeGeneration/Sources/SyntaxSupport/StmtNodes.swift +++ b/CodeGeneration/Sources/SyntaxSupport/StmtNodes.swift @@ -493,6 +493,18 @@ public let STMT_NODES: [Node] = [ kind: .returnStmt, base: .stmt, nameForDiagnostics: "'return' statement", + documentation: """ + A statement that exits a function or closure and optionally returns a value. + + Written as: + ```swift + return + ``` + + ```swift + return + ``` + """, children: [ Child( name: "returnKeyword", @@ -510,6 +522,15 @@ public let STMT_NODES: [Node] = [ kind: .throwStmt, base: .stmt, nameForDiagnostics: "'throw' statement", + documentation: """ + A statement that throws an error. + + Written as: + + ```swift + throw + ``` + """, children: [ Child( name: "throwKeyword", diff --git a/Sources/SwiftSyntax/generated/SyntaxCollections.swift b/Sources/SwiftSyntax/generated/SyntaxCollections.swift index 66824658e29..98a63aed7e2 100644 --- a/Sources/SwiftSyntax/generated/SyntaxCollections.swift +++ b/Sources/SwiftSyntax/generated/SyntaxCollections.swift @@ -1759,6 +1759,23 @@ public struct SwitchCaseItemListSyntax: SyntaxCollection, SyntaxHashable { /// - ``SwitchExprSyntax``.``SwitchExprSyntax/cases`` public struct SwitchCaseListSyntax: SyntaxCollection, SyntaxHashable { public enum Element: SyntaxChildChoices, SyntaxHashable { + /// A single case within a `switch` statement. + /// + /// A switch case consists of a label (`case` or `default`), + /// an optional `@unknown` attribute, and the statements + /// that are executed when the case is matched. + /// + /// ### Examples + /// + /// ```swift + /// case 1: + /// print("one") + /// ``` + /// + /// ```swift + /// default: + /// print("other") + /// ``` case switchCase(SwitchCaseSyntax) case ifConfigDecl(IfConfigDeclSyntax) diff --git a/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesQRS.swift b/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesQRS.swift index 3092d21e457..a609332497a 100644 --- a/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesQRS.swift +++ b/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesQRS.swift @@ -2282,6 +2282,23 @@ public struct RawSwitchCaseLabelSyntax: RawSyntaxNodeProtocol { @_spi(RawSyntax) public struct RawSwitchCaseListSyntax: RawSyntaxNodeProtocol { public enum Element: RawSyntaxNodeProtocol { + /// A single case within a `switch` statement. + /// + /// A switch case consists of a label (`case` or `default`), + /// an optional `@unknown` attribute, and the statements + /// that are executed when the case is matched. + /// + /// ### Examples + /// + /// ```swift + /// case 1: + /// print("one") + /// ``` + /// + /// ```swift + /// default: + /// print("other") + /// ``` case switchCase(RawSwitchCaseSyntax) case ifConfigDecl(RawIfConfigDeclSyntax) diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesQRS.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesQRS.swift index 1ad996a81d0..27aa060801e 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesQRS.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesQRS.swift @@ -399,6 +399,13 @@ public struct RepeatStmtSyntax: StmtSyntaxProtocol, SyntaxHashable, _LeafStmtSyn // MARK: - ReturnClauseSyntax +/// A clause that specifies the return type, typically of a function or subscript. +/// +/// For example, the `-> Int` part in +/// ```swift +/// func f() -> Int { } +/// ``` +/// /// ### Children /// /// - `arrow`: `->` @@ -528,6 +535,17 @@ public struct ReturnClauseSyntax: SyntaxProtocol, SyntaxHashable, _LeafSyntaxNod // MARK: - ReturnStmtSyntax +/// A statement that exits a function or closure and optionally returns a value. +/// +/// Written as: +/// ```swift +/// return +/// ``` +/// +/// ```swift +/// return +/// ``` +/// /// ### Children /// /// - `returnKeyword`: `return` @@ -3863,6 +3881,23 @@ public struct SwitchCaseItemSyntax: SyntaxProtocol, SyntaxHashable, _LeafSyntaxN // MARK: - SwitchCaseLabelSyntax +/// A label that introduces one or more cases in a switch statement. +/// +/// Written as: +/// ```swift +/// case : +/// ``` +/// +/// ### Examples +/// +/// ```swift +/// case 1: +/// ``` +/// +/// ```swift +/// case 1, 2, 3: +/// ``` +/// /// ### Children /// /// - `caseKeyword`: `case` @@ -4041,6 +4076,24 @@ public struct SwitchCaseLabelSyntax: SyntaxProtocol, SyntaxHashable, _LeafSyntax // MARK: - SwitchCaseSyntax +/// A single case within a `switch` statement. +/// +/// A switch case consists of a label (`case` or `default`), +/// an optional `@unknown` attribute, and the statements +/// that are executed when the case is matched. +/// +/// ### Examples +/// +/// ```swift +/// case 1: +/// print("one") +/// ``` +/// +/// ```swift +/// default: +/// print("other") +/// ``` +/// /// ### Children /// /// - `attribute`: ``AttributeSyntax``? @@ -4295,6 +4348,14 @@ public struct SwitchCaseSyntax: SyntaxProtocol, SyntaxHashable, _LeafSyntaxNodeP // MARK: - SwitchDefaultLabelSyntax +/// The default label is executed when none of the `case` patterns +/// match the value being switched over. +/// +/// Written as: +/// ```swift +/// default: +/// ``` +/// /// ### Children /// /// - `defaultKeyword`: `default` diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesTUVWXYZ.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesTUVWXYZ.swift index 40a3bc8890c..51c3481cd8e 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesTUVWXYZ.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesTUVWXYZ.swift @@ -355,6 +355,14 @@ public struct ThenStmtSyntax: StmtSyntaxProtocol, SyntaxHashable, _LeafStmtSynta // MARK: - ThrowStmtSyntax +/// A statement that throws an error. +/// +/// Written as: +/// +/// ```swift +/// throw +/// ``` +/// /// ### Children /// /// - `throwKeyword`: `throw` @@ -2159,6 +2167,22 @@ public struct TypeAliasDeclSyntax: DeclSyntaxProtocol, SyntaxHashable, _LeafDecl // MARK: - TypeAnnotationSyntax +/// A type annotation that explicitly specifies the type of a value or pattern. +/// +/// Written as a colon followed by a type: +/// ```swift +/// : +/// ``` +/// +/// ### Examples +/// +/// ```swift +/// let count: Int +/// ``` +/// ```swift +/// let point: (x: Int, y: Int) +/// ``` +/// /// ### Children /// /// - `colon`: `:` @@ -2486,6 +2510,13 @@ public struct TypeExprSyntax: ExprSyntaxProtocol, SyntaxHashable, _LeafExprSynta // MARK: - TypeInitializerClauseSyntax +/// A clause that specifies the underlying type of `typealias` or `associatedtype` declaration. +/// +/// For example, the `= Int` part in +/// ```swift +/// typealias MyInt = Int +/// ``` +/// /// ### Children /// /// - `equal`: `=`