File tree Expand file tree Collapse file tree 2 files changed +38
-4
lines changed Expand file tree Collapse file tree 2 files changed +38
-4
lines changed Original file line number Diff line number Diff line change @@ -268,6 +268,12 @@ private final class TokenStreamCreator: SyntaxVisitor {
268
268
super. visit ( node)
269
269
}
270
270
271
+ override func visit( _ node: IfConfigClauseSyntax ) {
272
+ after ( node. poundKeyword, tokens: . break)
273
+ after ( node. condition? . lastToken, tokens: . newline)
274
+ super. visit ( node)
275
+ }
276
+
271
277
override func visit( _ node: MemberDeclBlockSyntax ) {
272
278
for i in 0 ..< ( node. members. count - 1 ) {
273
279
after ( node. members [ i] . lastToken, tokens: . newline)
@@ -318,10 +324,6 @@ private final class TokenStreamCreator: SyntaxVisitor {
318
324
super. visit ( node)
319
325
}
320
326
321
- override func visit( _ node: IfConfigClauseSyntax ) {
322
- super. visit ( node)
323
- }
324
-
325
327
override func visit( _ node: EnumCaseElementSyntax ) {
326
328
after ( node. trailingComma, tokens: . break( offset: 2 ) )
327
329
super. visit ( node)
Original file line number Diff line number Diff line change
1
+ public class CompilerControlTests : PrettyPrintTestCase {
2
+ public func testConditionalCompilation( ) {
3
+ let input =
4
+ """
5
+ #if swift(>=4.0)
6
+ print( " Stuff " )
7
+ #endif
8
+ #if swift(>=4.0)
9
+ print( " Stuff " )
10
+ #elseif compiler(>=3.0)
11
+ print( " More Stuff " )
12
+ print( " Another Line " )
13
+ #endif
14
+ """
15
+
16
+ let expected =
17
+ """
18
+ #if swift(>=4.0)
19
+ print( " Stuff " )
20
+ #endif
21
+ #if swift(>=4.0)
22
+ print( " Stuff " )
23
+ #elseif compiler(>=3.0)
24
+ print( " More Stuff " )
25
+ print( " Another Line " )
26
+ #endif
27
+
28
+ """
29
+
30
+ assertPrettyPrintEqual ( input: input, expected: expected, linelength: 45 )
31
+ }
32
+ }
You can’t perform that action at this time.
0 commit comments