@@ -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
@@ -325,6 +333,10 @@ open class BasicFormat: SyntaxRewriter {
325
333
return previousToken. isStringLiteralWithLastCharacterBeingNewline
326
334
} ( )
327
335
336
+ /// Also considers `nextToken` as starting with a whitespace if a newline
337
+ /// should be added to it. It does not check whether `token` and `nextToken`
338
+ /// should be separated by whitespace because the whitespace should be added
339
+ /// to the `token`’s leading trivia.
328
340
lazy var nextTokenWillStartWithWhitespace : Bool = {
329
341
guard let nextToken = nextToken else {
330
342
return false
@@ -333,6 +345,8 @@ open class BasicFormat: SyntaxRewriter {
333
345
|| ( requiresNewline ( between: token, and: nextToken) && isMutable ( nextToken) )
334
346
} ( )
335
347
348
+ /// Also considers `nextToken` as starting with a leading newline if `token`
349
+ /// and `nextToken` should be separated by a newline.
336
350
lazy var nextTokenWillStartWithNewline : Bool = {
337
351
guard let nextToken = nextToken else {
338
352
return false
0 commit comments