mirror of
https://github.com/nicklockwood/SwiftFormat.git
synced 2026-06-16 10:34:34 +00:00
Updated for 0.5.1 release
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
// SwiftFormat
|
||||
// main.swift
|
||||
//
|
||||
// Version 0.5
|
||||
// Version 0.5.1
|
||||
//
|
||||
// Created by Nick Lockwood on 12/08/2016.
|
||||
// Copyright 2016 Charcoal Design
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
let version = "0.5"
|
||||
let version = "0.5.1"
|
||||
|
||||
func processInput(inputURL: NSURL, andWriteToOutput outputURL: NSURL, withOptions options: FormattingOptions) -> Int {
|
||||
let manager = NSFileManager.defaultManager()
|
||||
|
||||
Binary file not shown.
+1
-1
@@ -1,6 +1,6 @@
|
||||
SwiftFormat
|
||||
|
||||
Version 0.5, August 25th, 2016
|
||||
Version 0.5.1, August 25th, 2016
|
||||
|
||||
Copyright (c) 2016 Nick Lockwood
|
||||
|
||||
|
||||
@@ -322,6 +322,11 @@ With a syntax tree in place, it should become possible to add much more sophisti
|
||||
Release notes
|
||||
----------------
|
||||
|
||||
Version 0.5.1
|
||||
|
||||
- Fixed critical bug where double unwrap (e.g. `foo??.bar()`) was not handled correctly
|
||||
- Fixed bug where `case let .SomeEnum` was not handled correctly
|
||||
|
||||
Version 0.5
|
||||
|
||||
- swiftformat command-line tool now supports reading from stdin/writing to stdout
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SwiftFormat
|
||||
// Formatter.swift
|
||||
//
|
||||
// Version 0.5
|
||||
// Version 0.5.1
|
||||
//
|
||||
// Created by Nick Lockwood on 12/08/2016.
|
||||
// Copyright 2016 Charcoal Design
|
||||
@@ -416,7 +416,7 @@ public func spaceAroundOperators(formatter: Formatter) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func isUnwrapOperatorSequence(token: Token) -> Bool {
|
||||
for c in token.string.characters {
|
||||
if c != "?" && c != "!" {
|
||||
@@ -502,7 +502,7 @@ public func spaceAroundOperators(formatter: Formatter) {
|
||||
(previousNonWhitespaceToken.type != .Operator ||
|
||||
(previousNonWhitespaceToken.string == "?" && scopeStack.last?.string != "?") ||
|
||||
(previousNonWhitespaceToken.string != "?" &&
|
||||
isUnwrapOperatorSequence(previousNonWhitespaceToken))) &&
|
||||
isUnwrapOperatorSequence(previousNonWhitespaceToken))) &&
|
||||
(previousNonWhitespaceToken.type != .Identifier ||
|
||||
!spaceAfter(previousNonWhitespaceToken.string)) {
|
||||
if previousTokenWasWhitespace {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SwiftFormat
|
||||
// SwiftFormat.h
|
||||
//
|
||||
// Version 0.5
|
||||
// Version 0.5.1
|
||||
//
|
||||
// Created by Nick Lockwood on 12/08/2016.
|
||||
// Copyright 2016 Charcoal Design
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SwiftFormat
|
||||
// SwiftFormat.swift
|
||||
//
|
||||
// Version 0.5
|
||||
// Version 0.5.1
|
||||
//
|
||||
// Created by Nick Lockwood on 12/08/2016.
|
||||
// Copyright 2016 Charcoal Design
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SwiftFormat
|
||||
// Tokenizer.swift
|
||||
//
|
||||
// Version 0.5
|
||||
// Version 0.5.1
|
||||
//
|
||||
// Created by Nick Lockwood on 11/08/2016.
|
||||
// Copyright 2016 Charcoal Design
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SwiftFormat
|
||||
// FormatterTests.swift
|
||||
//
|
||||
// Version 0.5
|
||||
// Version 0.5.1
|
||||
//
|
||||
// Created by Nick Lockwood on 12/08/2016.
|
||||
// Copyright 2016 Charcoal Design
|
||||
@@ -383,7 +383,7 @@ class FormatterTests: XCTestCase {
|
||||
let output = "foo?.bar"
|
||||
XCTAssertEqual(format(input, rules: [spaceAroundOperators]), output)
|
||||
}
|
||||
|
||||
|
||||
func testNoSpaceAroundMultipleOptionalChaining() {
|
||||
let input = "foo??!?!.bar"
|
||||
let output = "foo??!?!.bar"
|
||||
@@ -401,7 +401,7 @@ class FormatterTests: XCTestCase {
|
||||
let output = "foo?.bar"
|
||||
XCTAssertEqual(format(input, rules: [spaceAroundOperators]), output)
|
||||
}
|
||||
|
||||
|
||||
func testNoSpaceBetweenMultipleOptionalChaining() {
|
||||
let input = "foo??! .bar"
|
||||
let output = "foo??!.bar"
|
||||
@@ -419,7 +419,7 @@ class FormatterTests: XCTestCase {
|
||||
let output = "foo?\n .bar"
|
||||
XCTAssertEqual(format(input, rules: [spaceAroundOperators]), output)
|
||||
}
|
||||
|
||||
|
||||
func testSplitLineMultipleOptionalChaining() {
|
||||
let input = "foo??!\n .bar"
|
||||
let output = "foo??!\n .bar"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SwiftFormat
|
||||
// TokenizerTests.swift
|
||||
//
|
||||
// Version 0.5
|
||||
// Version 0.5.1
|
||||
//
|
||||
// Created by Nick Lockwood on 12/08/2016.
|
||||
// Copyright 2016 Charcoal Design
|
||||
@@ -466,18 +466,18 @@ class TokenizerTests: XCTestCase {
|
||||
]
|
||||
XCTAssertEqualArrays(tokenize(input), output)
|
||||
}
|
||||
|
||||
|
||||
func testOperatorMayContainDotIfStartsWithDot() {
|
||||
let input = ".*.."
|
||||
let output = [Token(.Operator, ".*..")]
|
||||
XCTAssertEqualArrays(tokenize(input), output)
|
||||
}
|
||||
|
||||
|
||||
func testOperatorMayNotContainDotUnlessStartsWithDot() {
|
||||
let input = "*.."
|
||||
let output = [
|
||||
Token(.Operator, "*"),
|
||||
Token(.Operator, "..")
|
||||
Token(.Operator, ".."),
|
||||
]
|
||||
XCTAssertEqualArrays(tokenize(input), output)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user