Skip to content

Commit f5ba1b1

Browse files
committed
Add more documentation do Syntax nodes
1 parent 13f113e commit f5ba1b1

File tree

9 files changed

+92
-17
lines changed

9 files changed

+92
-17
lines changed

CodeGeneration/Sources/SyntaxSupport/CommonNodes.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ public let COMMON_NODES: [Node] = [
6666
children: [
6767
Child(
6868
name: "leftBrace",
69-
kind: .token(choices: [.token(.leftBrace)])
69+
kind: .token(choices: [.token(.leftBrace)]),
70+
documentation: "The opening brace of code block"
7071
),
7172
Child(
7273
name: "statements",
@@ -75,7 +76,8 @@ public let COMMON_NODES: [Node] = [
7576
),
7677
Child(
7778
name: "rightBrace",
78-
kind: .token(choices: [.token(.rightBrace)])
79+
kind: .token(choices: [.token(.rightBrace)]),
80+
documentation: "The closening brace of code block"
7981
),
8082
]
8183
),
@@ -92,11 +94,13 @@ public let COMMON_NODES: [Node] = [
9294
Child(
9395
name: "asyncSpecifier",
9496
kind: .token(choices: [.keyword(.async)]),
97+
documentation: "The `async` keyword.",
9598
isOptional: true
9699
),
97100
Child(
98101
name: "throwsSpecifier",
99102
kind: .token(choices: [.keyword(.throws)]),
103+
documentation: "The `throws` keyword.",
100104
isOptional: true
101105
),
102106
]
@@ -114,11 +118,13 @@ public let COMMON_NODES: [Node] = [
114118
Child(
115119
name: "asyncSpecifier",
116120
kind: .token(choices: [.keyword(.async), .keyword(.reasync)]),
121+
documentation: "The `async` or `reasync` keyword.",
117122
isOptional: true
118123
),
119124
Child(
120125
name: "throwsSpecifier",
121126
kind: .token(choices: [.keyword(.throws), .keyword(.rethrows)]),
127+
documentation: "The `throws` or `rethrows` keyword",
122128
isOptional: true
123129
),
124130
]
@@ -134,6 +140,7 @@ public let COMMON_NODES: [Node] = [
134140
Child(
135141
name: "asyncSpecifier",
136142
kind: .token(choices: [.keyword(.async)]),
143+
documentation: "The `async` keyword.",
137144
isOptional: true
138145
)
139146
]

CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ public let DECL_NODES: [Node] = [
5353
children: [
5454
Child(
5555
name: "leftBrace",
56-
kind: .token(choices: [.token(.leftBrace)])
56+
kind: .token(choices: [.token(.leftBrace)]),
57+
documentation: "The brace that is the opening of the accessor block"
5758
),
5859
Child(
5960
name: "accessors",
@@ -70,7 +71,8 @@ public let DECL_NODES: [Node] = [
7071
),
7172
Child(
7273
name: "rightBrace",
73-
kind: .token(choices: [.token(.rightBrace)])
74+
kind: .token(choices: [.token(.rightBrace)]),
75+
documentation: "The brace that is the closing of the accessor block"
7476
),
7577
]
7678
),
@@ -191,7 +193,8 @@ public let DECL_NODES: [Node] = [
191193
Child(
192194
name: "modifiers",
193195
kind: .collection(kind: .declModifierList, collectionElementName: "Modifier", defaultsToEmpty: true),
194-
nameForDiagnostics: "modifiers"
196+
nameForDiagnostics: "modifiers",
197+
documentation: "Modifiers attached to the actor."
195198
),
196199
Child(
197200
name: "actorKeyword",
@@ -200,7 +203,8 @@ public let DECL_NODES: [Node] = [
200203
Child(
201204
name: "name",
202205
deprecatedName: "identifier",
203-
kind: .token(choices: [.token(.identifier)])
206+
kind: .token(choices: [.token(.identifier)]),
207+
documentation: "The identifier of the actor"
204208
),
205209
Child(
206210
name: "genericParameterClause",
@@ -857,7 +861,8 @@ public let DECL_NODES: [Node] = [
857861
Child(
858862
name: "modifiers",
859863
kind: .collection(kind: .declModifierList, collectionElementName: "Modifier", defaultsToEmpty: true),
860-
nameForDiagnostics: "modifiers"
864+
nameForDiagnostics: "modifiers",
865+
documentation: "Modifiers modifiers applied to the extension declaration."
861866
),
862867
Child(
863868
name: "extensionKeyword",
@@ -906,7 +911,8 @@ public let DECL_NODES: [Node] = [
906911
Child(
907912
name: "modifiers",
908913
kind: .collection(kind: .declModifierList, collectionElementName: "Modifier", defaultsToEmpty: true),
909-
nameForDiagnostics: "modifiers"
914+
nameForDiagnostics: "modifiers",
915+
documentation: "Modifiers modifiers applied to the function declaration."
910916
),
911917
Child(
912918
name: "funcKeyword",
@@ -2324,7 +2330,8 @@ public let DECL_NODES: [Node] = [
23242330
Child(
23252331
name: "modifiers",
23262332
kind: .collection(kind: .declModifierList, collectionElementName: "Modifier", defaultsToEmpty: true),
2327-
nameForDiagnostics: "modifiers"
2333+
nameForDiagnostics: "modifiers",
2334+
documentation: "Modifiers modifiers applied to the variable declaration."
23282335
),
23292336
Child(
23302337
name: "bindingSpecifier",

CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,37 +1683,50 @@ public let EXPR_NODES: [Node] = [
16831683

16841684
// switch-expr -> identifier? ':'? 'switch' expr '{'
16851685
// switch-case-list '}' ';'?
1686-
//
1687-
// This node represents both a 'switch' expression, as well as a 'switch'
1688-
// statement when wrapped in an ExpressionStmt node.
16891686
Node(
16901687
kind: .switchExpr,
16911688
base: .expr,
16921689
nameForDiagnostics: "'switch' statement",
1690+
documentation: """
1691+
A `switch` statement expression.
1692+
1693+
This node represents both a 'switch' expression, as well as a 'switch'
1694+
statement when wrapped in an ``ExpressionStmtSyntax`` node.
1695+
1696+
```swift
1697+
switch <#expression#> {
1698+
}
1699+
```
1700+
""",
16931701
traits: [
16941702
"Braced"
16951703
],
16961704
children: [
16971705
Child(
16981706
name: "switchKeyword",
1699-
kind: .token(choices: [.keyword(.switch)])
1707+
kind: .token(choices: [.keyword(.switch)]),
1708+
documentation: "The switch keyword."
17001709
),
17011710
Child(
17021711
name: "subject",
17031712
deprecatedName: "expression",
1704-
kind: .node(kind: .expr)
1713+
kind: .node(kind: .expr),
1714+
documentation: "The expression to switch over."
17051715
),
17061716
Child(
17071717
name: "leftBrace",
1708-
kind: .token(choices: [.token(.leftBrace)])
1718+
kind: .token(choices: [.token(.leftBrace)]),
1719+
documentation: "The left brace of the switch body."
17091720
),
17101721
Child(
17111722
name: "cases",
1712-
kind: .collection(kind: .switchCaseList, collectionElementName: "Case")
1723+
kind: .collection(kind: .switchCaseList, collectionElementName: "Case"),
1724+
documentation: "The switch's body that contains the possible cases."
17131725
),
17141726
Child(
17151727
name: "rightBrace",
1716-
kind: .token(choices: [.token(.rightBrace)])
1728+
kind: .token(choices: [.token(.rightBrace)]),
1729+
documentation: "The right brace of the switch body."
17171730
),
17181731
]
17191732
),

Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesAB.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ public struct AccessorBlockSyntax: SyntaxProtocol, SyntaxHashable {
8787

8888
/// - Parameters:
8989
/// - 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.
90+
/// - leftBrace: The brace that is the opening of the accessor block
91+
/// - rightBrace: The brace that is the closing of the accessor block
9092
/// - 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.
9193
public init(
9294
leadingTrivia: Trivia? = nil,
@@ -142,6 +144,7 @@ public struct AccessorBlockSyntax: SyntaxProtocol, SyntaxHashable {
142144
}
143145
}
144146

147+
/// The brace that is the opening of the accessor block
145148
public var leftBrace: TokenSyntax {
146149
get {
147150
return TokenSyntax(data.child(at: 1)!)
@@ -178,6 +181,7 @@ public struct AccessorBlockSyntax: SyntaxProtocol, SyntaxHashable {
178181
}
179182
}
180183

184+
/// The brace that is the closing of the accessor block
181185
public var rightBrace: TokenSyntax {
182186
get {
183187
return TokenSyntax(data.child(at: 5)!)
@@ -501,6 +505,8 @@ public struct AccessorEffectSpecifiersSyntax: SyntaxProtocol, SyntaxHashable {
501505

502506
/// - Parameters:
503507
/// - 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.
508+
/// - asyncSpecifier: The `async` keyword.
509+
/// - throwsSpecifier: The `throws` keyword.
504510
/// - 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.
505511
public init(
506512
leadingTrivia: Trivia? = nil,
@@ -550,6 +556,7 @@ public struct AccessorEffectSpecifiersSyntax: SyntaxProtocol, SyntaxHashable {
550556
}
551557
}
552558

559+
/// The `async` keyword.
553560
public var asyncSpecifier: TokenSyntax? {
554561
get {
555562
return data.child(at: 1).map(TokenSyntax.init)
@@ -568,6 +575,7 @@ public struct AccessorEffectSpecifiersSyntax: SyntaxProtocol, SyntaxHashable {
568575
}
569576
}
570577

578+
/// The `throws` keyword.
571579
public var throwsSpecifier: TokenSyntax? {
572580
get {
573581
return data.child(at: 3).map(TokenSyntax.init)
@@ -784,6 +792,8 @@ public struct ActorDeclSyntax: DeclSyntaxProtocol, SyntaxHashable {
784792

785793
/// - Parameters:
786794
/// - 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.
795+
/// - modifiers: Modifiers attached to the actor.
796+
/// - name: The identifier of the actor
787797
/// - genericParameterClause: The parameter clause that defines the generic parameters.
788798
/// - genericWhereClause: A `where` clause that places additional constraints on generic parameters like `where Element: Hashable`.
789799
/// - 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.
@@ -915,6 +925,7 @@ public struct ActorDeclSyntax: DeclSyntaxProtocol, SyntaxHashable {
915925
}
916926
}
917927

928+
/// Modifiers attached to the actor.
918929
public var modifiers: DeclModifierListSyntax {
919930
get {
920931
return DeclModifierListSyntax(data.child(at: 3)!)
@@ -977,6 +988,7 @@ public struct ActorDeclSyntax: DeclSyntaxProtocol, SyntaxHashable {
977988
}
978989
}
979990

991+
/// The identifier of the actor
980992
public var name: TokenSyntax {
981993
get {
982994
return TokenSyntax(data.child(at: 7)!)

Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesC.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3171,6 +3171,8 @@ public struct CodeBlockSyntax: SyntaxProtocol, SyntaxHashable {
31713171

31723172
/// - Parameters:
31733173
/// - 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.
3174+
/// - leftBrace: The opening brace of code block
3175+
/// - rightBrace: The closening brace of code block
31743176
/// - 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.
31753177
public init(
31763178
leadingTrivia: Trivia? = nil,
@@ -3226,6 +3228,7 @@ public struct CodeBlockSyntax: SyntaxProtocol, SyntaxHashable {
32263228
}
32273229
}
32283230

3231+
/// The opening brace of code block
32293232
public var leftBrace: TokenSyntax {
32303233
get {
32313234
return TokenSyntax(data.child(at: 1)!)
@@ -3288,6 +3291,7 @@ public struct CodeBlockSyntax: SyntaxProtocol, SyntaxHashable {
32883291
}
32893292
}
32903293

3294+
/// The closening brace of code block
32913295
public var rightBrace: TokenSyntax {
32923296
get {
32933297
return TokenSyntax(data.child(at: 5)!)

Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesD.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,7 @@ public struct DeinitializerEffectSpecifiersSyntax: SyntaxProtocol, SyntaxHashabl
11581158

11591159
/// - Parameters:
11601160
/// - 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.
1161+
/// - asyncSpecifier: The `async` keyword.
11611162
/// - 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.
11621163
public init(
11631164
leadingTrivia: Trivia? = nil,
@@ -1193,6 +1194,7 @@ public struct DeinitializerEffectSpecifiersSyntax: SyntaxProtocol, SyntaxHashabl
11931194
}
11941195
}
11951196

1197+
/// The `async` keyword.
11961198
public var asyncSpecifier: TokenSyntax? {
11971199
get {
11981200
return data.child(at: 1).map(TokenSyntax.init)

Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesEF.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2189,6 +2189,7 @@ public struct ExtensionDeclSyntax: DeclSyntaxProtocol, SyntaxHashable {
21892189

21902190
/// - Parameters:
21912191
/// - 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.
2192+
/// - modifiers: Modifiers modifiers applied to the extension declaration.
21922193
/// - genericWhereClause: A `where` clause that places additional constraints on generic parameters like `where Element: Hashable`.
21932194
/// - 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.
21942195
public init(
@@ -2313,6 +2314,7 @@ public struct ExtensionDeclSyntax: DeclSyntaxProtocol, SyntaxHashable {
23132314
}
23142315
}
23152316

2317+
/// Modifiers modifiers applied to the extension declaration.
23162318
public var modifiers: DeclModifierListSyntax {
23172319
get {
23182320
return DeclModifierListSyntax(data.child(at: 3)!)
@@ -3415,6 +3417,7 @@ public struct FunctionDeclSyntax: DeclSyntaxProtocol, SyntaxHashable {
34153417

34163418
/// - Parameters:
34173419
/// - 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.
3420+
/// - modifiers: Modifiers modifiers applied to the function declaration.
34183421
/// - genericParameterClause: The parameter clause that defines the generic parameters.
34193422
/// - genericWhereClause: A `where` clause that places additional constraints on generic parameters like `where Element: Hashable`.
34203423
/// - 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.
@@ -3546,6 +3549,7 @@ public struct FunctionDeclSyntax: DeclSyntaxProtocol, SyntaxHashable {
35463549
}
35473550
}
35483551

3552+
/// Modifiers modifiers applied to the function declaration.
35493553
public var modifiers: DeclModifierListSyntax {
35503554
get {
35513555
return DeclModifierListSyntax(data.child(at: 3)!)
@@ -3754,6 +3758,8 @@ public struct FunctionEffectSpecifiersSyntax: SyntaxProtocol, SyntaxHashable {
37543758

37553759
/// - Parameters:
37563760
/// - 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.
3761+
/// - asyncSpecifier: The `async` or `reasync` keyword.
3762+
/// - throwsSpecifier: The `throws` or `rethrows` keyword
37573763
/// - 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.
37583764
public init(
37593765
leadingTrivia: Trivia? = nil,
@@ -3803,6 +3809,7 @@ public struct FunctionEffectSpecifiersSyntax: SyntaxProtocol, SyntaxHashable {
38033809
}
38043810
}
38053811

3812+
/// The `async` or `reasync` keyword.
38063813
public var asyncSpecifier: TokenSyntax? {
38073814
get {
38083815
return data.child(at: 1).map(TokenSyntax.init)
@@ -3821,6 +3828,7 @@ public struct FunctionEffectSpecifiersSyntax: SyntaxProtocol, SyntaxHashable {
38213828
}
38223829
}
38233830

3831+
/// The `throws` or `rethrows` keyword
38243832
public var throwsSpecifier: TokenSyntax? {
38253833
get {
38263834
return data.child(at: 3).map(TokenSyntax.init)

0 commit comments

Comments
 (0)