File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -117,6 +117,12 @@ extension PatternSyntaxProtocol {
117
117
}
118
118
119
119
// String interpolation support for the primary node kinds.
120
+ extension SourceFileSyntax : SyntaxExpressibleByStringInterpolation {
121
+ public static func parse( from parser: inout Parser ) -> Self {
122
+ return Syntax ( raw: parser. parseSourceFile ( ) . raw) . as ( Self . self) !
123
+ }
124
+ }
125
+
120
126
extension DeclSyntax : SyntaxExpressibleByStringInterpolation { }
121
127
extension ExprSyntax : SyntaxExpressibleByStringInterpolation { }
122
128
extension StmtSyntax : SyntaxExpressibleByStringInterpolation { }
Original file line number Diff line number Diff line change @@ -65,6 +65,14 @@ final class StringInterpolationTests: XCTestCase {
65
65
XCTAssertTrue ( structNode. is ( StructDeclSyntax . self) )
66
66
}
67
67
68
+ func testSourceFile( ) throws {
69
+ let _: SourceFileSyntax =
70
+ """
71
+ print( " Hello, world! " )
72
+ """
73
+ }
74
+
75
+
68
76
func testRewriter( ) throws {
69
77
let sourceFile = try Parser . parse ( source: """
70
78
class Foo {
You can’t perform that action at this time.
0 commit comments