@@ -296,6 +296,12 @@ open class BasicFormat: SyntaxRewriter {
296296 let previousToken = self . previousToken ?? token. previousToken ( viewMode: viewMode)
297297 let nextToken = token. nextToken ( viewMode: viewMode)
298298
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.
299305 lazy var previousTokenWillEndWithWhitespace : Bool = {
300306 guard let previousToken = previousToken else {
301307 return false
@@ -304,6 +310,8 @@ open class BasicFormat: SyntaxRewriter {
304310 || ( requiresWhitespace ( between: previousToken, and: token) && isMutable ( previousToken) )
305311 } ( )
306312
313+ /// This method does not consider any posssible mutations to `previousToken`
314+ /// because newlines should be added to the next token's leading trivia.
307315 lazy var previousTokenWillEndWithNewline : Bool = {
308316 guard let previousToken = previousToken else {
309317 // Assume that the start of the tree is equivalent to a newline so we
@@ -331,6 +339,10 @@ open class BasicFormat: SyntaxRewriter {
331339 return false
332340 } ( )
333341
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.
334346 lazy var nextTokenWillStartWithWhitespace : Bool = {
335347 guard let nextToken = nextToken else {
336348 return false
@@ -339,6 +351,8 @@ open class BasicFormat: SyntaxRewriter {
339351 || ( requiresNewline ( between: token, and: nextToken) && isMutable ( nextToken) )
340352 } ( )
341353
354+ /// Also considers `nextToken` as starting with a leading newline if `token`
355+ /// and `nextToken` should be separated by a newline.
342356 lazy var nextTokenWillStartWithNewline : Bool = {
343357 guard let nextToken = nextToken else {
344358 return false
0 commit comments