@@ -307,6 +307,12 @@ open class BasicFormat: SyntaxRewriter {
307
307
let previousToken = self . previousToken ?? token. previousToken ( viewMode: viewMode)
308
308
let nextToken = token. nextToken ( viewMode: viewMode)
309
309
310
+ /// In addition to existing trivia of `previousToken`, also considers
311
+ /// `previousToken` as ending with whitespace if it and `token` should be
312
+ /// separated by whitespace.
313
+ /// It does not consider whetehr a newline should be added between
314
+ /// `previousToken` and the `token` because that newline should be added to
315
+ /// the next token's trailing trivia.
310
316
lazy var previousTokenWillEndWithWhitespace : Bool = {
311
317
guard let previousToken = previousToken else {
312
318
return false
@@ -315,6 +321,8 @@ open class BasicFormat: SyntaxRewriter {
315
321
|| ( requiresWhitespace ( between: previousToken, and: token) && isMutable ( previousToken) )
316
322
} ( )
317
323
324
+ /// This method does not consider any posssible mutations to `previousToken`
325
+ /// because newlines should be added to the next token's leading trivia.
318
326
lazy var previousTokenWillEndWithNewline : Bool = {
319
327
guard let previousToken = previousToken else {
320
328
// Assume that the start of the tree is equivalent to a newline so we
@@ -342,6 +350,10 @@ open class BasicFormat: SyntaxRewriter {
342
350
return false
343
351
} ( )
344
352
353
+ /// Also considers `nextToken` as starting with a whitespace if a newline
354
+ /// should be added to it. It does not check whether `token` and `nextToken`
355
+ /// should be separated by whitespace because the whitespace should be added
356
+ /// to the `token`’s leading trivia.
345
357
lazy var nextTokenWillStartWithWhitespace : Bool = {
346
358
guard let nextToken = nextToken else {
347
359
return false
@@ -350,6 +362,8 @@ open class BasicFormat: SyntaxRewriter {
350
362
|| ( requiresLeadingNewline ( nextToken) && isMutable ( nextToken) )
351
363
} ( )
352
364
365
+ /// Also considers `nextToken` as starting with a leading newline if `token`
366
+ /// and `nextToken` should be separated by a newline.
353
367
lazy var nextTokenWillStartWithNewline : Bool = {
354
368
guard let nextToken = nextToken else {
355
369
return false
0 commit comments