@@ -295,6 +295,12 @@ open class BasicFormat: SyntaxRewriter {
295
295
let previousToken = self . previousToken ?? token. previousToken ( viewMode: viewMode)
296
296
let nextToken = token. nextToken ( viewMode: viewMode)
297
297
298
+ /// In addition to existing trivia of `previousToken`, also considers
299
+ /// `previousToken` as ending with whitespace if it and `token` should be
300
+ /// separated by whitespace.
301
+ /// It does not consider whetehr a newline should be added between
302
+ /// `previousToken` and the `token` because that newline should be added to
303
+ /// the next token's trailing trivia.
298
304
lazy var previousTokenWillEndWithWhitespace : Bool = {
299
305
guard let previousToken = previousToken else {
300
306
return false
@@ -303,6 +309,8 @@ open class BasicFormat: SyntaxRewriter {
303
309
|| ( requiresWhitespace ( between: previousToken, and: token) && isMutable ( previousToken) )
304
310
} ( )
305
311
312
+ /// This method does not consider any posssible mutations to `previousToken`
313
+ /// because newlines should be added to the next token's leading trivia.
306
314
lazy var previousTokenWillEndWithNewline : Bool = {
307
315
guard let previousToken = previousToken else {
308
316
// Assume that the start of the tree is equivalent to a newline so we
@@ -324,6 +332,10 @@ open class BasicFormat: SyntaxRewriter {
324
332
return previousToken. isStringSegmentWithLastCharacterBeingNewline
325
333
} ( )
326
334
335
+ /// Also considers `nextToken` as starting with a whitespace if a newline
336
+ /// should be added to it. It does not check whether `token` and `nextToken`
337
+ /// should be separated by whitespace because the whitespace should be added
338
+ /// to the `token`’s leading trivia.
327
339
lazy var nextTokenWillStartWithWhitespace : Bool = {
328
340
guard let nextToken = nextToken else {
329
341
return false
@@ -332,6 +344,8 @@ open class BasicFormat: SyntaxRewriter {
332
344
|| ( requiresNewline ( between: token, and: nextToken) && isMutable ( nextToken) )
333
345
} ( )
334
346
347
+ /// Also considers `nextToken` as starting with a leading newline if `token`
348
+ /// and `nextToken` should be separated by a newline.
335
349
lazy var nextTokenWillStartWithNewline : Bool = {
336
350
guard let nextToken = nextToken else {
337
351
return false
0 commit comments