Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge main into release/6.0 #731

Merged
merged 8 commits into from
May 2, 2024
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
5 changes: 5 additions & 0 deletions .swiftci/5_10_ubuntu2204
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
LinuxSwiftPackageJob {
swift_version_tag = "5.10-jammy"
repo = "swift-format"
branch = "main"
}
5 changes: 5 additions & 0 deletions .swiftci/5_7_ubuntu2204
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
LinuxSwiftPackageJob {
swift_version_tag = "5.7-jammy"
repo = "swift-format"
branch = "main"
}
5 changes: 5 additions & 0 deletions .swiftci/5_8_ubuntu2204
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
LinuxSwiftPackageJob {
swift_version_tag = "5.8-jammy"
repo = "swift-format"
branch = "main"
}
5 changes: 5 additions & 0 deletions .swiftci/5_9_ubuntu2204
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
LinuxSwiftPackageJob {
swift_version_tag = "5.9-jammy"
repo = "swift-format"
branch = "main"
}
5 changes: 5 additions & 0 deletions .swiftci/nightly_6_0_macos
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
macOSSwiftPackageJob {
swift_version = "6.0"
repo = "swift-format"
branch = "main"
}
5 changes: 5 additions & 0 deletions .swiftci/nightly_6_0_ubuntu2204
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
LinuxSwiftPackageJob {
nightly_docker_tag = "nightly-6.0-jammy"
repo = "swift-format"
branch = "main"
}
5 changes: 5 additions & 0 deletions .swiftci/nightly_main_macos
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
macOSSwiftPackageJob {
swift_version = "main"
repo = "swift-format"
branch = "main"
}
5 changes: 5 additions & 0 deletions .swiftci/nightly_main_ubuntu2204
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
LinuxSwiftPackageJob {
nightly_docker_tag = "nightly-jammy"
repo = "swift-format"
branch = "main"
}
7 changes: 7 additions & 0 deletions .swiftci/nightly_main_windows
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
WindowsSwiftPackageWithDockerImageJob {
docker_image = "swiftlang/swift:nightly-windowsservercore-1809"
repo = "swift-format"
branch = "main"
sub_dir = "swift-format"
label = "windows-server-2019"
}
2 changes: 1 addition & 1 deletion Documentation/RuleDocumentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Use the rules below in the `rules` block of your `.swift-format`
configuration file, as described in
[Configuration](Documentation/Configuration.md). All of these rules can be
[Configuration](Configuration.md). All of these rules can be
applied in the linter, but only some of them can format your source code
automatically.

Expand Down
8 changes: 0 additions & 8 deletions Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1350,14 +1350,6 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
}

override func visit(_ node: EnumCaseParameterClauseSyntax) -> SyntaxVisitorContinueKind {
// Prioritize keeping ") throws -> <return_type>" together. We can only do this if the function
// has arguments.
if !node.parameters.isEmpty && config.prioritizeKeepingFunctionOutputTogether {
// Due to visitation order, this .open corresponds to a .close added in FunctionDeclSyntax
// or SubscriptDeclSyntax.
before(node.rightParen, tokens: .open)
}

return .visitChildren
}

Expand Down
12 changes: 12 additions & 0 deletions Tests/SwiftFormatTests/PrettyPrint/EnumDeclTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -559,4 +559,16 @@ final class EnumDeclTests: PrettyPrintTestCase {
let input = "enum Foo { var bar: Int }"
assertPrettyPrintEqual(input: input, expected: input + "\n", linelength: 50)
}

func testEnumWithPrioritizeKeepingFunctionOutputTogetherFlag() {
let input = """
enum Error {
case alreadyOpen(Int)
}

"""
var config = Configuration.forTesting
config.prioritizeKeepingFunctionOutputTogether = true
assertPrettyPrintEqual(input: input, expected: input, linelength: 50, configuration: config)
}
}