@@ -97,14 +97,8 @@ public class CodeGenerationFormat: BasicFormat {
97
97
// Short tuple element list literals are presented on one line, list each element on a different line.
98
98
if children. count > maxElementsOnSameLine {
99
99
let inMethodCallThatStartsOnNewline =
100
- if let functionCallExpr = node. parent? . as ( FunctionCallExprSyntax . self) ,
101
- let memberAccessExpr = functionCallExpr. calledExpression. as ( MemberAccessExprSyntax . self) ,
102
- startsOnNewline ( memberAccessExpr. period)
103
- {
104
- true
105
- } else {
106
- false
107
- }
100
+ node. parent? . as ( FunctionCallExprSyntax . self) ? . calledExpression. as ( MemberAccessExprSyntax . self) ? . period
101
+ . startsOnNewline ?? false
108
102
if inMethodCallThatStartsOnNewline {
109
103
increaseIndentationLevel ( )
110
104
}
@@ -129,7 +123,7 @@ public class CodeGenerationFormat: BasicFormat {
129
123
if indentManually {
130
124
return false
131
125
}
132
- if !startsOnNewline ( node) {
126
+ if !node. startsOnNewline {
133
127
return false
134
128
}
135
129
default :
@@ -166,7 +160,7 @@ public class CodeGenerationFormat: BasicFormat {
166
160
var child = child
167
161
child. trailingTrivia = Trivia ( pieces: child. trailingTrivia. drop ( while: \. isSpaceOrTab) )
168
162
169
- if !startsOnNewline ( child) {
163
+ if !child. startsOnNewline {
170
164
child. leadingTrivia = indentedNewline + child. leadingTrivia
171
165
}
172
166
return child
@@ -186,7 +180,9 @@ public class CodeGenerationFormat: BasicFormat {
186
180
}
187
181
}
188
182
189
- private func startsOnNewline( _ node: some SyntaxProtocol ) -> Bool {
190
- return node. leadingTrivia. contains ( where: \. isNewline)
191
- || node. previousToken ( viewMode: . sourceAccurate) ? . trailingTrivia. contains ( where: \. isNewline) ?? false
183
+ private extension SyntaxProtocol {
184
+ var startsOnNewline : Bool {
185
+ return self . leadingTrivia. contains ( where: \. isNewline)
186
+ || self . previousToken ( viewMode: . sourceAccurate) ? . trailingTrivia. contains ( where: \. isNewline) ?? false
187
+ }
192
188
}
0 commit comments