diff --git a/CHANGELOG.md b/CHANGELOG.md index 07a11bf5d..7841e4d07 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Change Log +## [0.47.3](https://github.com/nicklockwood/SwiftFormat/releases/tag/0.47.3) (2020-11-09) + +- Fixed bug with `extensionAccessControl` increasing extension access level beyond extended type +- Fixed regression with non-standard `.swift-version` contents being flagged as an error +- Fixed bug in `hoistPatternLet` rule when using `--patternlet inline` +- Fixed case where `enumNamespaces` was incorrectly applied +- Fixed indenting of wrapped line starting with a closing paren or brace +- Fixed indenting of blocks starting on same line as a switch case +- Fixed indenting of wrapped closure parameter +- Fixed bug in `--allman` inference + ## [0.47.2](https://github.com/nicklockwood/SwiftFormat/releases/tag/0.47.2) (2020-10-30) - The `markTypes`, `organizeDeclarations` and`extensionAccessControl` rules now respect comment directives @@ -10,7 +21,7 @@ - The `typeSugar` rule is now applied in more cases - Fixed bug in cache logic resulting in slower formatting when using certain config options - Fixed crash in `indent` rule -- Fixed bug in wrapped else indent +- Fixed bug in wrapped `else` indent ## [0.47.1](https://github.com/nicklockwood/SwiftFormat/releases/tag/0.47.1) (2020-10-26) diff --git a/CommandLineTool/swiftformat b/CommandLineTool/swiftformat index f4a168762..74754ca3f 100755 Binary files a/CommandLineTool/swiftformat and b/CommandLineTool/swiftformat differ diff --git a/EditorExtension/SwiftFormat for Xcode.app/Contents/CodeResources b/EditorExtension/SwiftFormat for Xcode.app/Contents/CodeResources index 4dbb434de..70de6f60a 100644 Binary files a/EditorExtension/SwiftFormat for Xcode.app/Contents/CodeResources and b/EditorExtension/SwiftFormat for Xcode.app/Contents/CodeResources differ diff --git a/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftAppKit.dylib b/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftAppKit.dylib index cbac17152..28feae86c 100755 Binary files a/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftAppKit.dylib and b/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftAppKit.dylib differ diff --git a/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftCore.dylib b/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftCore.dylib index 92a71f465..7196e26b1 100755 Binary files a/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftCore.dylib and b/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftCore.dylib differ diff --git a/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftCoreData.dylib b/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftCoreData.dylib index 59615efe6..ae6a837ea 100755 Binary files a/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftCoreData.dylib and b/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftCoreData.dylib differ diff --git a/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftCoreFoundation.dylib b/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftCoreFoundation.dylib index a2a19ae6c..9c1c7c556 100755 Binary files a/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftCoreFoundation.dylib and b/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftCoreFoundation.dylib differ diff --git a/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftCoreGraphics.dylib b/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftCoreGraphics.dylib index e38666895..ee01f2738 100755 Binary files a/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftCoreGraphics.dylib and b/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftCoreGraphics.dylib differ diff --git a/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftCoreImage.dylib b/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftCoreImage.dylib index 9ee52ff82..ce2953507 100755 Binary files a/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftCoreImage.dylib and b/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftCoreImage.dylib differ diff --git a/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftDarwin.dylib b/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftDarwin.dylib index 489621d05..cace01b8e 100755 Binary files a/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftDarwin.dylib and b/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftDarwin.dylib differ diff --git a/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftDispatch.dylib b/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftDispatch.dylib index 3c8ad01a1..4ad5beb9b 100755 Binary files a/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftDispatch.dylib and b/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftDispatch.dylib differ diff --git a/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftFoundation.dylib b/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftFoundation.dylib index 4578a4f8e..cd701bda3 100755 Binary files a/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftFoundation.dylib and b/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftFoundation.dylib differ diff --git a/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftIOKit.dylib b/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftIOKit.dylib index cf9ba29a9..984e317be 100755 Binary files a/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftIOKit.dylib and b/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftIOKit.dylib differ diff --git a/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftMetal.dylib b/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftMetal.dylib index 2c058c64c..970477887 100755 Binary files a/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftMetal.dylib and b/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftMetal.dylib differ diff --git a/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftObjectiveC.dylib b/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftObjectiveC.dylib index de26c1f80..692ac2c8c 100755 Binary files a/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftObjectiveC.dylib and b/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftObjectiveC.dylib differ diff --git a/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftQuartzCore.dylib b/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftQuartzCore.dylib index 8451909f5..c3ddfe7a2 100755 Binary files a/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftQuartzCore.dylib and b/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftQuartzCore.dylib differ diff --git a/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftXPC.dylib b/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftXPC.dylib index ac139cdc9..447669779 100755 Binary files a/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftXPC.dylib and b/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftXPC.dylib differ diff --git a/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftos.dylib b/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftos.dylib index 30f831792..992cd89b7 100755 Binary files a/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftos.dylib and b/EditorExtension/SwiftFormat for Xcode.app/Contents/Frameworks/libswiftos.dylib differ diff --git a/EditorExtension/SwiftFormat for Xcode.app/Contents/Info.plist b/EditorExtension/SwiftFormat for Xcode.app/Contents/Info.plist index a0b17d4d8..8c366e092 100644 --- a/EditorExtension/SwiftFormat for Xcode.app/Contents/Info.plist +++ b/EditorExtension/SwiftFormat for Xcode.app/Contents/Info.plist @@ -3,7 +3,7 @@ BuildMachineOSBuild - 19H2 + 19H15 CFBundleDevelopmentRegion en CFBundleDocumentTypes @@ -36,7 +36,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 0.47.2 + 0.47.3 CFBundleSupportedPlatforms MacOSX diff --git a/EditorExtension/SwiftFormat for Xcode.app/Contents/MacOS/SwiftFormat for Xcode b/EditorExtension/SwiftFormat for Xcode.app/Contents/MacOS/SwiftFormat for Xcode index e27821e45..3e9a96edf 100755 Binary files a/EditorExtension/SwiftFormat for Xcode.app/Contents/MacOS/SwiftFormat for Xcode and b/EditorExtension/SwiftFormat for Xcode.app/Contents/MacOS/SwiftFormat for Xcode differ diff --git a/EditorExtension/SwiftFormat for Xcode.app/Contents/PlugIns/SwiftFormat.appex/Contents/Frameworks/XcodeKit.framework/Versions/A/XcodeKit b/EditorExtension/SwiftFormat for Xcode.app/Contents/PlugIns/SwiftFormat.appex/Contents/Frameworks/XcodeKit.framework/Versions/A/XcodeKit index 63671f922..ac39e8fc5 100755 Binary files a/EditorExtension/SwiftFormat for Xcode.app/Contents/PlugIns/SwiftFormat.appex/Contents/Frameworks/XcodeKit.framework/Versions/A/XcodeKit and b/EditorExtension/SwiftFormat for Xcode.app/Contents/PlugIns/SwiftFormat.appex/Contents/Frameworks/XcodeKit.framework/Versions/A/XcodeKit differ diff --git a/EditorExtension/SwiftFormat for Xcode.app/Contents/PlugIns/SwiftFormat.appex/Contents/Info.plist b/EditorExtension/SwiftFormat for Xcode.app/Contents/PlugIns/SwiftFormat.appex/Contents/Info.plist index b20fcdaa6..68ef331f9 100644 --- a/EditorExtension/SwiftFormat for Xcode.app/Contents/PlugIns/SwiftFormat.appex/Contents/Info.plist +++ b/EditorExtension/SwiftFormat for Xcode.app/Contents/PlugIns/SwiftFormat.appex/Contents/Info.plist @@ -3,7 +3,7 @@ BuildMachineOSBuild - 19H2 + 19H15 CFBundleDevelopmentRegion en CFBundleExecutable @@ -17,7 +17,7 @@ CFBundlePackageType XPC! CFBundleShortVersionString - 0.47.2 + 0.47.3 CFBundleSupportedPlatforms MacOSX diff --git a/EditorExtension/SwiftFormat for Xcode.app/Contents/PlugIns/SwiftFormat.appex/Contents/MacOS/SwiftFormat b/EditorExtension/SwiftFormat for Xcode.app/Contents/PlugIns/SwiftFormat.appex/Contents/MacOS/SwiftFormat index a42057d21..2b545c83d 100755 Binary files a/EditorExtension/SwiftFormat for Xcode.app/Contents/PlugIns/SwiftFormat.appex/Contents/MacOS/SwiftFormat and b/EditorExtension/SwiftFormat for Xcode.app/Contents/PlugIns/SwiftFormat.appex/Contents/MacOS/SwiftFormat differ diff --git a/EditorExtension/SwiftFormat for Xcode.app/Contents/Resources/Assets.car b/EditorExtension/SwiftFormat for Xcode.app/Contents/Resources/Assets.car index 9506ca558..d79fae4a6 100644 Binary files a/EditorExtension/SwiftFormat for Xcode.app/Contents/Resources/Assets.car and b/EditorExtension/SwiftFormat for Xcode.app/Contents/Resources/Assets.car differ diff --git a/EditorExtension/SwiftFormat for Xcode.app/Contents/Resources/Base.lproj/Main.storyboardc/9ZR-Qg-hHT-view-iDF-FY-6tf.nib b/EditorExtension/SwiftFormat for Xcode.app/Contents/Resources/Base.lproj/Main.storyboardc/9ZR-Qg-hHT-view-iDF-FY-6tf.nib index 6e35f96de..cbcff3027 100644 Binary files a/EditorExtension/SwiftFormat for Xcode.app/Contents/Resources/Base.lproj/Main.storyboardc/9ZR-Qg-hHT-view-iDF-FY-6tf.nib and b/EditorExtension/SwiftFormat for Xcode.app/Contents/Resources/Base.lproj/Main.storyboardc/9ZR-Qg-hHT-view-iDF-FY-6tf.nib differ diff --git a/EditorExtension/SwiftFormat for Xcode.app/Contents/Resources/Base.lproj/Main.storyboardc/Info.plist b/EditorExtension/SwiftFormat for Xcode.app/Contents/Resources/Base.lproj/Main.storyboardc/Info.plist index adf2d141e..6c5801282 100644 Binary files a/EditorExtension/SwiftFormat for Xcode.app/Contents/Resources/Base.lproj/Main.storyboardc/Info.plist and b/EditorExtension/SwiftFormat for Xcode.app/Contents/Resources/Base.lproj/Main.storyboardc/Info.plist differ diff --git a/EditorExtension/SwiftFormat for Xcode.app/Contents/Resources/Base.lproj/Main.storyboardc/MainMenu.nib b/EditorExtension/SwiftFormat for Xcode.app/Contents/Resources/Base.lproj/Main.storyboardc/MainMenu.nib index 30f2f2d22..410b413c1 100644 Binary files a/EditorExtension/SwiftFormat for Xcode.app/Contents/Resources/Base.lproj/Main.storyboardc/MainMenu.nib and b/EditorExtension/SwiftFormat for Xcode.app/Contents/Resources/Base.lproj/Main.storyboardc/MainMenu.nib differ diff --git a/EditorExtension/SwiftFormat for Xcode.app/Contents/Resources/Base.lproj/Main.storyboardc/MainWindowTabViewController.nib b/EditorExtension/SwiftFormat for Xcode.app/Contents/Resources/Base.lproj/Main.storyboardc/MainWindowTabViewController.nib index ffa3fe013..993465c8c 100644 Binary files a/EditorExtension/SwiftFormat for Xcode.app/Contents/Resources/Base.lproj/Main.storyboardc/MainWindowTabViewController.nib and b/EditorExtension/SwiftFormat for Xcode.app/Contents/Resources/Base.lproj/Main.storyboardc/MainWindowTabViewController.nib differ diff --git a/EditorExtension/SwiftFormat for Xcode.app/Contents/Resources/Base.lproj/Main.storyboardc/NSWindowController-B8D-0N-5wS.nib b/EditorExtension/SwiftFormat for Xcode.app/Contents/Resources/Base.lproj/Main.storyboardc/NSWindowController-B8D-0N-5wS.nib index 48f5de0db..1eeabd834 100644 Binary files a/EditorExtension/SwiftFormat for Xcode.app/Contents/Resources/Base.lproj/Main.storyboardc/NSWindowController-B8D-0N-5wS.nib and b/EditorExtension/SwiftFormat for Xcode.app/Contents/Resources/Base.lproj/Main.storyboardc/NSWindowController-B8D-0N-5wS.nib differ diff --git a/EditorExtension/SwiftFormat for Xcode.app/Contents/Resources/Base.lproj/Main.storyboardc/RulesViewController.nib b/EditorExtension/SwiftFormat for Xcode.app/Contents/Resources/Base.lproj/Main.storyboardc/RulesViewController.nib index b8c224bd6..3180d8806 100644 Binary files a/EditorExtension/SwiftFormat for Xcode.app/Contents/Resources/Base.lproj/Main.storyboardc/RulesViewController.nib and b/EditorExtension/SwiftFormat for Xcode.app/Contents/Resources/Base.lproj/Main.storyboardc/RulesViewController.nib differ diff --git a/EditorExtension/SwiftFormat for Xcode.app/Contents/_CodeSignature/CodeResources b/EditorExtension/SwiftFormat for Xcode.app/Contents/_CodeSignature/CodeResources index 979914596..990a72b3e 100644 --- a/EditorExtension/SwiftFormat for Xcode.app/Contents/_CodeSignature/CodeResources +++ b/EditorExtension/SwiftFormat for Xcode.app/Contents/_CodeSignature/CodeResources @@ -10,31 +10,31 @@ Resources/Assets.car - 2YoZ0Da4mCpyFL3PmNUqjhBclNs= + TTIWe4xVphrMC6YH1bZfmAfPhOo= Resources/Base.lproj/Main.storyboardc/9ZR-Qg-hHT-view-iDF-FY-6tf.nib - uK0RdX+b6+vbxkOLrHaoPCs6Qjs= + G5nqQn5muMKa4p4zKHZmdmrjxEo= Resources/Base.lproj/Main.storyboardc/Info.plist - BIuGtXwJ0nQ6i3Jzplnk400HNdk= + Bn4JObhT6MXI+HZ2GTUfZWtql2k= Resources/Base.lproj/Main.storyboardc/MainMenu.nib - oGw9ifNwr412P+UMqHHJw6ApbcA= + JZ/kqd07Vfly2KgaliPkcX08L9I= Resources/Base.lproj/Main.storyboardc/MainWindowTabViewController.nib - PoGRzWVI+b9U/8s1YS6Um+uHrkc= + yCCf0r408inabwo9LHE+JqzFXWQ= Resources/Base.lproj/Main.storyboardc/NSWindowController-B8D-0N-5wS.nib - u1K8Kor8nYLX5gqVMLgPw0hLx7U= + BUryZ7jyzjTBnVfeonLgAC8u10Y= Resources/Base.lproj/Main.storyboardc/RulesViewController.nib - O4mwayiFJtYMfiUA1h3Gtd54qRc= + bTOrfjf3y5eVX/CGEx3XYkHn0GM= Resources/Base.lproj/Main.storyboardc/XfG-lQ-9wD-view-m2S-Jp-Qdl.nib @@ -182,7 +182,7 @@ cdhash - zZ/v9o5QtoBHScfchRt5iXcOy8s= + 0JJUi8QMfQkhq0lgVuecOyByUoY= requirement anchor apple generic and identifier "com.charcoaldesign.SwiftFormat-for-Xcode.SourceEditorExtension" and (certificate leaf[field.1.2.840.113635.100.6.1.9] /* exists */ or certificate 1[field.1.2.840.113635.100.6.2.6] /* exists */ and certificate leaf[field.1.2.840.113635.100.6.1.13] /* exists */ and certificate leaf[subject.OU] = "8VQKF583ED") @@ -198,49 +198,49 @@ hash2 - MIAZxr1q5EwSj3eZ5pzHDdZgF7eCLCnNlNtQpSulsqY= + cN8Y4tXG4NJHzWIFFfn5cl/ZGWQYWccMlk9cdpIFibY= Resources/Base.lproj/Main.storyboardc/9ZR-Qg-hHT-view-iDF-FY-6tf.nib hash2 - vjwuubSANur9RETgkHarQW5s6tFV8341IQ2KWPrYYnY= + cAJixDO8vnHRPuPlUxTSoRApM7smXTdBA8XNVfkbGKE= Resources/Base.lproj/Main.storyboardc/Info.plist hash2 - 8sKJbJR71o+HVV9/1iVfRXocX0svNGwGDdNlUo8IZM4= + meha+4BnRJUJx1a/7Uo9hJt25m3JiWJNLUwN/DBwYfM= Resources/Base.lproj/Main.storyboardc/MainMenu.nib hash2 - o/Qc9h2AuuCEroeMHtB5Q6qYbFEzAB8Pg1V3kXhKu0A= + TbAVKio9lyh/dlN2NX3C4UWBD25yQ6n73ACVmLQgsfI= Resources/Base.lproj/Main.storyboardc/MainWindowTabViewController.nib hash2 - zRLyr25uGW7p+Z1laOd6Fyvkg27MnoFT8pNguJPnUpI= + +vcMmCCxUhQhR5ws5C8B6fJR/znkvMYoSFIF2rQw9LY= Resources/Base.lproj/Main.storyboardc/NSWindowController-B8D-0N-5wS.nib hash2 - 277VFl3yoYtkGDhHRk2yD6OtFiX9hyJwQ3cU2wTlFMA= + 4KAJQYHV0ZT0s61v9YozpPYV7H/8TlnMtgaIwdmeCNk= Resources/Base.lproj/Main.storyboardc/RulesViewController.nib hash2 - FCIkFV/qbvR+IeBBu1Y3YzsoA6jpuvUITbVb8KYebf0= + VZIk3ug+n6mzPkm677pon2T3xPgfuibGQ50EhYcDNl0= Resources/Base.lproj/Main.storyboardc/XfG-lQ-9wD-view-m2S-Jp-Qdl.nib diff --git a/README.md b/README.md index 923e50cf9..2081a712b 100644 --- a/README.md +++ b/README.md @@ -747,7 +747,7 @@ Known issues * When using the `initCoderUnavailable` rule, if an `init` that is marked as unavailable is overridden elsewhere in the program then it will cause a compilation error. The recommended workaround is to remove the override (which shouldn't affect the program behavior if the init was really unused) or use the `// swiftformat:disable:next initCoderUnavailable` comment directive to disable the rule for the overridden init (or just disable the `initCoderUnavailable` rule completely). -* When using the `extensionAccessControl` rule with the `--extensionacl on-extension` option, if you have public methods defined on an internal or private type, the resultant public extension will no longer compile. The recommended solution is to manually remove the `public` modifier (this won't change the program behavior) or disable the `extensionAccessControl` rule. +* When using the `extensionAccessControl` rule with the `--extensionacl on-extension` option, if you have public methods defined on an internal type defined in another file, the resultant public extension will no longer compile. The recommended solution is to manually remove the `public` modifier (this won't change the program behavior) or disable the `extensionAccessControl` rule. * When using the `preferKeyPath` rule, conversion of `compactMap { $0.foo }` to `compactMap(\.foo)` will result in code that fails to compile if `foo` is not an `Optional` property. This is due to a difference in the way that Swift handles type inference for closures vs keyPaths, as discussed [here](https://bugs.swift.org/browse/SR-13347). The recommended workaround is to replace `compactMap()` with `map()` in these cases, which will not change the behavior of the code. diff --git a/Snapshots/Issues/406.swift b/Snapshots/Issues/406.swift index 9d0202074..b82e1b5cc 100644 --- a/Snapshots/Issues/406.swift +++ b/Snapshots/Issues/406.swift @@ -32,8 +32,7 @@ SessionManager SessionManager .shared .validateSession() - .switchMap - { _ -> Observable in + .switchMap { _ -> Observable in someCode() } .switchMap { diff --git a/Sources/Formatter.swift b/Sources/Formatter.swift index 83f303dab..629ea29a9 100644 --- a/Sources/Formatter.swift +++ b/Sources/Formatter.swift @@ -2,7 +2,7 @@ // Formatter.swift // SwiftFormat // -// Version 0.47.2 +// Version 0.47.3 // // Created by Nick Lockwood on 12/08/2016. // Copyright 2016 Nick Lockwood diff --git a/Sources/Inference.swift b/Sources/Inference.swift index 50c1fa832..72359fa42 100644 --- a/Sources/Inference.swift +++ b/Sources/Inference.swift @@ -594,8 +594,7 @@ private struct Inference { return false // Keep looking } }), formatter.tokens[bodyStartIndex] == .startOfScope("{"), - let bodyEndIndex = formatter.index(of: .endOfScope("}"), after: bodyStartIndex) - else { + let bodyEndIndex = formatter.index(of: .endOfScope("}"), after: bodyStartIndex) else { return } removeUsed(from: &argNames, with: &nameIndices, in: bodyStartIndex + 1 ..< bodyEndIndex) diff --git a/Sources/ParsingHelpers.swift b/Sources/ParsingHelpers.swift index f5d30fe8a..a960a57a4 100644 --- a/Sources/ParsingHelpers.swift +++ b/Sources/ParsingHelpers.swift @@ -1417,12 +1417,11 @@ extension Formatter { guard let commaIndex = self.index(of: .nonSpaceOrCommentOrLinebreak, before: index + 1, if: { $0 == .delimiter(",") }), case let lineStart = startOfLine(at: commaIndex), - let firstToken = self.index(of: .nonSpace, after: lineStart - 1), - let firstNonBrace = (firstToken ..< commaIndex).first(where: { - let token = self.tokens[$0] - return !token.isEndOfScope && !token.isSpaceOrComment - }) - else { + let firstToken = self.index(of: .nonSpace, after: lineStart - 1), + let firstNonBrace = (firstToken ..< commaIndex).first(where: { + let token = self.tokens[$0] + return !token.isEndOfScope && !token.isSpaceOrComment + }) else { return options.indent } if case .endOfScope = tokens[firstToken], @@ -1434,9 +1433,7 @@ extension Formatter { [.keyword("if"), .keyword("guard"), .keyword("while")].contains($0) }) ?? lastIndex(in: firstNonBrace ..< commaIndex, where: { [.keyword("let"), .keyword("var"), .keyword("case")].contains($0) - }), - let nextTokenIndex = self.index(of: .nonSpace, after: keywordIndex) - else { + }), let nextTokenIndex = self.index(of: .nonSpace, after: keywordIndex) else { return options.indent } return spaceEquivalentToTokens(from: firstToken, upTo: nextTokenIndex) diff --git a/Sources/Rules.swift b/Sources/Rules.swift index 781c58948..9bb5774e6 100644 --- a/Sources/Rules.swift +++ b/Sources/Rules.swift @@ -645,8 +645,8 @@ public struct _FormatRules { guard let colonIndex = formatter.index(after: i, where: { [.delimiter(":"), .operator("=", .infix)].contains($0) }), formatter.tokens[colonIndex] == .delimiter(":"), - let equalsIndex = formatter.index(of: .operator("=", .infix), after: colonIndex), - let endIndex = formatter.index(of: .nonSpaceOrCommentOrLinebreak, before: equalsIndex) + let equalsIndex = formatter.index(of: .operator("=", .infix), after: colonIndex), + let endIndex = formatter.index(of: .nonSpaceOrCommentOrLinebreak, before: equalsIndex) else { return } // Check types match @@ -1275,10 +1275,9 @@ public struct _FormatRules { guard let lastIndex = formatter.index(of: .nonSpaceOrComment, before: i, if: { $0 == .endOfScope(")") }), let startIndex = formatter.index(of: .startOfScope("("), before: lastIndex), - formatter.tokens[startIndex ..< lastIndex].contains(where: { - if case .linebreak = $0 { return true } else { return false } - }) - else { + formatter.tokens[startIndex ..< lastIndex].contains(where: { + if case .linebreak = $0 { return true } else { return false } + }) else { break } indentStack[indentStack.count - 1] += formatter.options.indent @@ -1571,7 +1570,7 @@ public struct _FormatRules { }), let coderIndex = formatter.index(of: .nonSpaceOrCommentOrLinebreak, after: parenIndex, if: { $0 == .identifier("coder") }), let endParenIndex = formatter.index(of: .endOfScope(")"), after: coderIndex), - let braceIndex = formatter.index(of: .startOfScope("{"), after: endParenIndex) + let braceIndex = formatter.index(of: .startOfScope("{"), after: endParenIndex) else { return } // make sure the implementation is empty or fatalError @@ -1695,8 +1694,7 @@ public struct _FormatRules { if let endIndex = formatter.index(of: .nonSpaceOrCommentOrLinebreak, before: i, if: { $0 == .endOfScope("}") }), let startIndex = formatter.index(of: .startOfScope("{"), before: endIndex), - formatter.last(.nonSpaceOrCommentOrLinebreak, before: startIndex) == .keyword("repeat") - { + formatter.last(.nonSpaceOrCommentOrLinebreak, before: startIndex) == .keyword("repeat") { fallthrough } case .keyword("else"): @@ -2170,8 +2168,7 @@ public struct _FormatRules { guard let nextIndex = formatter.index(of: .nonSpaceOrComment, after: i, if: { $0 == .startOfScope("{") }), let lastIndex = formatter.index(of: .endOfScope("}"), after: nextIndex), - formatter.index(of: .nonSpaceOrComment, before: closingIndex) == lastIndex - else { + formatter.index(of: .nonSpaceOrComment, before: closingIndex) == lastIndex else { fallthrough } formatter.removeParen(at: closingIndex) @@ -2392,8 +2389,7 @@ public struct _FormatRules { ), let colonIndex = formatter.index( of: .nonSpaceOrCommentOrLinebreak, after: nameIndex, if: { $0 == .delimiter(":") } ), formatter.next(.nonSpaceOrCommentOrLinebreak, after: colonIndex) == .identifier("String"), - let braceIndex = formatter.index(of: .startOfScope("{"), after: colonIndex) - else { + let braceIndex = formatter.index(of: .startOfScope("{"), after: colonIndex) else { return } var lastIndex = formatter.index(of: .keyword("case"), after: braceIndex) @@ -3273,8 +3269,7 @@ public struct _FormatRules { return false // Keep looking } }), formatter.tokens[bodyStartIndex] == .startOfScope("{"), - let bodyEndIndex = formatter.index(of: .endOfScope("}"), after: bodyStartIndex) - else { + let bodyEndIndex = formatter.index(of: .endOfScope("}"), after: bodyStartIndex) else { return } removeUsed(from: &argNames, with: &nameIndexPairs, in: bodyStartIndex + 1 ..< bodyEndIndex) @@ -3690,8 +3685,7 @@ public struct _FormatRules { guard let endIndex = formatter.index(of: .nonSpaceOrLinebreak, after: i, if: { $0 == .endOfScope(")") }), let prevToken = formatter.last(.nonSpaceOrCommentOrLinebreak, before: i), - !isArgumentToken(at: endIndex) - else { + !isArgumentToken(at: endIndex) else { return } if formatter.last(.nonSpaceOrCommentOrLinebreak, before: i) == .operator("->", .infix) { @@ -3932,11 +3926,10 @@ public struct _FormatRules { }), let openParenIndex = formatter.index(of: .nonSpaceOrCommentOrLinebreak, after: i, if: { $0 == .startOfScope("(") }), let closeParenIndex = formatter.index(of: .endOfScope(")"), after: openParenIndex), - formatter.last(.nonSpaceOrCommentOrLinebreak, before: closeParenIndex) != .delimiter(":"), - let prevToken = formatter.last(.nonSpaceOrCommentOrLinebreak, before: dotIndex), - case let .identifier(name) = prevToken, let firstChar = name.first, - firstChar != "$", String(firstChar).uppercased() == String(firstChar) - else { + formatter.last(.nonSpaceOrCommentOrLinebreak, before: closeParenIndex) != .delimiter(":"), + let prevToken = formatter.last(.nonSpaceOrCommentOrLinebreak, before: dotIndex), + case let .identifier(name) = prevToken, let firstChar = name.first, + firstChar != "$", String(firstChar).uppercased() == String(firstChar) else { return } formatter.removeTokens(in: dotIndex ... i) @@ -4501,8 +4494,7 @@ public struct _FormatRules { acl = $1 return aclModifiers.contains(acl) }), let startIndex = formatter.index(of: .startOfScope("{"), after: i), - var endIndex = formatter.index(of: .endOfScope("}"), after: startIndex) - else { + var endIndex = formatter.index(of: .endOfScope("}"), after: startIndex) else { return } if acl == "private" { acl = "fileprivate" } @@ -4606,11 +4598,10 @@ public struct _FormatRules { guard let nameIndex = formatter.index(of: .nonSpaceOrCommentOrLinebreak, after: i, if: { $0.isIdentifier }), let openBraceIndex = formatter.index(of: .startOfScope("{"), after: nameIndex), - let colonIndex = - formatter.index(of: .delimiter(":"), in: nameIndex + 1 ..< openBraceIndex), - formatter.index(of: .identifier(className), in: colonIndex + 1 ..< openBraceIndex) - != nil - else { + let colonIndex = + formatter.index(of: .delimiter(":"), in: nameIndex + 1 ..< openBraceIndex), + formatter.index(of: .identifier(className), in: colonIndex + 1 ..< openBraceIndex) + != nil else { continue } // TODO: check if member names are actually referenced diff --git a/Sources/SwiftFormat.swift b/Sources/SwiftFormat.swift index 7beb4415a..50604eb0d 100644 --- a/Sources/SwiftFormat.swift +++ b/Sources/SwiftFormat.swift @@ -32,7 +32,7 @@ import Foundation /// The current SwiftFormat version -let swiftFormatVersion = "0.47.2" +let swiftFormatVersion = "0.47.3" public let version = swiftFormatVersion /// The standard SwiftFormat config file name diff --git a/Sources/Tokenizer.swift b/Sources/Tokenizer.swift index de29db1eb..5072f818f 100644 --- a/Sources/Tokenizer.swift +++ b/Sources/Tokenizer.swift @@ -2,7 +2,7 @@ // Tokenizer.swift // SwiftFormat // -// Version 0.47.2 +// Version 0.47.3 // // Created by Nick Lockwood on 11/08/2016. // Copyright 2016 Nick Lockwood diff --git a/SwiftFormat.podspec.json b/SwiftFormat.podspec.json index a0a1f0092..a1caea0f5 100644 --- a/SwiftFormat.podspec.json +++ b/SwiftFormat.podspec.json @@ -1,6 +1,6 @@ { "name": "SwiftFormat", - "version": "0.47.2", + "version": "0.47.3", "license": { "type": "MIT", "file": "LICENSE.md" @@ -10,7 +10,7 @@ "authors": "Nick Lockwood", "source": { "git": "https://github.com/nicklockwood/SwiftFormat.git", - "tag": "0.47.2" + "tag": "0.47.3" }, "default_subspecs": "Core", "subspecs": [ diff --git a/SwiftFormat.xcodeproj/project.pbxproj b/SwiftFormat.xcodeproj/project.pbxproj index e4ced111b..495290183 100644 --- a/SwiftFormat.xcodeproj/project.pbxproj +++ b/SwiftFormat.xcodeproj/project.pbxproj @@ -1122,7 +1122,7 @@ INFOPLIST_FILE = Sources/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; - MARKETING_VERSION = 0.47.2; + MARKETING_VERSION = 0.47.3; PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.SwiftFormat; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; @@ -1146,7 +1146,7 @@ INFOPLIST_FILE = Sources/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; - MARKETING_VERSION = 0.47.2; + MARKETING_VERSION = 0.47.3; PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.SwiftFormat; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; @@ -1222,7 +1222,7 @@ INFOPLIST_FILE = EditorExtension/Application/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.14; - MARKETING_VERSION = 0.47.2; + MARKETING_VERSION = 0.47.3; PRODUCT_BUNDLE_IDENTIFIER = "com.charcoaldesign.SwiftFormat-for-Xcode"; PRODUCT_NAME = "SwiftFormat for Xcode"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1249,7 +1249,7 @@ INFOPLIST_FILE = EditorExtension/Application/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.14; - MARKETING_VERSION = 0.47.2; + MARKETING_VERSION = 0.47.3; PRODUCT_BUNDLE_IDENTIFIER = "com.charcoaldesign.SwiftFormat-for-Xcode"; PRODUCT_NAME = "SwiftFormat for Xcode"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1273,7 +1273,7 @@ INFOPLIST_FILE = EditorExtension/Extension/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @executable_path/../../../../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.14; - MARKETING_VERSION = 0.47.2; + MARKETING_VERSION = 0.47.3; PRODUCT_BUNDLE_IDENTIFIER = "com.charcoaldesign.SwiftFormat-for-Xcode.SourceEditorExtension"; PRODUCT_NAME = SwiftFormat; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1299,7 +1299,7 @@ INFOPLIST_FILE = EditorExtension/Extension/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @executable_path/../../../../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.14; - MARKETING_VERSION = 0.47.2; + MARKETING_VERSION = 0.47.3; PRODUCT_BUNDLE_IDENTIFIER = "com.charcoaldesign.SwiftFormat-for-Xcode.SourceEditorExtension"; PRODUCT_NAME = SwiftFormat; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/Tests/Info.plist b/Tests/Info.plist index 280afff0b..b36d495f0 100644 --- a/Tests/Info.plist +++ b/Tests/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 0.47.2 + 0.47.3 CFBundleSignature ???? CFBundleVersion