@@ -319,6 +319,12 @@ open class BasicFormat: SyntaxRewriter {
319
319
let previousToken = self . previousToken ?? token. previousToken ( viewMode: viewMode)
320
320
let nextToken = token. nextToken ( viewMode: viewMode)
321
321
322
+ /// In addition to existing trivia of `previousToken`, also considers
323
+ /// `previousToken` as ending with whitespace if it and `token` should be
324
+ /// separated by whitespace.
325
+ /// It does not consider whetehr a newline should be added between
326
+ /// `previousToken` and the `token` because that newline should be added to
327
+ /// the next token's trailing trivia.
322
328
lazy var previousTokenWillEndWithWhitespace : Bool = {
323
329
guard let previousToken = previousToken else {
324
330
return false
@@ -327,6 +333,8 @@ open class BasicFormat: SyntaxRewriter {
327
333
|| ( requiresWhitespace ( between: previousToken, and: token) && isMutable ( previousToken) )
328
334
} ( )
329
335
336
+ /// This method does not consider any posssible mutations to `previousToken`
337
+ /// because newlines should be added to the next token's leading trivia.
330
338
lazy var previousTokenWillEndWithNewline : Bool = {
331
339
guard let previousToken = previousToken else {
332
340
// Assume that the start of the tree is equivalent to a newline so we
@@ -354,6 +362,10 @@ open class BasicFormat: SyntaxRewriter {
354
362
return false
355
363
} ( )
356
364
365
+ /// Also considers `nextToken` as starting with a whitespace if a newline
366
+ /// should be added to it. It does not check whether `token` and `nextToken`
367
+ /// should be separated by whitespace because the whitespace should be added
368
+ /// to the `token`’s leading trivia.
357
369
lazy var nextTokenWillStartWithWhitespace : Bool = {
358
370
guard let nextToken = nextToken else {
359
371
return false
@@ -362,6 +374,8 @@ open class BasicFormat: SyntaxRewriter {
362
374
|| ( requiresLeadingNewline ( nextToken) && isMutable ( nextToken) )
363
375
} ( )
364
376
377
+ /// Also considers `nextToken` as starting with a leading newline if `token`
378
+ /// and `nextToken` should be separated by a newline.
365
379
lazy var nextTokenWillStartWithNewline : Bool = {
366
380
guard let nextToken = nextToken else {
367
381
return false
0 commit comments