Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Sources/SwiftFormatPrettyPrint/TokenStreamCreator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ private final class TokenStreamCreator: SyntaxVisitor {
}

func visit(_ node: MemberAccessExprSyntax) -> SyntaxVisitorContinueKind {
before(node.dot, tokens: .break(.continue, size: 0))
return .visitChildren
}

Expand Down
23 changes: 23 additions & 0 deletions Tests/SwiftFormatPrettyPrintTests/MemberAccessExprTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
public class MemberAccessExprTests: PrettyPrintTestCase {
public func testMemberAccess() {
let input =
"""
let a = one.two.three.four.five
let b = (c as TypeD).one.two.three.four
"""

let expected =
"""
let a = one.two
.three.four
.five
let b = (
c as TypeD
).one.two.three
.four

"""

assertPrettyPrintEqual(input: input, expected: expected, linelength: 15)
}
}
10 changes: 10 additions & 0 deletions Tests/SwiftFormatPrettyPrintTests/XCTestManifests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,15 @@ extension InitializerDeclTests {
]
}

extension MemberAccessExprTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__MemberAccessExprTests = [
("testMemberAccess", testMemberAccess),
]
}

extension NewlineTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
Expand Down Expand Up @@ -492,6 +501,7 @@ public func __allTests() -> [XCTestCaseEntry] {
testCase(IfStmtTests.__allTests__IfStmtTests),
testCase(ImportTests.__allTests__ImportTests),
testCase(InitializerDeclTests.__allTests__InitializerDeclTests),
testCase(MemberAccessExprTests.__allTests__MemberAccessExprTests),
testCase(NewlineTests.__allTests__NewlineTests),
testCase(ProtocolDeclTests.__allTests__ProtocolDeclTests),
testCase(RepeatStmtTests.__allTests__RepeatStmtTests),
Expand Down