Updated to version 0.8.1

This commit is contained in:
Nick Lockwood committed 2016-08-31 22:47:50 +01:00
1 parent b39387ba11
commit c45fc2dbde
13 files changed
+50 -16

No files matched your search

+2 -2
View File
@@ -2,7 +2,7 @@
// main.swift
// SwiftFormat
//
// Version 0.8
// Version 0.8.1
//
// Created by Nick Lockwood on 12/08/2016.
// Copyright 2016 Charcoal Design
@@ -33,7 +33,7 @@
import Foundation
let version = "0.8"
let version = "0.8.1"
func processInput(inputURL: NSURL, andWriteToOutput outputURL: NSURL, withOptions options: FormatOptions) -> Int {
let manager = NSFileManager.defaultManager()
Binary file not shown.
+1 -1
View File
@@ -1,6 +1,6 @@
SwiftFormat
Version 0.8, August 31st, 2016
Version 0.8.1, August 31st, 2016
Copyright (c) 2016 Nick Lockwood
+4
View File
@@ -351,6 +351,10 @@ With a syntax tree in place, it should become possible to add much more sophisti
Release notes
----------------
Version 0.8.1
- Fixed formatting of `/*! ... */` and `//!` headerdoc comments, and `/*: ... */` and `//:` Swift Playground comments
Version 0.8
- Added new `ranges` rules that adds or removes the spaces around range operators (e.g. `0 ..< count`, `"a"..."z"`)
+1 -1
View File
@@ -2,7 +2,7 @@
// Formatter.swift
// SwiftFormat
//
// Version 0.8
// Version 0.8.1
//
// Created by Nick Lockwood on 12/08/2016.
// Copyright 2016 Charcoal Design
+7 -5
View File
@@ -2,7 +2,7 @@
// Rules.swift
// SwiftFormat
//
// Version 0.8
// Version 0.8.1
//
// Created by Nick Lockwood on 12/08/2016.
// Copyright 2016 Charcoal Design
@@ -432,10 +432,11 @@ public func spaceInsideComments(formatter: Formatter) {
guard let nextToken = formatter.tokenAtIndex(i + 1) else { return }
if !nextToken.isWhitespaceOrLinebreak {
let string = nextToken.string
if string.hasPrefix("*") {
if string.hasPrefix("*") || string.hasPrefix("!") || string.hasPrefix(":") {
if !string.hasPrefix("**") && !string.hasPrefix("* ") &&
!string.hasPrefix("*\t") && !string.hasPrefix("*/") {
let string = "* " + string.substringFromIndex(string.startIndex.advancedBy(1))
let string = String(string.characters.first!) + " " +
string.substringFromIndex(string.startIndex.advancedBy(1))
formatter.replaceTokenAtIndex(i + 1, with: Token(.CommentBody, string))
}
} else {
@@ -447,9 +448,10 @@ public func spaceInsideComments(formatter: Formatter) {
guard let nextToken = formatter.tokenAtIndex(i + 1) else { return }
if !nextToken.isWhitespaceOrLinebreak {
let string = nextToken.string
if string.hasPrefix("/") {
if string.hasPrefix("/") || string.hasPrefix("!") || string.hasPrefix(":") {
if !string.hasPrefix("/ ") && !string.hasPrefix("/\t") {
let string = "/ " + string.substringFromIndex(string.startIndex.advancedBy(1))
let string = String(string.characters.first!) + " " +
string.substringFromIndex(string.startIndex.advancedBy(1))
formatter.replaceTokenAtIndex(i + 1, with: Token(.CommentBody, string))
}
} else {
+1 -1
View File
@@ -2,7 +2,7 @@
// SwiftFormat.h
// SwiftFormat
//
// Version 0.8
// Version 0.8.1
//
// Created by Nick Lockwood on 12/08/2016.
// Copyright 2016 Charcoal Design
+1 -1
View File
@@ -2,7 +2,7 @@
// SwiftFormat.swift
// SwiftFormat
//
// Version 0.8
// Version 0.8.1
//
// Created by Nick Lockwood on 12/08/2016.
// Copyright 2016 Charcoal Design
+1 -1
View File
@@ -2,7 +2,7 @@
// Tokenizer.swift
// SwiftFormat
//
// Version 0.8
// Version 0.8.1
//
// Created by Nick Lockwood on 11/08/2016.
// Copyright 2016 Charcoal Design
+1 -1
View File
@@ -2,7 +2,7 @@
// FormatterTests.swift
// SwiftFormat
//
// Version 0.8
// Version 0.8.1
//
// Created by Nick Lockwood on 30/08/2016.
// Copyright 2016 Charcoal Design
+29 -1
View File
@@ -2,7 +2,7 @@
// RulesTests.swift
// SwiftFormat
//
// Version 0.8
// Version 0.8.1
//
// Created by Nick Lockwood on 12/08/2016.
// Copyright 2016 Charcoal Design
@@ -658,6 +658,20 @@ class RulesTests: XCTestCase {
XCTAssertEqual(format(input + "\n", rules: defaultRules), output + "\n")
}
func testSpaceInsideMultilineHeaderdocCommentType2() {
let input = "/*!foo\n bar*/"
let output = "/*! foo\n bar */"
XCTAssertEqual(format(input, rules: [spaceInsideComments]), output)
XCTAssertEqual(format(input + "\n", rules: defaultRules), output + "\n")
}
func testSpaceInsideMultilineSwiftPlaygroundDocComment() {
let input = "/*:foo\n bar*/"
let output = "/*: foo\n bar */"
XCTAssertEqual(format(input, rules: [spaceInsideComments]), output)
XCTAssertEqual(format(input + "\n", rules: defaultRules), output + "\n")
}
func testNoExtraSpaceInsideMultilineHeaderdocComment() {
let input = "/** foo\n bar */"
let output = "/** foo\n bar */"
@@ -672,6 +686,20 @@ class RulesTests: XCTestCase {
XCTAssertEqual(format(input + "\n", rules: defaultRules), output + "\n")
}
func testSpaceInsideSingleLineHeaderdocCommentType2() {
let input = "//!foo"
let output = "//! foo"
XCTAssertEqual(format(input, rules: [spaceInsideComments]), output)
XCTAssertEqual(format(input + "\n", rules: defaultRules), output + "\n")
}
func testSpaceInsideSingleLineSwiftPlaygroundDocComment() {
let input = "//:foo"
let output = "//: foo"
XCTAssertEqual(format(input, rules: [spaceInsideComments]), output)
XCTAssertEqual(format(input + "\n", rules: defaultRules), output + "\n")
}
func testNoExtraSpaceInsideSingleLineHeaderdocComment() {
let input = "/// foo"
let output = "/// foo"
+1 -1
View File
@@ -2,7 +2,7 @@
// SwiftFormatTests.swift
// SwiftFormat
//
// Version 0.8
// Version 0.8.1
//
// Created by Nick Lockwood on 28/08/2016.
// Copyright 2016 Charcoal Design
+1 -1
View File
@@ -2,7 +2,7 @@
// TokenizerTests.swift
// SwiftFormat
//
// Version 0.8
// Version 0.8.1
//
// Created by Nick Lockwood on 12/08/2016.
// Copyright 2016 Charcoal Design