File tree Expand file tree Collapse file tree 1 file changed +9
-11
lines changed
Sources/SwiftSyntaxBuilder Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Original file line number Diff line number Diff line change @@ -43,15 +43,8 @@ public struct SyntaxList: SyntaxListBuildable {
43
43
let builders : [ SyntaxListBuildable ]
44
44
45
45
public func buildSyntaxList( format: Format , leadingTrivia: Trivia ) -> [ Syntax ] {
46
- // Returns indented newlines to join syntaxes
47
- func trivia( for index: Int ) -> Trivia {
48
- leadingTrivia + ( index > builders. startIndex ? . newlines( 1 ) : . zero)
49
- }
50
-
51
- return builders
52
- . enumerated ( )
53
- . flatMap { index, builder in
54
- builder. buildSyntaxList ( format: format, leadingTrivia: trivia ( for: index) )
46
+ builders. flatMap {
47
+ $0. buildSyntaxList ( format: format, leadingTrivia: leadingTrivia)
55
48
}
56
49
}
57
50
}
@@ -75,10 +68,15 @@ public struct SourceFile: SyntaxBuildable {
75
68
let syntaxList = builder. buildSyntaxList ( format: format, leadingTrivia: leadingTrivia)
76
69
77
70
return SourceFileSyntax {
78
- for syntax in syntaxList {
71
+ for (index, syntax) in syntaxList. enumerated ( ) {
72
+ let leadingTrivia : Trivia =
73
+ index == syntaxList. startIndex
74
+ ? format. makeIndent ( )
75
+ : . newlines( 1 ) + format. makeIndent ( )
76
+
79
77
$0. addStatement ( CodeBlockItemSyntax {
80
78
$0. useItem ( syntax)
81
- } )
79
+ } . withLeadingTrivia ( leadingTrivia ) )
82
80
}
83
81
}
84
82
}
You can’t perform that action at this time.
0 commit comments