Skip to content

Commit c7912e1

Browse files
authored
Merge pull request #720 from ahoppen/6.0/merge-main-2024-04-18
2 parents ae202e3 + 64bba9f commit c7912e1

File tree

9 files changed

+54
-9
lines changed

9 files changed

+54
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Run `brew install swift-format` to install the latest version.
7373
Install `swift-format` using the following commands:
7474

7575
```sh
76-
VERSION=509.0.0 # replace this with the version you need
76+
VERSION=510.1.0 # replace this with the version you need
7777
git clone https://github.com/apple/swift-format.git
7878
cd swift-format
7979
git checkout "tags/$VERSION"

Sources/SwiftFormat/API/Configuration.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public struct Configuration: Codable, Equatable {
167167
///
168168
/// When `true` (default), the correct form is:
169169
/// ```swift
170-
/// let MyCollection = [1, 2,]
170+
/// let MyCollection = [1, 2]
171171
/// ...
172172
/// let MyCollection = [
173173
/// "a": 1,

Sources/SwiftFormat/Core/Trivia+Convenience.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ extension Trivia {
8080
})
8181
}
8282

83-
/// Returns `true` if this trivia contains any backslahes (used for multiline string newline
83+
/// Returns `true` if this trivia contains any backslashes (used for multiline string newline
8484
/// suppression).
8585
var containsBackslashes: Bool {
8686
return contains(

Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,6 +1799,17 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
17991799
return .visitChildren
18001800
}
18011801

1802+
override func visit(_ node: OriginallyDefinedInAttributeArgumentsSyntax) -> SyntaxVisitorContinueKind {
1803+
after(node.colon.lastToken(viewMode: .sourceAccurate), tokens: .break(.same, size: 1))
1804+
after(node.comma.lastToken(viewMode: .sourceAccurate), tokens: .break(.same, size: 1))
1805+
return .visitChildren
1806+
}
1807+
1808+
override func visit(_ node: DocumentationAttributeArgumentSyntax) -> SyntaxVisitorContinueKind {
1809+
after(node.colon, tokens: .break(.same, size: 1))
1810+
return .visitChildren
1811+
}
1812+
18021813
override func visit(_ node: AvailabilityLabeledArgumentSyntax) -> SyntaxVisitorContinueKind {
18031814
before(node.label, tokens: .open)
18041815

Sources/SwiftFormat/Rules/AlwaysUseLiteralForEmptyCollectionInit.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public final class AlwaysUseLiteralForEmptyCollectionInit : SyntaxFormatRule {
8686
if replacement.typeAnnotation == nil {
8787
// Drop trailing trivia after pattern because ':' has to appear connected to it.
8888
replacement.pattern = node.pattern.with(\.trailingTrivia, [])
89-
// Add explicit type annotiation: ': [<Type>]`
89+
// Add explicit type annotation: ': [<Type>]`
9090
replacement.typeAnnotation = .init(type: type.with(\.leadingTrivia, .space)
9191
.with(\.trailingTrivia, .space))
9292
}
@@ -109,7 +109,7 @@ public final class AlwaysUseLiteralForEmptyCollectionInit : SyntaxFormatRule {
109109
if replacement.typeAnnotation == nil {
110110
// Drop trailing trivia after pattern because ':' has to appear connected to it.
111111
replacement.pattern = node.pattern.with(\.trailingTrivia, [])
112-
// Add explicit type annotiation: ': [<Type>]`
112+
// Add explicit type annotation: ': [<Type>]`
113113
replacement.typeAnnotation = .init(type: type.with(\.leadingTrivia, .space)
114114
.with(\.trailingTrivia, .space))
115115
}

Sources/_SwiftFormatTestSupport/Configuration+Testing.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ extension Configuration {
2020
/// different module than where `Configuration` is defined, we can't make this an initializer that
2121
/// would enforce that every field of `Configuration` is initialized here (we're forced to
2222
/// delegate to another initializer first, which defeats the purpose). So, users adding new
23-
/// configuration settings shouls be sure to supply a default here for testing, otherwise they
23+
/// configuration settings should be sure to supply a default here for testing, otherwise they
2424
/// will be implicitly relying on the real default.
2525
public static var forTesting: Configuration {
2626
var config = Configuration()

Sources/swift-format/Utilities/FileIterator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public struct FileIterator: Sequence, IteratorProtocol {
132132
case .typeRegular:
133133
// We attempt to relativize the URLs based on the current working directory, not the
134134
// directory being iterated over, so that they can be displayed better in diagnostics. Thus,
135-
// if the user passes paths that are relative to the current working diectory, they will
135+
// if the user passes paths that are relative to the current working directory, they will
136136
// be displayed as relative paths. Otherwise, they will still be displayed as absolute
137137
// paths.
138138
let relativePath =

Tests/SwiftFormatTests/PrettyPrint/AttributeTests.swift

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,40 @@ final class AttributeTests: PrettyPrintTestCase {
2626
assertPrettyPrintEqual(input: input, expected: expected, linelength: 60)
2727
}
2828

29+
func testAttributeParamSpacingInOriginallyDefinedIn() {
30+
let input =
31+
"""
32+
@_originallyDefinedIn( module :"SwiftUI" , iOS 10.0 )
33+
func f() {}
34+
"""
35+
36+
let expected =
37+
"""
38+
@_originallyDefinedIn(module: "SwiftUI", iOS 10.0)
39+
func f() {}
40+
41+
"""
42+
43+
assertPrettyPrintEqual(input: input, expected: expected, linelength: 60)
44+
}
45+
46+
func testAttributeParamSpacingInDocVisibility() {
47+
let input =
48+
"""
49+
@_documentation( visibility :private )
50+
func f() {}
51+
"""
52+
53+
let expected =
54+
"""
55+
@_documentation(visibility: private)
56+
func f() {}
57+
58+
"""
59+
60+
assertPrettyPrintEqual(input: input, expected: expected, linelength: 60)
61+
}
62+
2963
func testAttributeBinPackedWrapping() {
3064
let input =
3165
"""

Tests/SwiftFormatTests/PrettyPrint/CommaTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ final class CommaTests: PrettyPrintTestCase {
105105
assertPrettyPrintEqual(input: input, expected: expected, linelength: 20, configuration: configuration)
106106
}
107107

108-
func testArraySingleLineCommasPresentDisabled() {
108+
func testArraySingleLineCommasPresentEnabled() {
109109
let input =
110110
"""
111111
let MyCollection = [1, 2, 3,]
@@ -124,7 +124,7 @@ final class CommaTests: PrettyPrintTestCase {
124124
assertPrettyPrintEqual(input: input, expected: expected, linelength: 40, configuration: configuration)
125125
}
126126

127-
func testArraySingleLineCommasPresentEnabled() {
127+
func testArraySingleLineCommasPresentDisabled() {
128128
let input =
129129
"""
130130
let MyCollection = [1, 2, 3,]

0 commit comments

Comments
 (0)