Skip to content
Draft
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
19 changes: 16 additions & 3 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,34 @@ jobs:
swift /tmp/cross-pr-checkout.swift "${{ github.repository }}" "${{ github.event.number }}"
- name: Build
run: swift build --configuration release
- name: Write check script
run: |
cat > /tmp/check-formatting.sh <<EOL
#!/usr/bin/env sh
set -ex
cd "\$1"
# Format and run 'git diff' first because this yields more insightful results than 'swift-format lint'
.build/release/swift-format --in-place --parallel --recursive .
git diff
# Linting may discover issues that weren't changed during formatting (such as diagnosing lowercase classes). Check that we didn't introduce any new lint errors.
.build/release/swift-format lint --parallel --recursive --strict .
EOL
chmod a+x /tmp/check-formatting.sh
- name: Format swift-format
run: .build/release/swift-format lint --parallel --recursive --strict .
run: /tmp/check-formatting.sh .
- name: Checkout swift-syntax
uses: actions/checkout@v4
with:
repository: swiftlang/swift-syntax
persist-credentials: false
path: swift-syntax
- name: Format swift-syntax
run: .build/release/swift-format lint --parallel --recursive --strict swift-syntax
run: /tmp/check-formatting.sh swift-syntax
- name: Checkout sourcekit-lsp
uses: actions/checkout@v4
with:
repository: swiftlang/sourcekit-lsp
persist-credentials: false
path: sourcekit-lsp
- name: Format sourcekit-lsp
run: .build/release/swift-format lint --parallel --recursive --strict sourcekit-lsp
run: /tmp/check-formatting.sh sourcekit-lsp
3 changes: 3 additions & 0 deletions Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2411,6 +2411,9 @@ private final class TokenStreamCreator: SyntaxVisitor {
)
}

before(node.baseType.firstToken(viewMode: .sourceAccurate), tokens: .open)
after(node.baseType.lastToken(viewMode: .sourceAccurate), tokens: .close)

after(node.lastToken(viewMode: .sourceAccurate), tokens: .close)
return .visitChildren
}
Expand Down
12 changes: 6 additions & 6 deletions Tests/SwiftFormatTests/PrettyPrint/FunctionTypeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -316,15 +316,15 @@ final class FunctionTypeTests: PrettyPrintTestCase {
expected: """
func f(
_ body:
nonisolated(nonsending) ()
async -> Void
nonisolated(nonsending)
() async -> Void
) {}

func f(
_ body:
@Foo @Bar
nonisolated(nonsending) ()
async -> Void
nonisolated(nonsending)
() async -> Void
) {}

func f(
Expand All @@ -336,8 +336,8 @@ final class FunctionTypeTests: PrettyPrintTestCase {
func f(
_ body:
inout @Foo @Bar
nonisolated(nonsending) ()
async -> Void
nonisolated(nonsending)
() async -> Void
) {}

""",
Expand Down
Loading