diff --git a/Rules.md b/Rules.md index 48dd9084..530a4034 100644 --- a/Rules.md +++ b/Rules.md @@ -2629,7 +2629,7 @@ Option | Description `--wrapparameters` | Wrap func params: "before-first", "after-first", "preserve" `--wrapcollections` | Wrap array/dict: "before-first", "after-first", "preserve" `--closingparen` | Closing paren position: "balanced" (default) or "same-line" -`--callsiteparen` | Closing paren at callsite: "inherit" (default) or "same-line" +`--callsiteparen` | Closing paren at call sites: "balanced" or "same-line" `--wrapreturntype` | Wrap return type: "if-multiline", "preserve" (default) `--wrapconditions` | Wrap conditions: "before-first", "after-first", "preserve" `--wraptypealiases` | Wrap typealiases: "before-first", "after-first", "preserve" diff --git a/Sources/FormattingHelpers.swift b/Sources/FormattingHelpers.swift index e6815249..f56e5577 100644 --- a/Sources/FormattingHelpers.swift +++ b/Sources/FormattingHelpers.swift @@ -397,7 +397,13 @@ extension Formatter { keepParameterLabelsOnSameLine(startOfScope: i, endOfScope: &endOfScope) - if options.closingCallSiteParenOnSameLine, isFunctionCall(at: i) { + let closingParenOnSameLine: Bool + switch options.callSiteClosingParenPosition { + case .balanced: closingParenOnSameLine = false + case .sameLine: closingParenOnSameLine = true + case .default: closingParenOnSameLine = options.closingParenPosition == .sameLine + } + if closingParenOnSameLine, isFunctionCall(at: i) { removeLinebreakBeforeEndOfScope(at: &endOfScope) } else if endOfScopeOnSameLine { removeLinebreakBeforeEndOfScope(at: &endOfScope) @@ -556,7 +562,7 @@ extension Formatter { return } - endOfScopeOnSameLine = options.closingParenOnSameLine + endOfScopeOnSameLine = options.closingParenPosition == .sameLine isParameters = isParameterList(at: i) if isParameters, options.wrapParameters != .default { mode = options.wrapParameters diff --git a/Sources/Inference.swift b/Sources/Inference.swift index ba2e91c6..456c0e95 100644 --- a/Sources/Inference.swift +++ b/Sources/Inference.swift @@ -378,7 +378,7 @@ private struct Inference { options.wrapCollections = formatter.wrapMode(for: "[") } - let closingParenOnSameLine = OptionInferrer { formatter, options in + let closingParenPosition = OptionInferrer { formatter, options in var functionCallSameLine = 0, functionCallBalanced = 0 var functionDeclarationSameLine = 0, functionDeclarationBalanced = 0 @@ -407,20 +407,24 @@ private struct Inference { } } - // Decide on closingCallSiteParenOnSameLine + // Decide on callSiteClosingParenPosition if functionCallSameLine > functionCallBalanced && functionDeclarationBalanced > functionDeclarationSameLine { - options.closingCallSiteParenOnSameLine = true + options.callSiteClosingParenPosition = .sameLine } else { - options.closingCallSiteParenOnSameLine = false + options.callSiteClosingParenPosition = .balanced } - // If closingCallSiteParenOnSameLine is true, trust only the declarations to infer closingParenOnSameLine - if options.closingCallSiteParenOnSameLine { - options.closingParenOnSameLine = functionDeclarationSameLine > functionDeclarationBalanced + // If callSiteClosingParenPosition is sameLine, trust only the declarations to infer closingParenPosition + if options.callSiteClosingParenPosition == .sameLine { + options.closingParenPosition = functionDeclarationSameLine > functionDeclarationBalanced ? .sameLine : .balanced } else { let balanced = functionDeclarationBalanced + functionCallBalanced let sameLine = functionDeclarationSameLine + functionCallSameLine - options.closingParenOnSameLine = sameLine > balanced + options.closingParenPosition = sameLine > balanced ? .sameLine : .balanced + } + + if options.closingParenPosition == options.callSiteClosingParenPosition { + options.callSiteClosingParenPosition = .default } } diff --git a/Sources/OptionDescriptor.swift b/Sources/OptionDescriptor.swift index 7926093d..82bd7ae2 100644 --- a/Sources/OptionDescriptor.swift +++ b/Sources/OptionDescriptor.swift @@ -496,21 +496,17 @@ struct _Descriptors { help: "Wrap ternary operators: \"default\", \"before-operators\"", keyPath: \.wrapTernaryOperators ) - let closingParenOnSameLine = OptionDescriptor( + let closingParenPosition = OptionDescriptor( argumentName: "closingparen", displayName: "Closing Paren Position", help: "Closing paren position: \"balanced\" (default) or \"same-line\"", - keyPath: \.closingParenOnSameLine, - trueValues: ["same-line"], - falseValues: ["balanced"] + keyPath: \.closingParenPosition ) - let closingCallSiteParenOnSameLine = OptionDescriptor( + let callSiteClosingParenPosition = OptionDescriptor( argumentName: "callsiteparen", displayName: "Call Site Closing Paren", - help: "Closing paren at callsite: \"inherit\" (default) or \"same-line\"", - keyPath: \.closingCallSiteParenOnSameLine, - trueValues: ["same-line"], - falseValues: ["inherit"] + help: "Closing paren at call sites: \"balanced\" or \"same-line\"", + keyPath: \.callSiteClosingParenPosition ) let uppercaseHex = OptionDescriptor( argumentName: "hexliteralcase", diff --git a/Sources/Options.swift b/Sources/Options.swift index c1cf8611..b753b488 100644 --- a/Sources/Options.swift +++ b/Sources/Options.swift @@ -552,6 +552,13 @@ public enum NilInitType: String, CaseIterable { case insert } +/// Placement for closing paren in a function call or definition +public enum ClosingParenPosition: String, CaseIterable { + case balanced + case sameLine = "same-line" + case `default` +} + /// Configuration options for formatting. These aren't actually used by the /// Formatter class itself, but it makes them available to the format rules. public struct FormatOptions: CustomStringConvertible { @@ -575,8 +582,8 @@ public struct FormatOptions: CustomStringConvertible { public var wrapCollections: WrapMode public var wrapTypealiases: WrapMode public var wrapEnumCases: WrapEnumCases - public var closingParenOnSameLine: Bool - public var closingCallSiteParenOnSameLine: Bool + public var closingParenPosition: ClosingParenPosition + public var callSiteClosingParenPosition: ClosingParenPosition public var wrapReturnType: WrapReturnType public var wrapConditions: WrapMode public var wrapTernaryOperators: TernaryOperatorWrapMode @@ -689,8 +696,8 @@ public struct FormatOptions: CustomStringConvertible { wrapCollections: WrapMode = .preserve, wrapTypealiases: WrapMode = .preserve, wrapEnumCases: WrapEnumCases = .always, - closingParenOnSameLine: Bool = false, - closingCallSiteParenOnSameLine: Bool = false, + closingParenPosition: ClosingParenPosition = .balanced, + callSiteClosingParenPosition: ClosingParenPosition = .default, wrapReturnType: WrapReturnType = .preserve, wrapConditions: WrapMode = .preserve, wrapTernaryOperators: TernaryOperatorWrapMode = .default, @@ -793,8 +800,8 @@ public struct FormatOptions: CustomStringConvertible { self.wrapCollections = wrapCollections self.wrapTypealiases = wrapTypealiases self.wrapEnumCases = wrapEnumCases - self.closingParenOnSameLine = closingParenOnSameLine - self.closingCallSiteParenOnSameLine = closingCallSiteParenOnSameLine + self.closingParenPosition = closingParenPosition + self.callSiteClosingParenPosition = callSiteClosingParenPosition self.wrapReturnType = wrapReturnType self.wrapConditions = wrapConditions self.wrapTernaryOperators = wrapTernaryOperators diff --git a/Tests/InferenceTests.swift b/Tests/InferenceTests.swift index 719a0a5c..4ddbba5d 100644 --- a/Tests/InferenceTests.swift +++ b/Tests/InferenceTests.swift @@ -292,18 +292,18 @@ class InferenceTests: XCTestCase { XCTAssertEqual(options.wrapCollections, .afterFirst) } - // MARK: closingParenOnSameLine + // MARK: closingParenPosition func testInferParenOnSameLine() { let input = "func foo(\n bar: Int,\n baz: String) {\n}\nfunc foo(\n bar: Int,\n baz: String)" let options = inferFormatOptions(from: tokenize(input)) - XCTAssertTrue(options.closingParenOnSameLine) + XCTAssertEqual(options.closingParenPosition, .sameLine) } func testInferParenOnNextLine() { let input = "func foo(\n bar: Int,\n baz: String) {\n}\nfunc foo(\n bar: Int,\n baz: String\n)" let options = inferFormatOptions(from: tokenize(input)) - XCTAssertFalse(options.closingParenOnSameLine) + XCTAssertEqual(options.closingParenPosition, .balanced) } // MARK: uppercaseHex diff --git a/Tests/MetadataTests.swift b/Tests/MetadataTests.swift index 54f025d5..58722451 100644 --- a/Tests/MetadataTests.swift +++ b/Tests/MetadataTests.swift @@ -198,7 +198,7 @@ class MetadataTests: XCTestCase { case .identifier("wrapCollectionsAndArguments"): referencedOptions += [ Descriptors.wrapArguments, Descriptors.wrapParameters, Descriptors.wrapCollections, - Descriptors.closingParenOnSameLine, Descriptors.closingCallSiteParenOnSameLine, + Descriptors.closingParenPosition, Descriptors.callSiteClosingParenPosition, Descriptors.linebreak, Descriptors.truncateBlankLines, Descriptors.indent, Descriptors.tabWidth, Descriptors.smartTabs, Descriptors.maxWidth, Descriptors.assetLiteralWidth, Descriptors.wrapReturnType, Descriptors.wrapEffects, diff --git a/Tests/RulesTests+Braces.swift b/Tests/RulesTests+Braces.swift index f43ee44f..b5b6098d 100644 --- a/Tests/RulesTests+Braces.swift +++ b/Tests/RulesTests+Braces.swift @@ -542,7 +542,7 @@ class BracesTests: RulesTests { } """ - let options = FormatOptions(wrapArguments: .beforeFirst, closingParenOnSameLine: true) + let options = FormatOptions(wrapArguments: .beforeFirst, closingParenPosition: .sameLine) testFormatting(for: input, rules: [FormatRules.braces, FormatRules.wrapMultilineStatementBraces], options: options) } @@ -557,7 +557,7 @@ class BracesTests: RulesTests { } """ - let options = FormatOptions(wrapArguments: .beforeFirst, closingParenOnSameLine: true) + let options = FormatOptions(wrapArguments: .beforeFirst, closingParenPosition: .sameLine) testFormatting(for: input, rules: [FormatRules.braces, FormatRules.wrapMultilineStatementBraces], options: options) } } diff --git a/Tests/RulesTests+Indentation.swift b/Tests/RulesTests+Indentation.swift index 00052679..30980537 100644 --- a/Tests/RulesTests+Indentation.swift +++ b/Tests/RulesTests+Indentation.swift @@ -184,7 +184,7 @@ class IndentTests: RulesTests { .build() } """ - let options = FormatOptions(closingParenOnSameLine: true) + let options = FormatOptions(closingParenPosition: .sameLine) testFormatting(for: input, rule: FormatRules.indent, options: options) } @@ -372,7 +372,7 @@ class IndentTests: RulesTests { self?.viewportLoggingRegistry.logViewportSessionEnd(with: viewportLoggingContext) } """ - let options = FormatOptions(closingParenOnSameLine: true) + let options = FormatOptions(closingParenPosition: .sameLine) testFormatting(for: input, rule: FormatRules.indent, options: options) } @@ -483,10 +483,7 @@ class IndentTests: RulesTests { "one" } """ - let options = FormatOptions( - wrapArguments: .afterFirst, - closingParenOnSameLine: true - ) + let options = FormatOptions(wrapArguments: .afterFirst, closingParenPosition: .sameLine) testFormatting(for: input, rule: FormatRules.indent, options: options) } @@ -1469,7 +1466,7 @@ class IndentTests: RulesTests { }, baz: baz) """ - let options = FormatOptions(closingParenOnSameLine: true) + let options = FormatOptions(closingParenPosition: .sameLine) testFormatting(for: input, rule: FormatRules.indent, options: options) } @@ -1528,7 +1525,7 @@ class IndentTests: RulesTests { } } """ - let options = FormatOptions(wrapArguments: .disabled, closingParenOnSameLine: false) + let options = FormatOptions(wrapArguments: .disabled, closingParenPosition: .balanced) testFormatting(for: input, rule: FormatRules.indent, options: options, exclude: ["wrapConditionalBodies"]) } @@ -1543,7 +1540,7 @@ class IndentTests: RulesTests { } } """ - let options = FormatOptions(wrapArguments: .disabled, closingParenOnSameLine: true) + let options = FormatOptions(wrapArguments: .disabled, closingParenPosition: .sameLine) testFormatting(for: input, rule: FormatRules.indent, options: options, exclude: ["wrapConditionalBodies", "wrapMultilineStatementBraces"]) } @@ -1559,7 +1556,7 @@ class IndentTests: RulesTests { } } """ - let options = FormatOptions(wrapArguments: .disabled, closingParenOnSameLine: true) + let options = FormatOptions(wrapArguments: .disabled, closingParenPosition: .sameLine) testFormatting(for: input, rule: FormatRules.indent, options: options, exclude: ["wrapConditionalBodies", "wrapMultilineStatementBraces"]) } @@ -1575,7 +1572,7 @@ class IndentTests: RulesTests { } } """ - let options = FormatOptions(wrapArguments: .disabled, closingParenOnSameLine: true) + let options = FormatOptions(wrapArguments: .disabled, closingParenPosition: .sameLine) testFormatting(for: input, rule: FormatRules.indent, options: options, exclude: ["wrapMultilineStatementBraces"]) } @@ -1588,7 +1585,7 @@ class IndentTests: RulesTests { cancelBlock() } """ - let options = FormatOptions(wrapArguments: .disabled, closingParenOnSameLine: true) + let options = FormatOptions(wrapArguments: .disabled, closingParenPosition: .sameLine) testFormatting(for: input, rule: FormatRules.indent, options: options) } @@ -1604,7 +1601,7 @@ class IndentTests: RulesTests { } } """ - let options = FormatOptions(wrapArguments: .disabled, closingParenOnSameLine: true) + let options = FormatOptions(wrapArguments: .disabled, closingParenPosition: .sameLine) testFormatting(for: input, rule: FormatRules.indent, options: options, exclude: ["braces", "wrapConditionalBodies"]) } @@ -1616,7 +1613,7 @@ class IndentTests: RulesTests { print("and a trailing closure") } """ - let options = FormatOptions(wrapArguments: .disabled, closingParenOnSameLine: true) + let options = FormatOptions(wrapArguments: .disabled, closingParenPosition: .sameLine) testFormatting(for: input, rule: FormatRules.indent, options: options, exclude: ["wrapConditionalBodies"]) } @@ -3706,7 +3703,7 @@ class IndentTests: RulesTests { bar _: String) async throws -> String {} """ - let options = FormatOptions(closingParenOnSameLine: true) + let options = FormatOptions(closingParenPosition: .sameLine) testFormatting(for: input, rule: FormatRules.indent, options: options) } @@ -3717,7 +3714,7 @@ class IndentTests: RulesTests { bar _: String) async throws(Foo) -> String {} """ - let options = FormatOptions(closingParenOnSameLine: true) + let options = FormatOptions(closingParenPosition: .sameLine) testFormatting(for: input, rule: FormatRules.indent, options: options) } @@ -3767,7 +3764,7 @@ class IndentTests: RulesTests { async _: String) -> String {} """ - let options = FormatOptions(closingParenOnSameLine: true) + let options = FormatOptions(closingParenPosition: .sameLine) testFormatting(for: input, rule: FormatRules.indent, options: options) } diff --git a/Tests/RulesTests+Redundancy.swift b/Tests/RulesTests+Redundancy.swift index 216e6974..0f55416f 100644 --- a/Tests/RulesTests+Redundancy.swift +++ b/Tests/RulesTests+Redundancy.swift @@ -8695,7 +8695,7 @@ class RedundancyTests: RulesTests { bar: bar) """ - let options = FormatOptions(wrapArguments: .beforeFirst, closingParenOnSameLine: true) + let options = FormatOptions(wrapArguments: .beforeFirst, closingParenPosition: .sameLine) testFormatting(for: input, [output], rules: [FormatRules.redundantClosure, FormatRules.wrapArguments], options: options) @@ -8714,7 +8714,7 @@ class RedundancyTests: RulesTests { bar: bar) """ - let options = FormatOptions(wrapArguments: .afterFirst, closingParenOnSameLine: true) + let options = FormatOptions(wrapArguments: .afterFirst, closingParenPosition: .sameLine) testFormatting(for: input, [output], rules: [FormatRules.redundantClosure, FormatRules.wrapArguments], options: options) diff --git a/Tests/RulesTests+Wrapping.swift b/Tests/RulesTests+Wrapping.swift index a8081e30..40040617 100644 --- a/Tests/RulesTests+Wrapping.swift +++ b/Tests/RulesTests+Wrapping.swift @@ -1486,7 +1486,7 @@ class WrappingTests: RulesTests { bar _: Int, baz _: String) {} """ - let options = FormatOptions(wrapArguments: .beforeFirst, closingParenOnSameLine: true) + let options = FormatOptions(wrapArguments: .beforeFirst, closingParenPosition: .sameLine) testFormatting(for: input, output, rule: FormatRules.wrapArguments, options: options) } @@ -1502,7 +1502,7 @@ class WrappingTests: RulesTests { baz _: String ) {} """ - let options = FormatOptions(wrapArguments: .beforeFirst, closingParenOnSameLine: false) + let options = FormatOptions(wrapArguments: .beforeFirst, closingParenPosition: .balanced) testFormatting(for: input, output, rule: FormatRules.wrapArguments, options: options) } @@ -1518,7 +1518,7 @@ class WrappingTests: RulesTests { bar _: Int, baz _: String) {} """ - let options = FormatOptions(wrapArguments: .beforeFirst, closingParenOnSameLine: true, closingCallSiteParenOnSameLine: true) + let options = FormatOptions(wrapArguments: .beforeFirst, closingParenPosition: .sameLine, callSiteClosingParenPosition: .sameLine) testFormatting(for: input, output, rule: FormatRules.wrapArguments, options: options) } @@ -1534,7 +1534,7 @@ class WrappingTests: RulesTests { baz _: String ) {} """ - let options = FormatOptions(wrapArguments: .beforeFirst, closingParenOnSameLine: false, closingCallSiteParenOnSameLine: true) + let options = FormatOptions(wrapArguments: .beforeFirst, closingParenPosition: .balanced, callSiteClosingParenPosition: .sameLine) testFormatting(for: input, output, rule: FormatRules.wrapArguments, options: options) } @@ -1550,7 +1550,7 @@ class WrappingTests: RulesTests { bar: 42, baz: "foo") """ - let options = FormatOptions(wrapArguments: .beforeFirst, closingParenOnSameLine: false, closingCallSiteParenOnSameLine: true) + let options = FormatOptions(wrapArguments: .beforeFirst, closingParenPosition: .balanced, callSiteClosingParenPosition: .sameLine) testFormatting(for: input, output, rule: FormatRules.wrapArguments, options: options) } @@ -2238,26 +2238,26 @@ class WrappingTests: RulesTests { exclude: ["wrap", "blankLinesAtStartOfScope", "blankLinesAtEndOfScope"]) } - // MARK: closingParenOnSameLine = true + // MARK: closingParenPosition = true func testParenOnSameLineWhenWrapAfterFirstConvertedToWrapBefore() { let input = "func foo(bar _: Int,\n baz _: String) {}" let output = "func foo(\n bar _: Int,\n baz _: String) {}" - let options = FormatOptions(wrapParameters: .beforeFirst, closingParenOnSameLine: true) + let options = FormatOptions(wrapParameters: .beforeFirst, closingParenPosition: .sameLine) testFormatting(for: input, output, rule: FormatRules.wrapArguments, options: options) } func testParenOnSameLineWhenWrapBeforeFirstUnchanged() { let input = "func foo(\n bar _: Int,\n baz _: String\n) {}" let output = "func foo(\n bar _: Int,\n baz _: String) {}" - let options = FormatOptions(wrapParameters: .beforeFirst, closingParenOnSameLine: true) + let options = FormatOptions(wrapParameters: .beforeFirst, closingParenPosition: .sameLine) testFormatting(for: input, output, rule: FormatRules.wrapArguments, options: options) } func testParenOnSameLineWhenWrapBeforeFirstPreserved() { let input = "func foo(\n bar _: Int,\n baz _: String\n) {}" let output = "func foo(\n bar _: Int,\n baz _: String) {}" - let options = FormatOptions(wrapParameters: .preserve, closingParenOnSameLine: true) + let options = FormatOptions(wrapParameters: .preserve, closingParenPosition: .sameLine) testFormatting(for: input, output, rule: FormatRules.wrapArguments, options: options) } @@ -3053,7 +3053,7 @@ class WrappingTests: RulesTests { let options = FormatOptions( wrapArguments: .beforeFirst, - closingParenOnSameLine: true, + closingParenPosition: .sameLine, wrapReturnType: .ifMultiline ) @@ -3076,7 +3076,7 @@ class WrappingTests: RulesTests { let options = FormatOptions( wrapArguments: .beforeFirst, - closingParenOnSameLine: true, + closingParenPosition: .sameLine, wrapReturnType: .ifMultiline, wrapEffects: .ifMultiline ) @@ -3091,7 +3091,7 @@ class WrappingTests: RulesTests { let options = FormatOptions( wrapArguments: .beforeFirst, - closingParenOnSameLine: true, + closingParenPosition: .sameLine, wrapReturnType: .ifMultiline, wrapEffects: .ifMultiline ) @@ -3106,7 +3106,7 @@ class WrappingTests: RulesTests { let options = FormatOptions( wrapArguments: .beforeFirst, - closingParenOnSameLine: true, + closingParenPosition: .sameLine, wrapReturnType: .ifMultiline, wrapEffects: .ifMultiline ) @@ -3131,7 +3131,7 @@ class WrappingTests: RulesTests { let options = FormatOptions( wrapArguments: .beforeFirst, - closingParenOnSameLine: true, + closingParenPosition: .sameLine, wrapReturnType: .ifMultiline, wrapEffects: .ifMultiline ) @@ -3156,7 +3156,7 @@ class WrappingTests: RulesTests { let options = FormatOptions( wrapArguments: .beforeFirst, - closingParenOnSameLine: true, + closingParenPosition: .sameLine, wrapReturnType: .ifMultiline, wrapEffects: .never ) @@ -3178,7 +3178,7 @@ class WrappingTests: RulesTests { let options = FormatOptions( wrapArguments: .afterFirst, - closingParenOnSameLine: true, + closingParenPosition: .sameLine, wrapReturnType: .ifMultiline ) @@ -3202,7 +3202,7 @@ class WrappingTests: RulesTests { let options = FormatOptions( wrapArguments: .afterFirst, - closingParenOnSameLine: true, + closingParenPosition: .sameLine, wrapReturnType: .ifMultiline ) @@ -3226,7 +3226,7 @@ class WrappingTests: RulesTests { let options = FormatOptions( wrapArguments: .afterFirst, - closingParenOnSameLine: true, + closingParenPosition: .sameLine, wrapReturnType: .ifMultiline, wrapEffects: .ifMultiline ) @@ -3246,7 +3246,7 @@ class WrappingTests: RulesTests { let options = FormatOptions( wrapArguments: .afterFirst, - closingParenOnSameLine: true, + closingParenPosition: .sameLine, wrapReturnType: .ifMultiline ) @@ -3263,7 +3263,7 @@ class WrappingTests: RulesTests { let options = FormatOptions( wrapArguments: .beforeFirst, - closingParenOnSameLine: true, + closingParenPosition: .sameLine, wrapReturnType: .ifMultiline ) @@ -3283,7 +3283,7 @@ class WrappingTests: RulesTests { let options = FormatOptions( wrapArguments: .beforeFirst, - closingParenOnSameLine: true, + closingParenPosition: .sameLine, wrapReturnType: .ifMultiline ) @@ -3305,7 +3305,7 @@ class WrappingTests: RulesTests { let options = FormatOptions( wrapArguments: .beforeFirst, - closingParenOnSameLine: true, + closingParenPosition: .sameLine, wrapReturnType: .ifMultiline ) @@ -3322,7 +3322,7 @@ class WrappingTests: RulesTests { let options = FormatOptions( wrapArguments: .beforeFirst, - closingParenOnSameLine: true + closingParenPosition: .sameLine ) testFormatting(for: input, rule: FormatRules.wrapArguments, options: options) @@ -3573,7 +3573,7 @@ class WrappingTests: RulesTests { let options = FormatOptions( wrapArguments: .beforeFirst, - closingParenOnSameLine: true + closingParenPosition: .sameLine ) testFormatting(for: input, output, rule: FormatRules.wrapMultilineStatementBraces, options: options, exclude: ["indent"]) @@ -3601,7 +3601,7 @@ class WrappingTests: RulesTests { let options = FormatOptions( wrapArguments: .beforeFirst, - closingParenOnSameLine: true + closingParenPosition: .sameLine ) testFormatting(for: input, [output], rules: [ FormatRules.wrapMultilineStatementBraces, @@ -3629,7 +3629,7 @@ class WrappingTests: RulesTests { let options = FormatOptions( wrapArguments: .beforeFirst, - closingParenOnSameLine: true + closingParenPosition: .sameLine ) testFormatting(for: input, [output], rules: [ FormatRules.wrapMultilineStatementBraces, @@ -3655,7 +3655,7 @@ class WrappingTests: RulesTests { let options = FormatOptions( wrapArguments: .afterFirst, - closingParenOnSameLine: true + closingParenPosition: .sameLine ) testFormatting(for: input, output, rule: FormatRules.wrapMultilineStatementBraces, options: options, exclude: ["indent"]) @@ -3672,7 +3672,7 @@ class WrappingTests: RulesTests { let options = FormatOptions( wrapArguments: .afterFirst, - closingParenOnSameLine: true + closingParenPosition: .sameLine ) testFormatting(for: input, [], rules: [ FormatRules.wrapMultilineStatementBraces, @@ -3692,7 +3692,7 @@ class WrappingTests: RulesTests { """ let options = FormatOptions( wrapArguments: .beforeFirst, - closingParenOnSameLine: true + closingParenPosition: .sameLine ) testFormatting(for: input, rule: FormatRules.wrapMultilineStatementBraces, options: options, exclude: ["trailingClosures"]) @@ -3719,7 +3719,7 @@ class WrappingTests: RulesTests { let options = FormatOptions( wrapArguments: .beforeFirst, - closingParenOnSameLine: true, + closingParenPosition: .sameLine, wrapReturnType: .ifMultiline, wrapEffects: .ifMultiline ) @@ -3750,7 +3750,7 @@ class WrappingTests: RulesTests { let options = FormatOptions( wrapArguments: .beforeFirst, - closingParenOnSameLine: true, + closingParenPosition: .sameLine, wrapReturnType: .ifMultiline, wrapEffects: .ifMultiline ) @@ -3781,7 +3781,7 @@ class WrappingTests: RulesTests { let options = FormatOptions( wrapArguments: .beforeFirst, - closingParenOnSameLine: true, + closingParenPosition: .sameLine, wrapReturnType: .ifMultiline, wrapEffects: .ifMultiline ) @@ -3812,7 +3812,7 @@ class WrappingTests: RulesTests { let options = FormatOptions( wrapArguments: .beforeFirst, - closingParenOnSameLine: true, + closingParenPosition: .sameLine, wrapReturnType: .ifMultiline, wrapEffects: .ifMultiline ) @@ -3843,7 +3843,7 @@ class WrappingTests: RulesTests { let options = FormatOptions( wrapArguments: .beforeFirst, - closingParenOnSameLine: true, + closingParenPosition: .sameLine, wrapReturnType: .ifMultiline, wrapEffects: .ifMultiline ) @@ -3873,7 +3873,7 @@ class WrappingTests: RulesTests { let options = FormatOptions( wrapArguments: .beforeFirst, - closingParenOnSameLine: false + closingParenPosition: .balanced ) testFormatting(for: input, [output], rules: [ FormatRules.wrapMultilineStatementBraces, @@ -3901,7 +3901,7 @@ class WrappingTests: RulesTests { let options = FormatOptions( wrapArguments: .beforeFirst, - closingParenOnSameLine: false, + closingParenPosition: .balanced, wrapEffects: .never ) testFormatting(for: input, [output], rules: [ @@ -3930,7 +3930,7 @@ class WrappingTests: RulesTests { let options = FormatOptions( wrapArguments: .beforeFirst, - closingParenOnSameLine: false, + closingParenPosition: .balanced, wrapEffects: .never ) testFormatting(for: input, [output], rules: [ @@ -3952,7 +3952,7 @@ class WrappingTests: RulesTests { let options = FormatOptions( // wrapMultilineStatementBraces: true, wrapArguments: .beforeFirst, - closingParenOnSameLine: false + closingParenPosition: .balanced ) testFormatting(for: input, [], rules: [ @@ -3982,7 +3982,7 @@ class WrappingTests: RulesTests { let options = FormatOptions( wrapArguments: .beforeFirst, - closingParenOnSameLine: true + closingParenPosition: .sameLine ) testFormatting(for: input, [output], rules: [ FormatRules.wrapMultilineStatementBraces, @@ -4000,7 +4000,7 @@ class WrappingTests: RulesTests { """ let options = FormatOptions( wrapArguments: .beforeFirst, - closingParenOnSameLine: true + closingParenPosition: .sameLine ) testFormatting(for: input, rule: FormatRules.wrapMultilineStatementBraces, options: options, exclude: ["trailingClosures"]) @@ -4018,7 +4018,7 @@ class WrappingTests: RulesTests { let options = FormatOptions( wrapArguments: .beforeFirst, - closingParenOnSameLine: true + closingParenPosition: .sameLine ) testFormatting(for: input, rules: [FormatRules.wrapMultilineStatementBraces, FormatRules.wrap], options: options, exclude: ["indent", "redundantClosure", "wrapConditionalBodies"]) @@ -4052,7 +4052,7 @@ class WrappingTests: RulesTests { """ testFormatting( for: input, rules: [FormatRules.wrapArguments, FormatRules.indent], - options: FormatOptions(closingParenOnSameLine: true, wrapConditions: .beforeFirst) + options: FormatOptions(closingParenPosition: .sameLine, wrapConditions: .beforeFirst) ) } @@ -4615,7 +4615,7 @@ class WrappingTests: RulesTests { help: "Long help text for my example arg from Swift argument parser") var foo: WrappedType """ - let options = FormatOptions(closingParenOnSameLine: true, varAttributes: .prevLine, storedVarAttributes: .sameLine, complexAttributes: .prevLine) + let options = FormatOptions(closingParenPosition: .sameLine, varAttributes: .prevLine, storedVarAttributes: .sameLine, complexAttributes: .prevLine) testFormatting(for: input, rule: FormatRules.wrapAttributes, options: options) }