From 799db2f920e4b215930df0c2e93487e0142da46f Mon Sep 17 00:00:00 2001 From: Nick Lockwood Date: Mon, 20 Jul 2020 23:33:41 +0100 Subject: [PATCH] Change --type/funcattributes argument to prev-line --- Rules.md | 12 ++++++------ Sources/Examples.swift | 6 +++--- Sources/Options.swift | 2 +- Sources/OptionsDescriptor.swift | 4 ++-- Sources/Rules.swift | 4 ++-- Tests/RulesTests.swift | 12 ++++++------ 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Rules.md b/Rules.md index 562e3fb7..59ebfc6c 100644 --- a/Rules.md +++ b/Rules.md @@ -119,17 +119,17 @@ swift version is set to 4.1 or above. ## attributes -Wrap @ attrubutes onto a separate line, or keep them on the same line. +Wrap @attributes onto a separate line, or keep them on the same line. Option | Description --- | --- -`--funcattributes` | Function @ attributes: "preserve", "new-line", or "same-line" -`--typeattributes` | Type @ attributes: "preserve", "new-line", or "same-line" +`--funcattributes` | Function @attributes: "preserve", "prev-line", or "same-line" +`--typeattributes` | Type @attributes: "preserve", "prev-line", or "same-line"
Examples -`--funcattributes new-line` +`--funcattributes prev-line` ```diff - @objc func foo() {} @@ -147,7 +147,7 @@ Option | Description + @objc func foo() {} ``` -`--typeattributes new-line` +`--typeattributes prev-line` ```diff - @objc class Foo {} @@ -162,7 +162,7 @@ Option | Description - @objc - enum Foo { } -+ @objc enun Foo {} ++ @objc enum Foo {} ```
diff --git a/Sources/Examples.swift b/Sources/Examples.swift index d943c36a..fde91a11 100644 --- a/Sources/Examples.swift +++ b/Sources/Examples.swift @@ -1038,7 +1038,7 @@ private struct Examples { """ let attributes = """ - `--funcattributes new-line` + `--funcattributes prev-line` ```diff - @objc func foo() {} @@ -1056,7 +1056,7 @@ private struct Examples { + @objc func foo() {} ``` - `--typeattributes new-line` + `--typeattributes prev-line` ```diff - @objc class Foo {} @@ -1071,7 +1071,7 @@ private struct Examples { - @objc - enum Foo { } - + @objc enun Foo {} + + @objc enum Foo {} ``` """ } diff --git a/Sources/Options.swift b/Sources/Options.swift index c386d2e8..4344d34f 100644 --- a/Sources/Options.swift +++ b/Sources/Options.swift @@ -86,7 +86,7 @@ public enum ArgumentStrippingMode: String { // Wrap mode for @ attributes public enum AttributeMode: String { - case newLine = "new-line" + case prevLine = "prev-line" case sameLine = "same-line" case preserve } diff --git a/Sources/OptionsDescriptor.swift b/Sources/OptionsDescriptor.swift index 30967a82..4a6370d7 100644 --- a/Sources/OptionsDescriptor.swift +++ b/Sources/OptionsDescriptor.swift @@ -687,14 +687,14 @@ extension FormatOptions.Descriptor { argumentName: "funcattributes", propertyName: "funcAttributes", displayName: "Function Attributes", - help: "Function @ attributes: \"preserve\", \"new-line\", or \"same-line\"", + help: "Function @attributes: \"preserve\", \"prev-line\", or \"same-line\"", keyPath: \.funcAttributes ) static let typeAttributes = FormatOptions.Descriptor( argumentName: "typeattributes", propertyName: "typeAttributes", displayName: "Type Attributes", - help: "Type @ attributes: \"preserve\", \"new-line\", or \"same-line\"", + help: "Type @attributes: \"preserve\", \"prev-line\", or \"same-line\"", keyPath: \.typeAttributes ) diff --git a/Sources/Rules.swift b/Sources/Rules.swift index 40ed67bd..52a1a8e2 100644 --- a/Sources/Rules.swift +++ b/Sources/Rules.swift @@ -4387,7 +4387,7 @@ public struct _FormatRules { /// Strip header comments from the file public let attributes = FormatRule( - help: "Wrap @ attrubutes onto a separate line, or keep them on the same line.", + help: "Wrap @attributes onto a separate line, or keep them on the same line.", options: ["funcattributes", "typeattributes"], sharedOptions: ["linebreaks"] ) { formatter in @@ -4441,7 +4441,7 @@ public struct _FormatRules { switch attributeMode { case .preserve: return - case .newLine: + case .prevLine: // Make sure there's a newline immediately following the attribute if let nextTokenIndex = formatter.index(of: .nonSpaceOrComment, after: attributeEndIndex), formatter.token(at: nextTokenIndex)?.isLinebreak != true { diff --git a/Tests/RulesTests.swift b/Tests/RulesTests.swift index 78ded9e1..e76780e5 100644 --- a/Tests/RulesTests.swift +++ b/Tests/RulesTests.swift @@ -12019,7 +12019,7 @@ class RulesTests: XCTestCase { @available(iOS 14.0, *) func foo() {} """ - let options = FormatOptions(funcAttributes: .newLine) + let options = FormatOptions(funcAttributes: .prevLine) testFormatting(for: input, output, rule: FormatRules.attributes, options: options) } @@ -12028,7 +12028,7 @@ class RulesTests: XCTestCase { @available(iOS 14.0, *) func foo() {} """ - let options = FormatOptions(funcAttributes: .newLine) + let options = FormatOptions(funcAttributes: .prevLine) testFormatting(for: input, rule: FormatRules.attributes, options: options) } @@ -12059,7 +12059,7 @@ class RulesTests: XCTestCase { @available(iOS 14.0, *) func foo() {} """ - let options = FormatOptions(funcAttributes: .newLine) + let options = FormatOptions(funcAttributes: .prevLine) testFormatting(for: input, rule: FormatRules.attributes, options: options) } @@ -12071,7 +12071,7 @@ class RulesTests: XCTestCase { @available(iOS 14.0, *) class Foo {} """ - let options = FormatOptions(typeAttributes: .newLine) + let options = FormatOptions(typeAttributes: .prevLine) testFormatting(for: input, output, rule: FormatRules.attributes, options: options) } @@ -12080,7 +12080,7 @@ class RulesTests: XCTestCase { @available(iOS 14.0, *) struct Foo {} """ - let options = FormatOptions(typeAttributes: .newLine) + let options = FormatOptions(typeAttributes: .prevLine) testFormatting(for: input, rule: FormatRules.attributes, options: options) } @@ -12111,7 +12111,7 @@ class RulesTests: XCTestCase { @available(iOS 14.0, *) class Foo {} """ - let options = FormatOptions(typeAttributes: .newLine) + let options = FormatOptions(typeAttributes: .prevLine) testFormatting(for: input, rule: FormatRules.attributes, options: options) } }