File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed
Sources/SwiftFormatPrettyPrint
Tests/SwiftFormatPrettyPrintTests Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -406,11 +406,21 @@ private final class TokenStreamCreator: SyntaxVisitor {
406
406
super. visit ( node)
407
407
}
408
408
409
+ override func visit( _ node: CodeBlockItemListSyntax ) {
410
+ if node. parent is AccessorBlockSyntax , node. count > 0 {
411
+ for i in 0 ..< ( node. count - 1 ) {
412
+ after ( node [ i] . lastToken, tokens: . newline)
413
+ }
414
+ }
415
+ super. visit ( node)
416
+ }
417
+
409
418
override func visit( _ node: CodeBlockItemSyntax ) {
410
419
before ( node. firstToken, tokens: . open)
411
420
if !( node. parent? . parent is CodeBlockSyntax ||
412
421
node. parent? . parent is SwitchCaseSyntax ||
413
- node. parent? . parent is ClosureExprSyntax
422
+ node. parent? . parent is ClosureExprSyntax ||
423
+ node. parent? . parent is AccessorBlockSyntax
414
424
) {
415
425
after ( node. lastToken, tokens: . close, . newline)
416
426
} else {
@@ -694,7 +704,7 @@ private final class TokenStreamCreator: SyntaxVisitor {
694
704
695
705
override func visit( _ node: ReturnStmtSyntax ) {
696
706
before ( node. firstToken, tokens: . open)
697
- after ( node. returnKeyword , tokens: . break)
707
+ before ( node. expression ? . firstToken , tokens: . break( offset : 2 ) )
698
708
after ( node. lastToken, tokens: . close)
699
709
super. visit ( node)
700
710
}
Original file line number Diff line number Diff line change @@ -30,6 +30,16 @@ public class AccessorTests: PrettyPrintTestCase {
30
30
}
31
31
}
32
32
}
33
+ struct MyStruct {
34
+ var memberValue: Int
35
+ var SomeValue: Int {
36
+ return 123
37
+ }
38
+ var AnotherValue: Double {
39
+ let out = 1.23
40
+ return out
41
+ }
42
+ }
33
43
"""
34
44
35
45
let expected =
@@ -63,6 +73,14 @@ public class AccessorTests: PrettyPrintTestCase {
63
73
}
64
74
}
65
75
}
76
+ struct MyStruct {
77
+ var memberValue: Int
78
+ var SomeValue: Int { return 123 }
79
+ var AnotherValue: Double {
80
+ let out = 1.23
81
+ return out
82
+ }
83
+ }
66
84
67
85
"""
68
86
You can’t perform that action at this time.
0 commit comments