Skip to content

Commit d4be124

Browse files
dabelknapallevato
authored andcommitted
Add support for imports.
1 parent 29b09a5 commit d4be124

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

Sources/PrettyPrint/TokenStreamCreator.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,9 @@ private final class TokenStreamCreator: SyntaxVisitor {
522522
}
523523

524524
override func visit(_ node: ImportDeclSyntax) {
525+
after(node.attributes?.lastToken, tokens: .space)
526+
after(node.importTok, tokens: .space)
527+
after(node.importKind, tokens: .space)
525528
super.visit(node)
526529
}
527530

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
public class ImportTests: PrettyPrintTestCase {
2+
public func testImports() {
3+
let input =
4+
"""
5+
import someModule
6+
import someLongerModule.withSubmodules
7+
import class MyModule.MyClass
8+
import struct MyModule.MyStruct
9+
@testable import testModule
10+
"""
11+
12+
let expected =
13+
"""
14+
import someModule
15+
import someLongerModule.withSubmodules
16+
import class MyModule.MyClass
17+
import struct MyModule.MyStruct
18+
@testable import testModule
19+
20+
"""
21+
22+
// Imports should not wrap
23+
assertPrettyPrintEqual(input: input, expected: expected, linelength: 5)
24+
}
25+
}

0 commit comments

Comments
 (0)