Skip to content

Commit 6fb0cb9

Browse files
committed
Add documentation for local helper variables
1 parent 550eafd commit 6fb0cb9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Sources/SwiftBasicFormat/BasicFormat.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,12 @@ open class BasicFormat: SyntaxRewriter {
319319
let previousToken = self.previousToken ?? token.previousToken(viewMode: viewMode)
320320
let nextToken = token.nextToken(viewMode: viewMode)
321321

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.
322328
lazy var previousTokenWillEndWithWhitespace: Bool = {
323329
guard let previousToken = previousToken else {
324330
return false
@@ -327,6 +333,8 @@ open class BasicFormat: SyntaxRewriter {
327333
|| (requiresWhitespace(between: previousToken, and: token) && isMutable(previousToken))
328334
}()
329335

336+
/// This method does not consider any posssible mutations to `previousToken`
337+
/// because newlines should be added to the next token's leading trivia.
330338
lazy var previousTokenWillEndWithNewline: Bool = {
331339
guard let previousToken = previousToken else {
332340
// Assume that the start of the tree is equivalent to a newline so we
@@ -354,6 +362,10 @@ open class BasicFormat: SyntaxRewriter {
354362
return false
355363
}()
356364

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.
357369
lazy var nextTokenWillStartWithWhitespace: Bool = {
358370
guard let nextToken = nextToken else {
359371
return false
@@ -362,6 +374,8 @@ open class BasicFormat: SyntaxRewriter {
362374
|| (requiresLeadingNewline(nextToken) && isMutable(nextToken))
363375
}()
364376

377+
/// Also considers `nextToken` as starting with a leading newline if `token`
378+
/// and `nextToken` should be separated by a newline.
365379
lazy var nextTokenWillStartWithNewline: Bool = {
366380
guard let nextToken = nextToken else {
367381
return false

0 commit comments

Comments
 (0)