@@ -307,6 +307,12 @@ open class BasicFormat: SyntaxRewriter {
307307 let previousToken = self . previousToken ?? token. previousToken ( viewMode: viewMode)
308308 let nextToken = token. nextToken ( viewMode: viewMode)
309309
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.
310316 lazy var previousTokenWillEndWithWhitespace : Bool = {
311317 guard let previousToken = previousToken else {
312318 return false
@@ -315,6 +321,8 @@ open class BasicFormat: SyntaxRewriter {
315321 || ( requiresWhitespace ( between: previousToken, and: token) && isMutable ( previousToken) )
316322 } ( )
317323
324+ /// This method does not consider any posssible mutations to `previousToken`
325+ /// because newlines should be added to the next token's leading trivia.
318326 lazy var previousTokenWillEndWithNewline : Bool = {
319327 guard let previousToken = previousToken else {
320328 // Assume that the start of the tree is equivalent to a newline so we
@@ -342,6 +350,10 @@ open class BasicFormat: SyntaxRewriter {
342350 return false
343351 } ( )
344352
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.
345357 lazy var nextTokenWillStartWithWhitespace : Bool = {
346358 guard let nextToken = nextToken else {
347359 return false
@@ -350,6 +362,8 @@ open class BasicFormat: SyntaxRewriter {
350362 || ( requiresLeadingNewline ( nextToken) && isMutable ( nextToken) )
351363 } ( )
352364
365+ /// Also considers `nextToken` as starting with a leading newline if `token`
366+ /// and `nextToken` should be separated by a newline.
353367 lazy var nextTokenWillStartWithNewline : Bool = {
354368 guard let nextToken = nextToken else {
355369 return false
0 commit comments