Skip to content

Commit 2444350

Browse files
authored
Merge pull request #2159 from ahoppen/ahoppen/string-interpolation-fix
Fix a string interpolation error in CodeGeneration
2 parents 361a140 + b12b70c commit 2444350

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

CodeGeneration/Sources/generate-swift-syntax/templates/swiftsyntax/SyntaxBaseNodesFile.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ let syntaxBaseNodesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
285285
}
286286

287287
leafProtocolDecl(type: node.kind.leafProtocolType, inheritedType: node.kind.protocolType)
288+
leafProtocolExtension(type: node.kind.leafProtocolType, inheritedType: node.kind.protocolType)
288289
}
289290

290291
try! ExtensionDeclSyntax(
@@ -314,18 +315,25 @@ let syntaxBaseNodesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
314315
}
315316

316317
leafProtocolDecl(type: "_LeafSyntaxNodeProtocol", inheritedType: "SyntaxProtocol")
318+
leafProtocolExtension(type: "_LeafSyntaxNodeProtocol", inheritedType: "SyntaxProtocol")
317319
}
318320

319321
private func leafProtocolDecl(type: TypeSyntax, inheritedType: TypeSyntax) -> DeclSyntax {
320322
DeclSyntax(
321-
#"""
323+
"""
322324
/// Protocol that syntax nodes conform to if they don't have any semantic subtypes.
323325
/// These are syntax nodes that are not considered base nodes for other syntax types.
324326
///
325327
/// Syntax nodes conforming to this protocol have their inherited casting methods
326328
/// deprecated to prevent incorrect casting.
327-
public protocol \#(type): \#(inheritedType) {}
329+
public protocol \(type): \(inheritedType) {}
330+
"""
331+
)
332+
}
328333

334+
private func leafProtocolExtension(type: TypeSyntax, inheritedType: TypeSyntax) -> DeclSyntax {
335+
DeclSyntax(
336+
#"""
329337
public extension \#(type) {
330338
/// Checks if the current leaf syntax node can be cast to a different specified type.
331339
///

Sources/SwiftSyntax/generated/SyntaxBaseNodes.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ public extension _LeafDeclSyntaxNodeProtocol {
261261
func `is`<S: DeclSyntaxProtocol>(_ syntaxType: S.Type) -> Bool {
262262
return false
263263
}
264+
264265

265266
/// Attempts to cast the current leaf syntax node to a different specified type.
266267
///
@@ -272,6 +273,7 @@ public extension _LeafDeclSyntaxNodeProtocol {
272273
func `as`<S: DeclSyntaxProtocol>(_ syntaxType: S.Type) -> S? {
273274
return nil
274275
}
276+
275277

276278
/// Force-casts the current leaf syntax node to a different specified type.
277279
///
@@ -563,6 +565,7 @@ public extension _LeafExprSyntaxNodeProtocol {
563565
func `is`<S: ExprSyntaxProtocol>(_ syntaxType: S.Type) -> Bool {
564566
return false
565567
}
568+
566569

567570
/// Attempts to cast the current leaf syntax node to a different specified type.
568571
///
@@ -574,6 +577,7 @@ public extension _LeafExprSyntaxNodeProtocol {
574577
func `as`<S: ExprSyntaxProtocol>(_ syntaxType: S.Type) -> S? {
575578
return nil
576579
}
580+
577581

578582
/// Force-casts the current leaf syntax node to a different specified type.
579583
///
@@ -820,6 +824,7 @@ public extension _LeafPatternSyntaxNodeProtocol {
820824
func `is`<S: PatternSyntaxProtocol>(_ syntaxType: S.Type) -> Bool {
821825
return false
822826
}
827+
823828

824829
/// Attempts to cast the current leaf syntax node to a different specified type.
825830
///
@@ -831,6 +836,7 @@ public extension _LeafPatternSyntaxNodeProtocol {
831836
func `as`<S: PatternSyntaxProtocol>(_ syntaxType: S.Type) -> S? {
832837
return nil
833838
}
839+
834840

835841
/// Force-casts the current leaf syntax node to a different specified type.
836842
///
@@ -1087,6 +1093,7 @@ public extension _LeafStmtSyntaxNodeProtocol {
10871093
func `is`<S: StmtSyntaxProtocol>(_ syntaxType: S.Type) -> Bool {
10881094
return false
10891095
}
1096+
10901097

10911098
/// Attempts to cast the current leaf syntax node to a different specified type.
10921099
///
@@ -1098,6 +1105,7 @@ public extension _LeafStmtSyntaxNodeProtocol {
10981105
func `as`<S: StmtSyntaxProtocol>(_ syntaxType: S.Type) -> S? {
10991106
return nil
11001107
}
1108+
11011109

11021110
/// Force-casts the current leaf syntax node to a different specified type.
11031111
///
@@ -1355,6 +1363,7 @@ public extension _LeafTypeSyntaxNodeProtocol {
13551363
func `is`<S: TypeSyntaxProtocol>(_ syntaxType: S.Type) -> Bool {
13561364
return false
13571365
}
1366+
13581367

13591368
/// Attempts to cast the current leaf syntax node to a different specified type.
13601369
///
@@ -1366,6 +1375,7 @@ public extension _LeafTypeSyntaxNodeProtocol {
13661375
func `as`<S: TypeSyntaxProtocol>(_ syntaxType: S.Type) -> S? {
13671376
return nil
13681377
}
1378+
13691379

13701380
/// Force-casts the current leaf syntax node to a different specified type.
13711381
///
@@ -1684,6 +1694,7 @@ public extension _LeafSyntaxNodeProtocol {
16841694
func `is`<S: SyntaxProtocol>(_ syntaxType: S.Type) -> Bool {
16851695
return false
16861696
}
1697+
16871698

16881699
/// Attempts to cast the current leaf syntax node to a different specified type.
16891700
///
@@ -1695,6 +1706,7 @@ public extension _LeafSyntaxNodeProtocol {
16951706
func `as`<S: SyntaxProtocol>(_ syntaxType: S.Type) -> S? {
16961707
return nil
16971708
}
1709+
16981710

16991711
/// Force-casts the current leaf syntax node to a different specified type.
17001712
///

0 commit comments

Comments
 (0)