@@ -14,13 +14,18 @@ import SwiftSyntax
1414
1515// MARK: - PartialSyntaxNode
1616
17+ @available ( * , deprecated, renamed: " SyntaxNodeString " )
18+ public typealias PartialSyntaxNodeString = SyntaxNodeString
19+
1720/// A type that is expressible by string interpolation the same way that syntax
1821/// nodes are, but instead of producing a node, it stores the string interpolation
19- /// text. Used to represent partial syntax nodes in initializers that take a
22+ /// text.
23+ ///
24+ /// Used to represent partial syntax nodes in initializers that take a
2025/// trailing code block.
2126///
2227/// This type should always be constructed using string interpolation.
23- public struct PartialSyntaxNodeString : SyntaxExpressibleByStringInterpolation {
28+ public struct SyntaxNodeString : SyntaxExpressibleByStringInterpolation {
2429 let sourceText : [ UInt8 ]
2530
2631 public init ( stringInterpolation: SyntaxStringInterpolation ) {
@@ -29,7 +34,7 @@ public struct PartialSyntaxNodeString: SyntaxExpressibleByStringInterpolation {
2934}
3035
3136extension SyntaxStringInterpolation {
32- public mutating func appendInterpolation( _ value: PartialSyntaxNodeString ) {
37+ public mutating func appendInterpolation( _ value: SyntaxNodeString ) {
3338 sourceText. append ( contentsOf: value. sourceText)
3439 self . lastIndentation = nil
3540 }
@@ -59,11 +64,11 @@ public protocol HasTrailingCodeBlock {
5964 /// ```
6065 ///
6166 /// Throws an error if `header` defines a different node type than the type the initializer is called on. E.g. if calling `try IfStmtSyntax("while x < 5") {}`
62- init ( _ header: PartialSyntaxNodeString , @CodeBlockItemListBuilder bodyBuilder: ( ) throws -> CodeBlockItemListSyntax ) rethrows
67+ init ( _ header: SyntaxNodeString , @CodeBlockItemListBuilder bodyBuilder: ( ) throws -> CodeBlockItemListSyntax ) rethrows
6368}
6469
6570public extension HasTrailingCodeBlock where Self: StmtSyntaxProtocol {
66- init ( _ header: PartialSyntaxNodeString , @CodeBlockItemListBuilder bodyBuilder: ( ) throws -> CodeBlockItemListSyntax ) throws {
71+ init ( _ header: SyntaxNodeString , @CodeBlockItemListBuilder bodyBuilder: ( ) throws -> CodeBlockItemListSyntax ) throws {
6772 let stmt = StmtSyntax ( " \( header) {} " )
6873 guard let castedStmt = stmt. as ( Self . self) else {
6974 throw SyntaxStringInterpolationError . producedInvalidNodeType ( expectedType: Self . self, actualNode: stmt)
@@ -74,7 +79,7 @@ public extension HasTrailingCodeBlock where Self: StmtSyntaxProtocol {
7479}
7580
7681extension CatchClauseSyntax : HasTrailingCodeBlock {
77- public init ( _ header: PartialSyntaxNodeString , @CodeBlockItemListBuilder bodyBuilder: ( ) throws -> CodeBlockItemListSyntax ) rethrows {
82+ public init ( _ header: SyntaxNodeString , @CodeBlockItemListBuilder bodyBuilder: ( ) throws -> CodeBlockItemListSyntax ) rethrows {
7883 self = CatchClauseSyntax ( " \( header) {} " )
7984 self . body = try CodeBlockSyntax ( statements: bodyBuilder ( ) )
8085 }
@@ -109,11 +114,11 @@ public protocol HasTrailingOptionalCodeBlock {
109114 /// ```
110115 ///
111116 /// Throws an error if `header` defines a different node type than the type the initializer is called on. E.g. if calling `try FunctionDeclSyntax("init") {}`
112- init ( _ header: PartialSyntaxNodeString , @CodeBlockItemListBuilder bodyBuilder: ( ) throws -> CodeBlockItemListSyntax ) throws
117+ init ( _ header: SyntaxNodeString , @CodeBlockItemListBuilder bodyBuilder: ( ) throws -> CodeBlockItemListSyntax ) throws
113118}
114119
115120public extension HasTrailingOptionalCodeBlock where Self: DeclSyntaxProtocol {
116- init ( _ header: PartialSyntaxNodeString , @CodeBlockItemListBuilder bodyBuilder: ( ) throws -> CodeBlockItemListSyntax ) throws {
121+ init ( _ header: SyntaxNodeString , @CodeBlockItemListBuilder bodyBuilder: ( ) throws -> CodeBlockItemListSyntax ) throws {
117122 let decl = DeclSyntax ( " \( header) {} " )
118123 guard let castedDecl = decl. as ( Self . self) else {
119124 throw SyntaxStringInterpolationError . producedInvalidNodeType ( expectedType: Self . self, actualNode: decl)
@@ -154,11 +159,11 @@ public protocol HasTrailingMemberDeclBlock {
154159 /// ```
155160 ///
156161 /// Throws an error if `header` defines a different node type than the type the initializer is called on. E.g. if calling `try StructDeclSyntax("class MyClass") {}`
157- init ( _ header: PartialSyntaxNodeString , @MemberBlockItemListBuilder membersBuilder: ( ) throws -> MemberBlockItemListSyntax ) throws
162+ init ( _ header: SyntaxNodeString , @MemberBlockItemListBuilder membersBuilder: ( ) throws -> MemberBlockItemListSyntax ) throws
158163}
159164
160165public extension HasTrailingMemberDeclBlock where Self: DeclSyntaxProtocol {
161- init ( _ header: PartialSyntaxNodeString , @MemberBlockItemListBuilder membersBuilder: ( ) throws -> MemberBlockItemListSyntax ) throws {
166+ init ( _ header: SyntaxNodeString , @MemberBlockItemListBuilder membersBuilder: ( ) throws -> MemberBlockItemListSyntax ) throws {
162167 let decl = DeclSyntax ( " \( header) {} " )
163168 guard let castedDecl = decl. as ( Self . self) else {
164169 throw SyntaxStringInterpolationError . producedInvalidNodeType ( expectedType: Self . self, actualNode: decl)
@@ -198,7 +203,7 @@ public extension IfExprSyntax {
198203 ///
199204 /// Throws an error if `header` does not start an `if` expression. E.g. if calling `try IfExprSyntax("while true") {}`
200205 init (
201- _ header: PartialSyntaxNodeString ,
206+ _ header: SyntaxNodeString ,
202207 @CodeBlockItemListBuilder bodyBuilder: ( ) throws -> CodeBlockItemListSyntax ,
203208 @CodeBlockItemListBuilder `else` elseBuilder: ( ) throws -> CodeBlockItemListSyntax ? = { nil }
204209 ) throws {
@@ -246,7 +251,7 @@ public extension IfExprSyntax {
246251 /// ```
247252 ///
248253 /// Throws an error if `header` does not start an `if` expression. E.g. if calling `try IfExprSyntax("while true", bodyBuilder: {}, elseIf: {})`
249- init ( _ header: PartialSyntaxNodeString , @CodeBlockItemListBuilder bodyBuilder: ( ) throws -> CodeBlockItemListSyntax , elseIf: IfExprSyntax ) throws {
254+ init ( _ header: SyntaxNodeString , @CodeBlockItemListBuilder bodyBuilder: ( ) throws -> CodeBlockItemListSyntax , elseIf: IfExprSyntax ) throws {
250255 let expr = ExprSyntax ( " \( header) {} " )
251256 guard let ifExpr = expr. as ( Self . self) else {
252257 throw SyntaxStringInterpolationError . producedInvalidNodeType ( expectedType: Self . self, actualNode: expr)
@@ -279,7 +284,7 @@ extension SwitchCaseSyntax {
279284 /// ```
280285 ///
281286 /// Throws an error if `header` does not start a switch case item. E.g. if calling `try SwitchCaseSyntax("func foo") {}`
282- public init ( _ header: PartialSyntaxNodeString , @CodeBlockItemListBuilder statementsBuilder: ( ) throws -> CodeBlockItemListSyntax ) rethrows {
287+ public init ( _ header: SyntaxNodeString , @CodeBlockItemListBuilder statementsBuilder: ( ) throws -> CodeBlockItemListSyntax ) rethrows {
283288 self = SwitchCaseSyntax ( " \( header) " )
284289 self . statements = try statementsBuilder ( )
285290 }
@@ -313,7 +318,7 @@ public extension SwitchExprSyntax {
313318 /// ```
314319 ///
315320 /// Throws an error if `header` does not start a switch expression. E.g. if calling `try SwitchExprSyntax("if x < 42") {}`
316- init ( _ header: PartialSyntaxNodeString , @SwitchCaseListBuilder casesBuilder: ( ) throws -> SwitchCaseListSyntax = { SwitchCaseListSyntax ( [ ] ) } ) throws {
321+ init ( _ header: SyntaxNodeString , @SwitchCaseListBuilder casesBuilder: ( ) throws -> SwitchCaseListSyntax = { SwitchCaseListSyntax ( [ ] ) } ) throws {
317322 let expr = ExprSyntax ( " \( header) {} " )
318323 guard let switchExpr = expr. as ( Self . self) else {
319324 throw SyntaxStringInterpolationError . producedInvalidNodeType ( expectedType: Self . self, actualNode: expr)
@@ -347,7 +352,7 @@ public extension VariableDeclSyntax {
347352 /// ```
348353 ///
349354 /// Throws an error if `header` does not start a variable declaration. E.g. if calling `try VariableDeclSyntax("func foo") {}`
350- init ( _ header: PartialSyntaxNodeString , @CodeBlockItemListBuilder accessor: ( ) throws -> CodeBlockItemListSyntax ) throws {
355+ init ( _ header: SyntaxNodeString , @CodeBlockItemListBuilder accessor: ( ) throws -> CodeBlockItemListSyntax ) throws {
351356 let decl = DeclSyntax ( " \( header) {} " )
352357 guard let castedDecl = decl. as ( Self . self) else {
353358 throw SyntaxStringInterpolationError . producedInvalidNodeType ( expectedType: Self . self, actualNode: decl)
0 commit comments