Skip to content

Commit

Permalink
Updated for 0.17 release
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklockwood committed Nov 8, 2016
1 parent 0831657 commit c9d44c1
Show file tree
Hide file tree
Showing 45 changed files with 111 additions and 80 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Change Log

## [0.17](https://github.com/nicklockwood/SwiftFormat/releases/tag/0.17) (2016-11-08)

- Added cache, allowing SwiftFormat to skip formatting for files that haven't changed
- Added `stripHeaders` rule to remove Xcode's copyright header comments (off by default)
- Disabled `linebreakAtEndOfFile` rule when formatted text is a fragment
- Fixed bug where generics were wrongly formatted if followed by a greater-than sign in the same file
- Fixed space incorrectly added after `#available`, `#colorLiteral`, etc
- Fixed several bugs with indenting of blocks containing wrapped lines

## [0.16.4](https://github.com/nicklockwood/SwiftFormat/releases/tag/0.16.4) (2016-11-07)

- SwiftFormat is now ~3X faster!
Expand Down
2 changes: 1 addition & 1 deletion CommandLineTool/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// main.swift
// SwiftFormat
//
// Version 0.16.4
// Version 0.17
//
// Created by Nick Lockwood on 12/08/2016.
// Copyright 2016 Nick Lockwood
Expand Down
Binary file modified CommandLineTool/swiftformat
Binary file not shown.
2 changes: 1 addition & 1 deletion EditorExtension/Application/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.16.4</string>
<string>0.17</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSMinimumSystemVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion EditorExtension/Extension/CommandErrors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// CommandErrors.swift
// Swift Formatter
//
// Version 0.16.4
// Version 0.17
//
// Created by Tony Arnold on 6/10/16.
// Copyright 2016 Nick Lockwood
Expand Down
2 changes: 1 addition & 1 deletion EditorExtension/Extension/FormatEntireFileCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// FormatEntireFileCommand.swift
// Swift Formatter
//
// Version 0.16.4
// Version 0.17
//
// Created by Tony Arnold on 5/10/16.
// Copyright 2016 Nick Lockwood
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// FormatSelectedSourceCommand.swift
// Swift Formatter
//
// Version 0.16.4
// Version 0.17
//
// Created by Tony Arnold on 5/10/16.
// Copyright 2016 Nick Lockwood
Expand Down
2 changes: 1 addition & 1 deletion EditorExtension/Extension/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>0.16.4</string>
<string>0.17</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSMinimumSystemVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion EditorExtension/Extension/SourceEditorExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SourceEditorExtension.swift
// Swift Formatter
//
// Version 0.16.4
// Version 0.17
//
// Created by Tony Arnold on 5/10/16.
// Copyright 2016 Nick Lockwood
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// XCSourceTextBuffer+SwiftFormat.swift
// SwiftFormat
//
// Version 0.16.4
// Version 0.17
//
// Created by Nick Lockwood on 21/10/2016.
// Copyright © 2016 Nick Lockwood. All rights reserved.
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.16.4</string>
<string>0.17</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>0.16.4</string>
<string>0.17</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@
<dict>
<key>Resources/Base.lproj/Main.storyboardc/Info.plist</key>
<data>
xQLsJr1pDjnMReLhxGhEKnPDwZY=
z7/KppXiw6gl/OFlwjx6vFz3eYM=
</data>
<key>Resources/Base.lproj/Main.storyboardc/MainMenu.nib</key>
<data>
YBeUobc6BhabLLXiHesTFYokqBo=
rdrD6u7oVfyoXnXjpRSmNUMj+7E=
</data>
<key>Resources/Base.lproj/Main.storyboardc/NSWindowController-B8D-0N-5wS.nib</key>
<data>
+agrO6Hpur6mm/Ud4MQjKcfBWmE=
tQQFALaJfhPjbR8igTwvHW84OEQ=
</data>
<key>Resources/Base.lproj/Main.storyboardc/ViewController.nib</key>
<data>
OplkZTx3wRSnHe8hnLu0MPxy+To=
hi7e4KP8eeuvcAwgK6LQVEWJbvA=
</data>
<key>Resources/Base.lproj/Main.storyboardc/XfG-lQ-9wD-view-m2S-Jp-Qdl.nib</key>
<data>
Mi2GA8YgGLwNjIh+3UAMroOE2JE=
BJ5gRj8axTYdecLJ+nPXnwACTtw=
</data>
<key>Resources/libswiftRemoteMirror.dylib</key>
<data>
Expand Down Expand Up @@ -152,7 +152,7 @@
<dict>
<key>cdhash</key>
<data>
75v5tzn5SJHulpnYHaoViFejB1s=
Z/kLrBoLU2/G611y7opdMbxYXfw=
</data>
<key>requirement</key>
<string>identifier "com.charcoaldesign.SwiftFormat-for-Xcode.SourceEditorExtension" and anchor apple generic and certificate leaf[subject.CN] = "Mac Developer: Nick Lockwood (XDQ4XJZXHD)" and certificate 1[field.1.2.840.113635.100.6.2.1] /* exists */</string>
Expand All @@ -161,55 +161,55 @@
<dict>
<key>hash</key>
<data>
xQLsJr1pDjnMReLhxGhEKnPDwZY=
z7/KppXiw6gl/OFlwjx6vFz3eYM=
</data>
<key>hash2</key>
<data>
YcwdvZHaVv2t2gJorrEiKA9khuTPZObOgppWR8/gmj8=
3X87NrRCb0nEmsIr7+7u5dAATmmZwERBMhTkaE5wyLk=
</data>
</dict>
<key>Resources/Base.lproj/Main.storyboardc/MainMenu.nib</key>
<dict>
<key>hash</key>
<data>
YBeUobc6BhabLLXiHesTFYokqBo=
rdrD6u7oVfyoXnXjpRSmNUMj+7E=
</data>
<key>hash2</key>
<data>
ORB+XQ8NHuaL2NT/UJXnXLF3y1Q4tBGh5fM9RbMtMG0=
HaPHiM2U3sq8AW/e13kOXxX6zcewzCdbdF3nRnp8BEw=
</data>
</dict>
<key>Resources/Base.lproj/Main.storyboardc/NSWindowController-B8D-0N-5wS.nib</key>
<dict>
<key>hash</key>
<data>
+agrO6Hpur6mm/Ud4MQjKcfBWmE=
tQQFALaJfhPjbR8igTwvHW84OEQ=
</data>
<key>hash2</key>
<data>
9maPL9DtpH247BHkboBX57Qzz14dvJX4kmAWAsPcdIE=
4kgNEdpQzCwQSR/mFwPf8g7FA87TCry8cOvyXW3v6b8=
</data>
</dict>
<key>Resources/Base.lproj/Main.storyboardc/ViewController.nib</key>
<dict>
<key>hash</key>
<data>
OplkZTx3wRSnHe8hnLu0MPxy+To=
hi7e4KP8eeuvcAwgK6LQVEWJbvA=
</data>
<key>hash2</key>
<data>
jVJ0zaflxRyHUTD8oA9z73lpym9f4gVaH+9Up8K+suY=
NXsuTeioIzx4bk5YlvnC+M+LddFHbfRWnljYJyQkx4o=
</data>
</dict>
<key>Resources/Base.lproj/Main.storyboardc/XfG-lQ-9wD-view-m2S-Jp-Qdl.nib</key>
<dict>
<key>hash</key>
<data>
Mi2GA8YgGLwNjIh+3UAMroOE2JE=
BJ5gRj8axTYdecLJ+nPXnwACTtw=
</data>
<key>hash2</key>
<data>
tOVW7MHFW2Mw1+CFJR4QkOy4w+kmzeXA5xZ5Du4hw5U=
XRgqSzUBaJE7PUXAbuQPGi0ThZYs5MSYBoSznEU6xKg=
</data>
</dict>
<key>Resources/libswiftRemoteMirror.dylib</key>
Expand Down
100 changes: 61 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ Here are all the rules that SwiftFormat currently applies:
if (foo == true) {} --> if foo == true {}

while (i < bar.count) {} --> while i < bar.count {}

*stripHeaders* - removes the comment header blocks that Xcode adds to the top of each file (off by default).


FAQ
Expand Down Expand Up @@ -392,50 +394,70 @@ There haven't been many questions yet, but here's what I'd like to think people
> A. I only created the framework to facilitate testing, so to be honest I've no idea if it will work in an app, but you're welcome to try. If you need to make adjustments to the public/private flags or namespaces to get it working, open an issue on Github (or evene better, a pull request).

Cache
------

SwiftFormat uses a cache file to avoid reformatting files that haven't changed. For a large project, this can significantly reduce processing time.

By default, the cache is stored in `~/Library/Caches/com.charcoaldesign.swiftformat`. To clear the cache, you can delete the cache file or use the command line option `--cache clear`.

If you prefer, you can specify an alternative location for the cache file by passing a path as the `--cache` option value. For example, you might want to store the cache file inside your project directory, to improve first-run SwiftFormat performance for all users of the codebase.

The cache file is fairly small, as it only stores the path and size for each file, not the contents. It's unlikely to grow beyond a few hundred KB.


Known issues
---------------

SwiftFormat currently reformats multiline comment blocks without regard for the original indenting. That means
* The formatted file cache is based on file length, so it's possible (though unlikely) that an edited file will have the exact same character count as the previously formatted version, causing SwiftFormat to incorrectly identify it as not having changed, and fail to format it.

/* some documentation

func codeExample() {
print("Hello World")
}

*/
Will become
To fix this, you can type an extra space in the file (which SwiftFormat will then remove again when it applies the formatting).

Alternatively, use the command line option `--cache clear` to force SwiftFormat to ignore the cache for all files.

/* some documentation

func codeExample() {
print("Hello World")
}
*/
To work around that, you can disable automatic indenting of comments using the `comments` command line flag.

Alternatively, if you prefer to leave the comment indenting feature enabled, you can rewrite your multiline comment as a block of single-line comments...

// some documentation
//
// func codeExample() {
// print("Hello World")
// }
//
//

Or begin each line with a `*` (or any other non-whitespace character)

/* some documentation
*
* func codeExample() {
* print("Hello World")
* }
*
*/
* If a file begins with a comment, the `stripHeaders` rule will remove it if is followed by a blank line. To avoid this, make sure that the first comment is directly followed by a line of code.

* SwiftFormat currently reformats multiline comment blocks without regard for the original indenting. That means

/* some documentation
func codeExample() {
print("Hello World")
}
*/
Will become

/* some documentation
func codeExample() {
print("Hello World")
}
*/
To work around that, you can disable automatic indenting of comments using the `comments` command line flag.

Alternatively, if you prefer to leave the comment indenting feature enabled, you can rewrite your multiline comment as a block of single-line comments...

// some documentation
//
// func codeExample() {
// print("Hello World")
// }
//
//
Or begin each line with a `*` (or any other non-whitespace character)

/* some documentation
*
* func codeExample() {
* print("Hello World")
* }
*
*/


Credits
Expand Down
4 changes: 2 additions & 2 deletions SwiftFormat.podspec.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "SwiftFormat",
"version": "0.16.4",
"version": "0.17",
"license": {
"type": "zlib",
"file": "LICENCE.md"
Expand All @@ -10,7 +10,7 @@
"authors": "Nick Lockwood",
"source": {
"git": "https://github.com/nicklockwood/SwiftFormat.git",
"tag": "0.16.4"
"tag": "0.17"
},
"source_files": "SwiftFormat",
"requires_arc": true,
Expand Down
2 changes: 1 addition & 1 deletion SwiftFormat.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/CommandLineTool/swiftformat\" \"${SRCROOT}\" --experimental enabled";
shellScript = "\"${SRCROOT}/CommandLineTool/swiftformat\" \"${SRCROOT}\" --experimental enabled --cache clear";
};
017AEBB31D6F27D500764325 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
<dict>
<key>baselineAverage</key>
<real>0.28</real>
<real>0.377</real>
<key>baselineIntegrationDisplayName</key>
<string>Local Baseline</string>
</dict>
Expand All @@ -21,7 +21,7 @@
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
<dict>
<key>baselineAverage</key>
<real>0.072</real>
<real>0.105</real>
<key>baselineIntegrationDisplayName</key>
<string>Local Baseline</string>
</dict>
Expand All @@ -31,7 +31,7 @@
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
<dict>
<key>baselineAverage</key>
<real>0.871</real>
<real>0.188</real>
<key>baselineIntegrationDisplayName</key>
<string>Local Baseline</string>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion SwiftFormat/Formatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Formatter.swift
// SwiftFormat
//
// Version 0.16.4
// Version 0.17
//
// Created by Nick Lockwood on 12/08/2016.
// Copyright 2016 Nick Lockwood
Expand Down
2 changes: 1 addition & 1 deletion SwiftFormat/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.16.4</string>
<string>0.17</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
Loading

0 comments on commit c9d44c1

Please sign in to comment.