From 3062c3a0b329326a7a9230aad236bd42fc215a29 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Fri, 19 Apr 2024 12:48:20 -0700 Subject: [PATCH 1/4] Add post merge Swift CI support for swift-format --- .swiftci/5_10_ubuntu2204 | 5 +++++ .swiftci/5_7_ubuntu2204 | 5 +++++ .swiftci/5_8_ubuntu2204 | 5 +++++ .swiftci/5_9_ubuntu2204 | 5 +++++ .swiftci/nightly_6_0_macos | 5 +++++ .swiftci/nightly_6_0_ubuntu2204 | 5 +++++ .swiftci/nightly_main_macos | 5 +++++ .swiftci/nightly_main_ubuntu2204 | 5 +++++ .swiftci/nightly_main_windows | 7 +++++++ 9 files changed, 47 insertions(+) create mode 100644 .swiftci/5_10_ubuntu2204 create mode 100644 .swiftci/5_7_ubuntu2204 create mode 100644 .swiftci/5_8_ubuntu2204 create mode 100644 .swiftci/5_9_ubuntu2204 create mode 100644 .swiftci/nightly_6_0_macos create mode 100644 .swiftci/nightly_6_0_ubuntu2204 create mode 100644 .swiftci/nightly_main_macos create mode 100644 .swiftci/nightly_main_ubuntu2204 create mode 100644 .swiftci/nightly_main_windows diff --git a/.swiftci/5_10_ubuntu2204 b/.swiftci/5_10_ubuntu2204 new file mode 100644 index 00000000..bc063162 --- /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 00000000..7b7f9623 --- /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 00000000..26077ad9 --- /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 00000000..53e0ebc3 --- /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 00000000..e3c0187c --- /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 00000000..936388e3 --- /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 00000000..72bb76b2 --- /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 00000000..f0337280 --- /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 00000000..2e683db2 --- /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-collections" + label = "windows-server-2019" +} From 58c2ef514d5b8b3766d2d0957b816a8387b01fed Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Fri, 19 Apr 2024 15:29:46 -0700 Subject: [PATCH 2/4] Fix typo in the .swiftci windows testing file --- .swiftci/nightly_main_windows | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.swiftci/nightly_main_windows b/.swiftci/nightly_main_windows index 2e683db2..e3bbb519 100644 --- a/.swiftci/nightly_main_windows +++ b/.swiftci/nightly_main_windows @@ -2,6 +2,6 @@ WindowsSwiftPackageWithDockerImageJob { docker_image = "swiftlang/swift:nightly-windowsservercore-1809" repo = "swift-format" branch = "main" - sub_dir = "swift-collections" + sub_dir = "swift-format" label = "windows-server-2019" } From f93ddbde24c7b9a0353047ad6fbd056553c810dd Mon Sep 17 00:00:00 2001 From: Fawkes Wei Date: Mon, 29 Apr 2024 16:02:21 +0200 Subject: [PATCH 3/4] Update RuleDocumentation.md Fix link to Configuration.md --- Documentation/RuleDocumentation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/RuleDocumentation.md b/Documentation/RuleDocumentation.md index cc3ae92d..654bc8b0 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. From 2dd68a061c5958d52dbb62e89eede2af9be1cca4 Mon Sep 17 00:00:00 2001 From: Shawn Hyam Date: Mon, 29 Apr 2024 10:44:24 -0400 Subject: [PATCH 4/4] Remove check for prioritizeKeepingFunctionOutputTogether on enum decl. --- .../SwiftFormat/PrettyPrint/TokenStreamCreator.swift | 8 -------- .../SwiftFormatTests/PrettyPrint/EnumDeclTests.swift | 12 ++++++++++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift b/Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift index 1023d886..0b96cf02 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 675d75ed..1561d8e8 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) + } }