Skip to content

Commit 78a1f05

Browse files
authored
Merge pull request #2188 from AnthonyLatsis/jepa
Enable some nice-to-have code formatting rules
2 parents 4b2afe8 + 7fb77b6 commit 78a1f05

File tree

15 files changed

+31
-29
lines changed

15 files changed

+31
-29
lines changed

.swift-format

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
"NoBlockComments": false,
1414
"OrderedImports": true,
1515
"UseLetInEveryBoundCaseVariable": false,
16-
"UseSynthesizedInitializer": false
16+
"UseSynthesizedInitializer": false,
17+
"ReturnVoidInsteadOfEmptyTuple": true,
18+
"NoVoidReturnOnFunctionSignature": true,
1719
}
1820
}

Sources/CompletionScoring/Text/CandidateBatch.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,13 @@ package struct CandidateBatch: Sendable {
9999
/// Don't add a method that returns a candidate, the candidates have unsafe pointers back into the batch, and
100100
/// must not outlive it.
101101
@inline(__always)
102-
func enumerate(body: (Candidate) throws -> ()) rethrows {
102+
func enumerate(body: (Candidate) throws -> Void) rethrows {
103103
for idx in 0..<count {
104104
try body(candidate(at: idx))
105105
}
106106
}
107107

108-
func enumerate(_ range: Range<Int>, body: (Int, Candidate) throws -> ()) rethrows {
108+
func enumerate(_ range: Range<Int>, body: (Int, Candidate) throws -> Void) rethrows {
109109
precondition(range.lowerBound >= 0)
110110
precondition(range.upperBound <= count)
111111
for idx in range {
@@ -224,15 +224,15 @@ package struct CandidateBatch: Sendable {
224224
append(contentsOf: candidates, contentType: contentType)
225225
}
226226

227-
package func enumerate(body: (Candidate) throws -> ()) rethrows {
227+
package func enumerate(body: (Candidate) throws -> Void) rethrows {
228228
try readonlyStorage.enumerate(body: body)
229229
}
230230

231-
package func enumerate(body: (Int, Candidate) throws -> ()) rethrows {
231+
package func enumerate(body: (Int, Candidate) throws -> Void) rethrows {
232232
try readonlyStorage.enumerate(0..<count, body: body)
233233
}
234234

235-
internal func enumerate(_ range: Range<Int>, body: (Int, Candidate) throws -> ()) rethrows {
235+
internal func enumerate(_ range: Range<Int>, body: (Int, Candidate) throws -> Void) rethrows {
236236
try readonlyStorage.enumerate(range, body: body)
237237
}
238238

@@ -283,7 +283,7 @@ package struct CandidateBatch: Sendable {
283283
count > 0
284284
}
285285

286-
private mutating func mutate(body: (inout UnsafeStorage) -> ()) {
286+
private mutating func mutate(body: (inout UnsafeStorage) -> Void) {
287287
if !isKnownUniquelyReferenced(&__storageBox_useAccessor) {
288288
__storageBox_useAccessor = __storageBox_useAccessor.copy()
289289
}
@@ -524,7 +524,7 @@ package struct Candidate {
524524
// Creates a buffer of `capacity` elements of type `T?`, each initially set to nil.
525525
///
526526
/// After running `initialize`, returns all elements that were set to non-`nil` values.
527-
private func compactScratchArea<T>(capacity: Int, initialize: (UnsafeMutablePointer<T?>) -> ()) -> [T] {
527+
private func compactScratchArea<T>(capacity: Int, initialize: (UnsafeMutablePointer<T?>) -> Void) -> [T] {
528528
let scratchArea = UnsafeMutablePointer<T?>.allocate(capacity: capacity)
529529
scratchArea.initialize(repeating: nil, count: capacity)
530530
defer {

Sources/CompletionScoring/Text/Pattern.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ extension Pattern {
752752
self.baseNameLength = baseNameLength ?? byteCount
753753
}
754754

755-
func enumerate(body: (Range<Int>) -> ()) {
755+
func enumerate(body: (Range<Int>) -> Void) {
756756
var position = 0
757757
for token in tokens {
758758
body(position ..+ token.length)

Sources/CompletionScoring/Utilities/Serialization/BinaryEncoder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ package struct BinaryEncoder {
2929
/// - body: a closure accepting a `BinaryEncoder` that you can make `write(_:)` calls against to populate the
3030
/// archive.
3131
/// - Returns: a byte array that can be used with `BinaryDecoder`
32-
static func encode(contentVersion: Int, _ body: (inout Self) -> ()) -> [UInt8] {
32+
static func encode(contentVersion: Int, _ body: (inout Self) -> Void) -> [UInt8] {
3333
var encoder = BinaryEncoder(contentVersion: contentVersion)
3434
body(&encoder)
3535
return encoder.stream

Sources/CompletionScoring/Utilities/SwiftExtensions.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ protocol ContiguousZeroBasedIndexedCollection: Collection where Index == Int {
290290
}
291291

292292
extension ContiguousZeroBasedIndexedCollection {
293-
func slicedConcurrentForEachSliceRange(body: @Sendable (Range<Index>) -> ()) {
293+
func slicedConcurrentForEachSliceRange(body: @Sendable (Range<Index>) -> Void) {
294294
// We want to use `DispatchQueue.concurrentPerform`, but we want to be called only a few times. So that we
295295
// can amortize per-callback work. We also want to oversubscribe so that we can efficiently use
296296
// heterogeneous CPUs. If we had 4 efficiency cores, and 4 performance cores, and we dispatched 8 work items
@@ -336,7 +336,7 @@ extension Array {
336336
/// }
337337
/// ```
338338
package func unsafeSlicedConcurrentMap<T>(
339-
writer: @Sendable (ArraySlice<Element>, _ destination: UnsafeMutablePointer<T>) -> ()
339+
writer: @Sendable (ArraySlice<Element>, _ destination: UnsafeMutablePointer<T>) -> Void
340340
) -> [T] where Self: Sendable {
341341
return Array<T>(unsafeUninitializedCapacity: count) { buffer, initializedCount in
342342
if let bufferBase = buffer.baseAddress {
@@ -353,13 +353,13 @@ extension Array {
353353
}
354354

355355
/// Concurrent for-each on self, but slice based to allow the body to amortize work across callbacks
356-
func slicedConcurrentForEach(body: @Sendable (ArraySlice<Element>) -> ()) where Self: Sendable {
356+
func slicedConcurrentForEach(body: @Sendable (ArraySlice<Element>) -> Void) where Self: Sendable {
357357
slicedConcurrentForEachSliceRange { sliceRange in
358358
body(self[sliceRange])
359359
}
360360
}
361361

362-
func concurrentForEach(body: @Sendable (Element) -> ()) where Self: Sendable {
362+
func concurrentForEach(body: @Sendable (Element) -> Void) where Self: Sendable {
363363
DispatchQueue.concurrentPerform(iterations: count) { index in
364364
body(self[index])
365365
}

Sources/CompletionScoringTestSupport/TestExtensions.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import XCTest
1818
@inline(never)
1919
package func drain<T>(_ value: T) {}
2020

21-
func duration(of body: () -> ()) -> TimeInterval {
21+
func duration(of body: () -> Void) -> TimeInterval {
2222
let start = ProcessInfo.processInfo.systemUptime
2323
body()
2424
return ProcessInfo.processInfo.systemUptime - start
@@ -30,7 +30,7 @@ extension RandomNumberGenerator {
3030
}
3131
}
3232

33-
package func withEachPermutation<T>(_ a: T, _ b: T, body: (T, T) -> ()) {
33+
package func withEachPermutation<T>(_ a: T, _ b: T, body: (T, T) -> Void) {
3434
body(a, b)
3535
body(b, a)
3636
}
@@ -134,7 +134,7 @@ extension XCTestCase {
134134
/// Run `body()` `iterations`, gathering timing stats, and print them.
135135
/// In between runs, coax for the machine into an arbitrary but consistent thermal state by either sleeping or doing
136136
/// pointless work so that results are more comparable run to run, no matter else is happening on the machine.
137-
package func gaugeTiming(iterations: Int = 1, testName: String = #function, _ body: () -> ()) {
137+
package func gaugeTiming(iterations: Int = 1, testName: String = #function, _ body: () -> Void) {
138138
let logFD = tryOrFailTest(try Self.openPerformanceLog(), message: "Failed to open performance log")
139139
var timings = Timings()
140140
for iteration in 0..<iterations {

Sources/CompletionScoringTestSupport/Timings.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ package struct Timings {
107107
}
108108

109109
extension Optional {
110-
mutating func mutateWrappedValue(mutator: (inout Wrapped) -> ()) {
110+
mutating func mutateWrappedValue(mutator: (inout Wrapped) -> Void) {
111111
if var wrapped = self {
112112
self = nil // Avoid COW for clients.
113113
mutator(&wrapped)

Sources/DocCDocumentation/DocCReferenceResolutionService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ final class DocCReferenceResolutionService: DocumentationService, Sendable {
4545

4646
func process(
4747
_ message: DocumentationServer.Message,
48-
completion: @escaping (DocumentationServer.Message) -> ()
48+
completion: @escaping (DocumentationServer.Message) -> Void
4949
) {
5050
do {
5151
let response = try process(message)

Sources/SourceKitD/SourceKitD.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ package actor SourceKitD {
482482

483483
/// A sourcekitd notification handler in a class to allow it to be uniquely referenced.
484484
package protocol SKDNotificationHandler: AnyObject, Sendable {
485-
func notification(_: SKDResponse) -> Void
485+
func notification(_: SKDResponse)
486486
}
487487

488488
struct WeakSKDNotificationHandler: Sendable {

Sources/SourceKitLSP/Swift/SwiftLanguageService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ package actor SwiftLanguageService: LanguageService, Sendable {
272272
}
273273

274274
/// - Important: For testing only
275-
package func setReusedNodeCallback(_ callback: (@Sendable (_ node: Syntax) -> ())?) async {
275+
package func setReusedNodeCallback(_ callback: (@Sendable (_ node: Syntax) -> Void)?) async {
276276
await self.syntaxTreeManager.setReusedNodeCallback(callback)
277277
}
278278

0 commit comments

Comments
 (0)