@@ -14,12 +14,16 @@ import Foundation
14
14
@_spi ( RawSyntax) import SwiftParser
15
15
@_spi ( RawSyntax) import SwiftSyntax
16
16
17
+ // MARK: - BinaryOperatorExpr
18
+
17
19
extension BinaryOperatorExpr {
18
20
public init ( text: String ) {
19
21
self . init ( operatorToken: . spacedBinaryOperator( text) )
20
22
}
21
23
}
22
24
25
+ // MARK: - BooleanLiteralExpr
26
+
23
27
extension BooleanLiteralExpr : ExpressibleByBooleanLiteral {
24
28
public init ( _ value: Bool ) {
25
29
self . init ( booleanLiteral: value ? . true : . false )
@@ -30,6 +34,8 @@ extension BooleanLiteralExpr: ExpressibleByBooleanLiteral {
30
34
}
31
35
}
32
36
37
+ // MARK: - CatchClause
38
+
33
39
extension CatchClause {
34
40
/// A convenience initializer that calculates spacing around the `catch` keyword.
35
41
public init (
@@ -46,6 +52,8 @@ extension CatchClause {
46
52
}
47
53
}
48
54
55
+ // MARK: - CustomAttribute
56
+
49
57
extension CustomAttribute {
50
58
/// A convenience initializer that allows passing in arguments using a result builder
51
59
/// and automatically adds parentheses as needed, similar to the convenience
@@ -64,6 +72,8 @@ extension CustomAttribute {
64
72
}
65
73
}
66
74
75
+ // MARK: - DictionaryExpr
76
+
67
77
extension DictionaryExpr {
68
78
/// A convenience initializer that allows passing in members using a result builder
69
79
/// instead of having to wrap them in a `DictionaryElementList`.
@@ -81,6 +91,8 @@ extension DictionaryExpr {
81
91
}
82
92
}
83
93
94
+ // MARK: - FloatLiteralExprSyntax
95
+
84
96
extension FloatLiteralExprSyntax : ExpressibleByFloatLiteral {
85
97
public init ( _ value: Float ) {
86
98
self . init ( floatingDigits: String ( value) )
@@ -91,6 +103,8 @@ extension FloatLiteralExprSyntax: ExpressibleByFloatLiteral {
91
103
}
92
104
}
93
105
106
+ // MARK: - FunctionCallExpr
107
+
94
108
extension FunctionCallExpr {
95
109
/// A convenience initializer that allows passing in arguments using a result builder
96
110
/// instead of having to wrap them in a `TupleExprElementList`.
@@ -114,6 +128,8 @@ extension FunctionCallExpr {
114
128
}
115
129
}
116
130
131
+ // MARK: - FunctionParameter
132
+
117
133
extension FunctionParameter {
118
134
public init (
119
135
_ source: String ,
@@ -125,6 +141,8 @@ extension FunctionParameter {
125
141
}
126
142
}
127
143
144
+ // MARK: - IfStmt
145
+
128
146
extension IfStmt {
129
147
/// A convenience initializer that uses builder closures to express an
130
148
/// if body, potentially with a second trailing builder closure for an else
@@ -147,6 +165,8 @@ extension IfStmt {
147
165
}
148
166
149
167
168
+ // MARK: - IntegerLiteralExpr
169
+
150
170
extension IntegerLiteralExpr : ExpressibleByIntegerLiteral {
151
171
public init ( _ value: Int ) {
152
172
self . init ( digits: String ( value) )
@@ -157,6 +177,8 @@ extension IntegerLiteralExpr: ExpressibleByIntegerLiteral {
157
177
}
158
178
}
159
179
180
+ // MARK: - MemberAccessExpr
181
+
160
182
extension MemberAccessExpr {
161
183
/// Creates a `MemberAccessExpr` using the provided parameters.
162
184
public init (
@@ -169,6 +191,8 @@ extension MemberAccessExpr {
169
191
}
170
192
}
171
193
194
+ // MARK: - StringLiteralExpr
195
+
172
196
extension StringLiteralExpr {
173
197
private enum PoundState {
174
198
case afterQuote, afterBackslash, none
@@ -244,13 +268,17 @@ extension StringLiteralExpr {
244
268
}
245
269
}
246
270
271
+ // MARK: - SwitchCase
272
+
247
273
extension SwitchCase {
248
274
public init ( _ label: String , @CodeBlockItemListBuilder statementsBuilder: ( ) -> CodeBlockItemListSyntax ) {
249
275
self . init ( " \( label) " )
250
276
self . statements = statementsBuilder ( )
251
277
}
252
278
}
253
279
280
+ // MARK: - TernaryExpr
281
+
254
282
extension TernaryExpr {
255
283
public init (
256
284
if condition: ExprSyntaxProtocol ,
@@ -267,6 +295,8 @@ extension TernaryExpr {
267
295
}
268
296
}
269
297
298
+ // MARK: - TupleExprElement
299
+
270
300
extension TupleExprElement {
271
301
/// A convenience initializer that allows passing in label as an optional string.
272
302
/// The presence of the colon will be inferred based on the presence of the label.
@@ -276,6 +306,8 @@ extension TupleExprElement {
276
306
}
277
307
}
278
308
309
+ // MARK: - VariableDecl
310
+
279
311
extension VariableDecl {
280
312
/// Creates an optionally initialized property.
281
313
public init (
0 commit comments