@@ -14,23 +14,6 @@ import SwiftFormatConfiguration
14
14
import SwiftFormatCore
15
15
import SwiftSyntax
16
16
17
- private class FindChildScope : SyntaxVisitor {
18
- var found = false
19
- override func visit( _ node: CodeBlockSyntax ) {
20
- found = true
21
- }
22
- override func visit( _ node: SwitchStmtSyntax ) {
23
- found = true
24
- }
25
- func findChildScope( in items: CodeBlockItemListSyntax ) -> Bool {
26
- for child in items {
27
- visit ( child)
28
- if found { return true }
29
- }
30
- return false
31
- }
32
- }
33
-
34
17
private let rangeOperators : Set = [ " ... " , " ..< " ]
35
18
36
19
private final class TokenStreamCreator : SyntaxVisitor {
@@ -412,15 +395,6 @@ private final class TokenStreamCreator: SyntaxVisitor {
412
395
super. visit ( node)
413
396
}
414
397
415
- func shouldAddOpenCloseNewlines( _ node: Syntax ) -> Bool {
416
- if node is AccessorListSyntax { return true }
417
- guard let list = node as? CodeBlockItemListSyntax else {
418
- return false
419
- }
420
- if list. count > 1 { return true }
421
- return FindChildScope ( ) . findChildScope ( in: list)
422
- }
423
-
424
398
override func visit( _ node: CodeBlockSyntax ) {
425
399
insertToken ( . newline, betweenChildrenOf: node. statements)
426
400
super. visit ( node)
@@ -585,6 +559,9 @@ private final class TokenStreamCreator: SyntaxVisitor {
585
559
}
586
560
587
561
override func visit( _ node: ArrowExprSyntax ) {
562
+ before ( node. throwsToken, tokens: . break)
563
+ before ( node. arrowToken, tokens: . break)
564
+ after ( node. arrowToken, tokens: . break)
588
565
super. visit ( node)
589
566
}
590
567
@@ -1400,14 +1377,6 @@ private final class TokenStreamCreator: SyntaxVisitor {
1400
1377
}
1401
1378
tokens. append ( token)
1402
1379
}
1403
-
1404
- private func shouldAddNewlineBefore( _ token: TokenSyntax ? ) -> Bool {
1405
- guard let token = token, let before = beforeMap [ token] else { return false }
1406
- for item in before {
1407
- if case . newlines = item { return false }
1408
- }
1409
- return true
1410
- }
1411
1380
}
1412
1381
1413
1382
extension Syntax {
0 commit comments