@@ -2735,7 +2735,7 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
2735
2735
extractLeadingTrivia ( token)
2736
2736
closeScopeTokens. forEach ( appendToken)
2737
2737
2738
- generateEnable (
2738
+ generateEnableFormattingIfNecessary (
2739
2739
token. positionAfterSkippingLeadingTrivia ..< token. endPositionBeforeTrailingTrivia
2740
2740
)
2741
2741
@@ -2744,7 +2744,7 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
2744
2744
appendToken ( . syntax( token. presence == . present ? token. text : " " ) )
2745
2745
}
2746
2746
2747
- generateDisable ( token. endPositionBeforeTrailingTrivia)
2747
+ generateDisableFormattingIfNecessary ( token. endPositionBeforeTrailingTrivia)
2748
2748
2749
2749
appendTrailingTrivia ( token)
2750
2750
appendAfterTokensAndTrailingComments ( token)
@@ -2753,15 +2753,15 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
2753
2753
return . skipChildren
2754
2754
}
2755
2755
2756
- func generateEnable ( _ range: Range < AbsolutePosition > ) {
2756
+ private func generateEnableFormattingIfNecessary ( _ range: Range < AbsolutePosition > ) {
2757
2757
if case . infinite = selection { return }
2758
2758
if !isInsideSelection && selection. overlapsOrTouches ( range) {
2759
2759
appendToken ( . enableFormatting( range. lowerBound) )
2760
2760
isInsideSelection = true
2761
2761
}
2762
2762
}
2763
2763
2764
- func generateDisable ( _ position: AbsolutePosition ) {
2764
+ private func generateDisableFormattingIfNecessary ( _ position: AbsolutePosition ) {
2765
2765
if case . infinite = selection { return }
2766
2766
if isInsideSelection && !selection. contains ( position) {
2767
2767
appendToken ( . disableFormatting( position) )
@@ -3270,19 +3270,19 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
3270
3270
switch piece {
3271
3271
case . lineComment( let text) :
3272
3272
if index > 0 || isStartOfFile {
3273
- generateEnable ( position ..< position + piece. sourceLength)
3273
+ generateEnableFormattingIfNecessary ( position ..< position + piece. sourceLength)
3274
3274
appendToken ( . comment( Comment ( kind: . line, text: text) , wasEndOfLine: false ) )
3275
- generateDisable ( position + piece. sourceLength)
3275
+ generateDisableFormattingIfNecessary ( position + piece. sourceLength)
3276
3276
appendNewlines ( . soft)
3277
3277
isStartOfFile = false
3278
3278
}
3279
3279
requiresNextNewline = true
3280
3280
3281
3281
case . blockComment( let text) :
3282
3282
if index > 0 || isStartOfFile {
3283
- generateEnable ( position ..< position + piece. sourceLength)
3283
+ generateEnableFormattingIfNecessary ( position ..< position + piece. sourceLength)
3284
3284
appendToken ( . comment( Comment ( kind: . block, text: text) , wasEndOfLine: false ) )
3285
- generateDisable ( position + piece. sourceLength)
3285
+ generateDisableFormattingIfNecessary ( position + piece. sourceLength)
3286
3286
// There is always a break after the comment to allow a discretionary newline after it.
3287
3287
var breakSize = 0
3288
3288
if index + 1 < trivia. endIndex {
@@ -3297,17 +3297,17 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
3297
3297
requiresNextNewline = false
3298
3298
3299
3299
case . docLineComment( let text) :
3300
- generateEnable ( position ..< position + piece. sourceLength)
3300
+ generateEnableFormattingIfNecessary ( position ..< position + piece. sourceLength)
3301
3301
appendToken ( . comment( Comment ( kind: . docLine, text: text) , wasEndOfLine: false ) )
3302
- generateDisable ( position + piece. sourceLength)
3302
+ generateDisableFormattingIfNecessary ( position + piece. sourceLength)
3303
3303
appendNewlines ( . soft)
3304
3304
isStartOfFile = false
3305
3305
requiresNextNewline = true
3306
3306
3307
3307
case . docBlockComment( let text) :
3308
- generateEnable ( position ..< position + piece. sourceLength)
3308
+ generateEnableFormattingIfNecessary ( position ..< position + piece. sourceLength)
3309
3309
appendToken ( . comment( Comment ( kind: . docBlock, text: text) , wasEndOfLine: false ) )
3310
- generateDisable ( position + piece. sourceLength)
3310
+ generateDisableFormattingIfNecessary ( position + piece. sourceLength)
3311
3311
appendNewlines ( . soft)
3312
3312
isStartOfFile = false
3313
3313
requiresNextNewline = false
0 commit comments