@@ -40,24 +40,24 @@ extension SyntaxStringInterpolation {
40
40
public protocol HasTrailingCodeBlock {
41
41
var body : CodeBlockSyntax { get set }
42
42
43
- init ( _ header: PartialSyntaxNodeString , @CodeBlockItemListBuilder bodyBuilder: ( ) -> CodeBlockItemListSyntax ) throws
43
+ init ( _ header: PartialSyntaxNodeString , @CodeBlockItemListBuilder bodyBuilder: ( ) throws -> CodeBlockItemListSyntax ) throws
44
44
}
45
45
46
46
public extension HasTrailingCodeBlock where Self: StmtSyntaxProtocol {
47
- init ( _ header: PartialSyntaxNodeString , @CodeBlockItemListBuilder bodyBuilder: ( ) -> CodeBlockItemListSyntax ) throws {
47
+ init ( _ header: PartialSyntaxNodeString , @CodeBlockItemListBuilder bodyBuilder: ( ) throws -> CodeBlockItemListSyntax ) throws {
48
48
let stmt = StmtSyntax ( " \( header) {} " )
49
49
guard let castedStmt = stmt. as ( Self . self) else {
50
50
throw SyntaxStringInterpolationError . producedInvalidNodeType ( expectedType: Self . self, actualNode: stmt)
51
51
}
52
52
self = castedStmt
53
- self . body = CodeBlockSyntax ( statements: bodyBuilder ( ) )
53
+ self . body = try CodeBlockSyntax ( statements: bodyBuilder ( ) )
54
54
}
55
55
}
56
56
57
57
extension CatchClauseSyntax : HasTrailingCodeBlock {
58
- public init ( _ header: PartialSyntaxNodeString , @CodeBlockItemListBuilder bodyBuilder: ( ) -> CodeBlockItemListSyntax ) throws {
58
+ public init ( _ header: PartialSyntaxNodeString , @CodeBlockItemListBuilder bodyBuilder: ( ) throws -> CodeBlockItemListSyntax ) throws {
59
59
self = CatchClauseSyntax ( " \( header) {} " )
60
- self . body = CodeBlockSyntax ( statements: bodyBuilder ( ) )
60
+ self . body = try CodeBlockSyntax ( statements: bodyBuilder ( ) )
61
61
}
62
62
}
63
63
extension DeferStmtSyntax : HasTrailingCodeBlock { }
@@ -71,17 +71,17 @@ extension WhileStmtSyntax: HasTrailingCodeBlock {}
71
71
public protocol HasTrailingOptionalCodeBlock {
72
72
var body : CodeBlockSyntax ? { get set }
73
73
74
- init ( _ header: PartialSyntaxNodeString , @CodeBlockItemListBuilder bodyBuilder: ( ) -> CodeBlockItemListSyntax ) throws
74
+ init ( _ header: PartialSyntaxNodeString , @CodeBlockItemListBuilder bodyBuilder: ( ) throws -> CodeBlockItemListSyntax ) throws
75
75
}
76
76
77
77
public extension HasTrailingOptionalCodeBlock where Self: DeclSyntaxProtocol {
78
- init ( _ header: PartialSyntaxNodeString , @CodeBlockItemListBuilder bodyBuilder: ( ) -> CodeBlockItemListSyntax ) throws {
78
+ init ( _ header: PartialSyntaxNodeString , @CodeBlockItemListBuilder bodyBuilder: ( ) throws -> CodeBlockItemListSyntax ) throws {
79
79
let decl = DeclSyntax ( " \( header) {} " )
80
80
guard let castedDecl = decl. as ( Self . self) else {
81
81
throw SyntaxStringInterpolationError . producedInvalidNodeType ( expectedType: Self . self, actualNode: decl)
82
82
}
83
83
self = castedDecl
84
- self . body = CodeBlockSyntax ( statements: bodyBuilder ( ) )
84
+ self . body = try CodeBlockSyntax ( statements: bodyBuilder ( ) )
85
85
}
86
86
}
87
87
@@ -95,17 +95,17 @@ extension InitializerDeclSyntax: HasTrailingOptionalCodeBlock {}
95
95
public protocol HasTrailingMemberDeclBlock {
96
96
var members : MemberDeclBlockSyntax { get set }
97
97
98
- init ( _ header: PartialSyntaxNodeString , @MemberDeclListBuilder membersBuilder: ( ) -> MemberDeclListSyntax ) throws
98
+ init ( _ header: PartialSyntaxNodeString , @MemberDeclListBuilder membersBuilder: ( ) throws -> MemberDeclListSyntax ) throws
99
99
}
100
100
101
101
public extension HasTrailingMemberDeclBlock where Self: DeclSyntaxProtocol {
102
- init ( _ header: PartialSyntaxNodeString , @MemberDeclListBuilder membersBuilder: ( ) -> MemberDeclListSyntax ) throws {
102
+ init ( _ header: PartialSyntaxNodeString , @MemberDeclListBuilder membersBuilder: ( ) throws -> MemberDeclListSyntax ) throws {
103
103
let decl = DeclSyntax ( " \( header) {} " )
104
104
guard let castedDecl = decl. as ( Self . self) else {
105
105
throw SyntaxStringInterpolationError . producedInvalidNodeType ( expectedType: Self . self, actualNode: decl)
106
106
}
107
107
self = castedDecl
108
- self . members = MemberDeclBlockSyntax ( members: membersBuilder ( ) )
108
+ self . members = try MemberDeclBlockSyntax ( members: membersBuilder ( ) )
109
109
}
110
110
}
111
111
@@ -121,14 +121,14 @@ extension StructDeclSyntax: HasTrailingMemberDeclBlock {}
121
121
// So we cannot conform to `HasTrailingCodeBlock`
122
122
123
123
public extension IfStmtSyntax {
124
- init ( _ header: PartialSyntaxNodeString , @CodeBlockItemListBuilder bodyBuilder: ( ) -> CodeBlockItemListSyntax , @CodeBlockItemListBuilder `else` elseBuilder: ( ) -> CodeBlockItemListSyntax ? = { nil } ) throws {
124
+ init ( _ header: PartialSyntaxNodeString , @CodeBlockItemListBuilder bodyBuilder: ( ) throws -> CodeBlockItemListSyntax , @CodeBlockItemListBuilder `else` elseBuilder: ( ) throws -> CodeBlockItemListSyntax ? = { nil } ) throws {
125
125
let stmt = StmtSyntax ( " \( header) {} " )
126
126
guard let ifStmt = stmt. as ( IfStmtSyntax . self) else {
127
127
throw SyntaxStringInterpolationError . producedInvalidNodeType ( expectedType: Self . self, actualNode: stmt)
128
128
}
129
129
self = ifStmt
130
- self . body = CodeBlockSyntax ( statements: bodyBuilder ( ) )
131
- self . elseBody = elseBuilder ( ) . map { . codeBlock( CodeBlockSyntax ( statements: $0) ) }
130
+ self . body = try CodeBlockSyntax ( statements: bodyBuilder ( ) )
131
+ self . elseBody = try elseBuilder ( ) . map { . codeBlock( CodeBlockSyntax ( statements: $0) ) }
132
132
self . elseKeyword = elseBody != nil ? . keyword( . else) : nil
133
133
}
134
134
@@ -149,13 +149,13 @@ public extension IfStmtSyntax {
149
149
// So we cannot conform to `HasTrailingCodeBlock` or `HasTrailingMemberDeclBlock`
150
150
151
151
public extension SwitchStmtSyntax {
152
- init ( _ header: PartialSyntaxNodeString , @SwitchCaseListBuilder casesBuilder: ( ) -> SwitchCaseListSyntax = { SwitchCaseListSyntax ( [ ] ) } ) throws {
152
+ init ( _ header: PartialSyntaxNodeString , @SwitchCaseListBuilder casesBuilder: ( ) throws -> SwitchCaseListSyntax = { SwitchCaseListSyntax ( [ ] ) } ) throws {
153
153
let stmt = StmtSyntax ( " \( header) {} " )
154
154
guard let castedStmt = stmt. as ( Self . self) else {
155
155
throw SyntaxStringInterpolationError . producedInvalidNodeType ( expectedType: Self . self, actualNode: stmt)
156
156
}
157
157
self = castedStmt
158
- self . cases = casesBuilder ( )
158
+ self . cases = try casesBuilder ( )
159
159
}
160
160
}
161
161
@@ -164,15 +164,15 @@ public extension SwitchStmtSyntax {
164
164
// So we cannot conform to `HasTrailingCodeBlock` or `HasTrailingMemberDeclBlock`
165
165
166
166
public extension VariableDeclSyntax {
167
- init ( _ header: PartialSyntaxNodeString , @CodeBlockItemListBuilder accessor: ( ) -> CodeBlockItemListSyntax ) throws {
167
+ init ( _ header: PartialSyntaxNodeString , @CodeBlockItemListBuilder accessor: ( ) throws -> CodeBlockItemListSyntax ) throws {
168
168
let decl = DeclSyntax ( " \( header) {} " )
169
169
guard let castedDecl = decl. as ( Self . self) else {
170
170
throw SyntaxStringInterpolationError . producedInvalidNodeType ( expectedType: Self . self, actualNode: decl)
171
171
}
172
172
self = castedDecl
173
173
assert ( self . bindings. count == 1 )
174
174
var binding : PatternBindingSyntax ? = self . bindings. last
175
- binding? . accessor = . getter( CodeBlockSyntax ( statements: accessor ( ) ) )
175
+ binding? . accessor = try . getter( CodeBlockSyntax ( statements: accessor ( ) ) )
176
176
bindings = PatternBindingListSyntax ( [ binding ] . compactMap { $0 } )
177
177
}
178
178
}
0 commit comments