Skip to content

Commit

Permalink
Updated for 0.11.3 release
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklockwood committed Oct 4, 2016
1 parent 5409ed2 commit 0f9de5f
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 19 deletions.
4 changes: 2 additions & 2 deletions CommandLineTool/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// main.swift
// SwiftFormat
//
// Version 0.11.2
// Version 0.11.3
//
// Created by Nick Lockwood on 12/08/2016.
// Copyright 2016 Charcoal Design
Expand Down Expand Up @@ -33,7 +33,7 @@

import Foundation

let version = "0.11.2"
let version = "0.11.3"

func showHelp() {
print("swiftformat, version \(version)")
Expand Down
Binary file modified CommandLineTool/swiftformat
Binary file not shown.
2 changes: 1 addition & 1 deletion LICENCE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SwiftFormat

Version 0.11.2, October 4th, 2016
Version 0.11.3, October 4th, 2016

Copyright (c) 2016 Nick Lockwood

Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,11 @@ What's next?
Release notes
----------------

Version 0.11.3

- Fixed spacing between closure capture list and arguments
- Fixed incorrect indenting of closures after and `if` statement, and other braced clauses

Version 0.11.2

- Fixed incorrect indenting of closures inside `for` loops, and other braced clauses
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.11.2
// Version 0.11.3
//
// Created by Nick Lockwood on 12/08/2016.
// Copyright 2016 Charcoal Design
Expand Down
6 changes: 3 additions & 3 deletions SwiftFormat/Rules.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Rules.swift
// SwiftFormat
//
// Version 0.11.2
// Version 0.11.3
//
// Created by Nick Lockwood on 12/08/2016.
// Copyright 2016 Charcoal Design
Expand Down Expand Up @@ -83,7 +83,7 @@ public func spaceAroundParens(_ formatter: Formatter) {
}
return true
}

formatter.forEachToken("(") { i, token in
guard let previousToken = formatter.tokenAtIndex(i - 1) else {
return
Expand Down Expand Up @@ -925,7 +925,7 @@ public func indent(_ formatter: Formatter) {
while let token = formatter.tokenAtIndex(i) {
switch token.type {
case .identifier:
if ["if", "for", "while", "catch", "switch" /* TODO: get/set/didSet */ ].contains(token.string) {
if ["if", "for", "while", "catch", "switch", "guard" /* TODO: get/set/didSet */ ].contains(token.string) {
// Check that it's actually a keyword and not a member property or enum value
return formatter.previousNonWhitespaceOrCommentOrLinebreakToken(fromIndex: i)?.string == "."
}
Expand Down
2 changes: 1 addition & 1 deletion SwiftFormat/SwiftFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SwiftFormat.h
// SwiftFormat
//
// Version 0.11.2
// Version 0.11.3
//
// Created by Nick Lockwood on 12/08/2016.
// Copyright 2016 Charcoal Design
Expand Down
2 changes: 1 addition & 1 deletion SwiftFormat/SwiftFormat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SwiftFormat.swift
// SwiftFormat
//
// Version 0.11.2
// Version 0.11.3
//
// Created by Nick Lockwood on 12/08/2016.
// Copyright 2016 Charcoal Design
Expand Down
2 changes: 1 addition & 1 deletion SwiftFormat/Tokenizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Tokenizer.swift
// SwiftFormat
//
// Version 0.11.2
// Version 0.11.3
//
// Created by Nick Lockwood on 11/08/2016.
// Copyright 2016 Charcoal Design
Expand Down
18 changes: 9 additions & 9 deletions SwiftFormatTests/RulesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,14 @@ class RulesTests: XCTestCase {
XCTAssertEqual(try! format(input, rules: [spaceAroundParens]), output)
XCTAssertEqual(try! format(input + "\n", rules: defaultRules), output + "\n")
}

func testNoRemoveSpaceBetweenCaptureListAndArguments() {
let input = "{ [weak self] (foo) in }"
let output = "{ [weak self] (foo) in }"
XCTAssertEqual(try! format(input, rules: [spaceAroundParens]), output)
XCTAssertEqual(try! format(input + "\n", rules: defaultRules), output + "\n")
}

func testAddSpaceBetweenCaptureListAndArguments() {
let input = "{ [weak self](foo) in }"
let output = "{ [weak self] (foo) in }"
Expand Down Expand Up @@ -1370,49 +1370,49 @@ class RulesTests: XCTestCase {
XCTAssertEqual(try! format(input, rules: [indent]), output)
XCTAssertEqual(try! format(input + "\n", rules: defaultRules), output + "\n")
}

func testNestedWrappedIfIndents() {
let input = "if foo {\nif bar &&\n(baz ||\nquux) {\nfoo()\n}\n}"
let output = "if foo {\n if bar &&\n (baz ||\n quux) {\n foo()\n }\n}"
XCTAssertEqual(try! format(input, rules: [indent]), output)
XCTAssertEqual(try! format(input + "\n", rules: defaultRules), output + "\n")
}

func testWrappedEnumThatLooksLikeIf() {
let input = "foo &&\n bar.if {\nfoo()\n}"
let output = "foo &&\n bar.if {\n foo()\n }"
XCTAssertEqual(try! format(input, rules: [indent]), output)
XCTAssertEqual(try! format(input + "\n", rules: defaultRules), output + "\n")
}

func testChainedClosureIndents() {
let input = "foo\n.bar {\nbaz()\n}\n.bar {\nbaz()\n}"
let output = "foo\n .bar {\n baz()\n }\n .bar {\n baz()\n }"
XCTAssertEqual(try! format(input, rules: [indent]), output)
XCTAssertEqual(try! format(input + "\n", rules: defaultRules), output + "\n")
}

func testChainedFunctionsInsideIf() {
let input = "if foo {\nreturn bar()\n.baz()\n}"
let output = "if foo {\n return bar()\n .baz()\n}"
XCTAssertEqual(try! format(input, rules: [indent]), output)
XCTAssertEqual(try! format(input + "\n", rules: defaultRules), output + "\n")
}

func testChainedFunctionsInsideForLoop() {
let input = "for x in y {\nfoo\n.bar {\nbaz()\n}\n.quux()\n}"
let output = "for x in y {\n foo\n .bar {\n baz()\n }\n .quux()\n}"
XCTAssertEqual(try! format(input, rules: [indent]), output)
XCTAssertEqual(try! format(input + "\n", rules: defaultRules), output + "\n")
}

func testChainedFunctionsAfterAnIfStatement() {
let input = "if foo {}\nbar\n.baz {\n}\n.quux()"
let output = "if foo {}\nbar\n .baz {\n }\n .quux()"
XCTAssertEqual(try! format(input, rules: [indent]), output)
XCTAssertEqual(try! format(input + "\n", rules: defaultRules), output + "\n")
}

func testIndentInsideWrappedIfStatementWithClosureCondition() {
let input = "if foo({ 1 }) ||\nbar {\nbaz()\n}"
let output = "if foo({ 1 }) ||\n bar {\n baz()\n}"
Expand Down

0 comments on commit 0f9de5f

Please sign in to comment.