Skip to content

Commit e04c5c1

Browse files
authored
Merge pull request #1962 from ahoppen/ahoppen/let-instead-of-lazy-var
2 parents 8105452 + cd4d5cd commit e04c5c1

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Sources/SwiftBasicFormat/BasicFormat.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ open class BasicFormat: SyntaxRewriter {
374374

375375
/// This method does not consider any posssible mutations to `previousToken`
376376
/// because newlines should be added to the next token's leading trivia.
377-
lazy var previousTokenWillEndWithNewline: Bool = {
377+
let previousTokenWillEndWithNewline: Bool = {
378378
guard let previousToken = previousToken else {
379379
// Assume that the start of the tree is equivalent to a newline so we
380380
// don't add a leading newline to the file.
@@ -386,7 +386,7 @@ open class BasicFormat: SyntaxRewriter {
386386
return previousToken.isStringSegmentWithLastCharacterBeingNewline
387387
}()
388388

389-
lazy var previousTokenIsStringLiteralEndingInNewline: Bool = {
389+
let previousTokenIsStringLiteralEndingInNewline: Bool = {
390390
guard let previousToken = previousToken else {
391391
// Assume that the start of the tree is equivalent to a newline so we
392392
// don't add a leading newline to the file.
@@ -409,7 +409,7 @@ open class BasicFormat: SyntaxRewriter {
409409

410410
/// Also considers `nextToken` as starting with a leading newline if `token`
411411
/// and `nextToken` should be separated by a newline.
412-
lazy var nextTokenWillStartWithNewline: Bool = {
412+
let nextTokenWillStartWithNewline: Bool = {
413413
guard let nextToken = nextToken else {
414414
return false
415415
}
@@ -426,16 +426,16 @@ open class BasicFormat: SyntaxRewriter {
426426
return false
427427
}()
428428

429+
var leadingTrivia = token.leadingTrivia
430+
var trailingTrivia = token.trailingTrivia
431+
429432
/// This token's trailing trivia + any spaces or tabs at the start of the
430433
/// next token's leading trivia.
431-
lazy var combinedTrailingTrivia: Trivia = {
434+
let combinedTrailingTrivia: Trivia = {
432435
let nextTokenLeadingWhitespace = nextToken?.leadingTrivia.prefix(while: { $0.isSpaceOrTab }) ?? []
433436
return trailingTrivia + Trivia(pieces: nextTokenLeadingWhitespace)
434437
}()
435438

436-
var leadingTrivia = token.leadingTrivia
437-
var trailingTrivia = token.trailingTrivia
438-
439439
if requiresNewline(between: previousToken, and: token) {
440440
// Add a leading newline if the token requires it unless
441441
// - it already starts with a newline or

0 commit comments

Comments
 (0)