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