diff --git a/.swiftci/5_10_ubuntu2204 b/.swiftci/5_10_ubuntu2204 new file mode 100644 index 000000000..bc063162a --- /dev/null +++ b/.swiftci/5_10_ubuntu2204 @@ -0,0 +1,5 @@ +LinuxSwiftPackageJob { + swift_version_tag = "5.10-jammy" + repo = "swift-format" + branch = "main" +} diff --git a/.swiftci/5_7_ubuntu2204 b/.swiftci/5_7_ubuntu2204 new file mode 100644 index 000000000..7b7f96233 --- /dev/null +++ b/.swiftci/5_7_ubuntu2204 @@ -0,0 +1,5 @@ +LinuxSwiftPackageJob { + swift_version_tag = "5.7-jammy" + repo = "swift-format" + branch = "main" +} diff --git a/.swiftci/5_8_ubuntu2204 b/.swiftci/5_8_ubuntu2204 new file mode 100644 index 000000000..26077ad9c --- /dev/null +++ b/.swiftci/5_8_ubuntu2204 @@ -0,0 +1,5 @@ +LinuxSwiftPackageJob { + swift_version_tag = "5.8-jammy" + repo = "swift-format" + branch = "main" +} diff --git a/.swiftci/5_9_ubuntu2204 b/.swiftci/5_9_ubuntu2204 new file mode 100644 index 000000000..53e0ebc31 --- /dev/null +++ b/.swiftci/5_9_ubuntu2204 @@ -0,0 +1,5 @@ +LinuxSwiftPackageJob { + swift_version_tag = "5.9-jammy" + repo = "swift-format" + branch = "main" +} diff --git a/.swiftci/nightly_6_0_macos b/.swiftci/nightly_6_0_macos new file mode 100644 index 000000000..e3c0187c3 --- /dev/null +++ b/.swiftci/nightly_6_0_macos @@ -0,0 +1,5 @@ +macOSSwiftPackageJob { + swift_version = "6.0" + repo = "swift-format" + branch = "main" +} diff --git a/.swiftci/nightly_6_0_ubuntu2204 b/.swiftci/nightly_6_0_ubuntu2204 new file mode 100644 index 000000000..936388e31 --- /dev/null +++ b/.swiftci/nightly_6_0_ubuntu2204 @@ -0,0 +1,5 @@ +LinuxSwiftPackageJob { + nightly_docker_tag = "nightly-6.0-jammy" + repo = "swift-format" + branch = "main" +} diff --git a/.swiftci/nightly_main_macos b/.swiftci/nightly_main_macos new file mode 100644 index 000000000..72bb76b23 --- /dev/null +++ b/.swiftci/nightly_main_macos @@ -0,0 +1,5 @@ +macOSSwiftPackageJob { + swift_version = "main" + repo = "swift-format" + branch = "main" +} diff --git a/.swiftci/nightly_main_ubuntu2204 b/.swiftci/nightly_main_ubuntu2204 new file mode 100644 index 000000000..f0337280a --- /dev/null +++ b/.swiftci/nightly_main_ubuntu2204 @@ -0,0 +1,5 @@ +LinuxSwiftPackageJob { + nightly_docker_tag = "nightly-jammy" + repo = "swift-format" + branch = "main" +} diff --git a/.swiftci/nightly_main_windows b/.swiftci/nightly_main_windows new file mode 100644 index 000000000..e3bbb519b --- /dev/null +++ b/.swiftci/nightly_main_windows @@ -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" +} diff --git a/Documentation/RuleDocumentation.md b/Documentation/RuleDocumentation.md index cc3ae92de..654bc8b04 100644 --- a/Documentation/RuleDocumentation.md +++ b/Documentation/RuleDocumentation.md @@ -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. diff --git a/Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift b/Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift index 1023d886f..0b96cf024 100644 --- a/Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift +++ b/Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift @@ -1350,14 +1350,6 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor { } override func visit(_ node: EnumCaseParameterClauseSyntax) -> SyntaxVisitorContinueKind { - // Prioritize keeping ") throws -> " 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 } diff --git a/Tests/SwiftFormatTests/PrettyPrint/EnumDeclTests.swift b/Tests/SwiftFormatTests/PrettyPrint/EnumDeclTests.swift index 675d75eda..1561d8e8d 100644 --- a/Tests/SwiftFormatTests/PrettyPrint/EnumDeclTests.swift +++ b/Tests/SwiftFormatTests/PrettyPrint/EnumDeclTests.swift @@ -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) + } }