Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .swift-format
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"NoBlockComments": false,
"OrderedImports": true,
"UseLetInEveryBoundCaseVariable": false,
"UseSynthesizedInitializer": false
"UseSynthesizedInitializer": false,
"ReturnVoidInsteadOfEmptyTuple": true,
"NoVoidReturnOnFunctionSignature": true,
}
}
14 changes: 7 additions & 7 deletions Sources/CompletionScoring/Text/CandidateBatch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ package struct CandidateBatch: Sendable {
/// Don't add a method that returns a candidate, the candidates have unsafe pointers back into the batch, and
/// must not outlive it.
@inline(__always)
func enumerate(body: (Candidate) throws -> ()) rethrows {
func enumerate(body: (Candidate) throws -> Void) rethrows {
for idx in 0..<count {
try body(candidate(at: idx))
}
}

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

package func enumerate(body: (Candidate) throws -> ()) rethrows {
package func enumerate(body: (Candidate) throws -> Void) rethrows {
try readonlyStorage.enumerate(body: body)
}

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

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

Expand Down Expand Up @@ -283,7 +283,7 @@ package struct CandidateBatch: Sendable {
count > 0
}

private mutating func mutate(body: (inout UnsafeStorage) -> ()) {
private mutating func mutate(body: (inout UnsafeStorage) -> Void) {
if !isKnownUniquelyReferenced(&__storageBox_useAccessor) {
__storageBox_useAccessor = __storageBox_useAccessor.copy()
}
Expand Down Expand Up @@ -524,7 +524,7 @@ package struct Candidate {
// Creates a buffer of `capacity` elements of type `T?`, each initially set to nil.
///
/// After running `initialize`, returns all elements that were set to non-`nil` values.
private func compactScratchArea<T>(capacity: Int, initialize: (UnsafeMutablePointer<T?>) -> ()) -> [T] {
private func compactScratchArea<T>(capacity: Int, initialize: (UnsafeMutablePointer<T?>) -> Void) -> [T] {
let scratchArea = UnsafeMutablePointer<T?>.allocate(capacity: capacity)
scratchArea.initialize(repeating: nil, count: capacity)
defer {
Expand Down
2 changes: 1 addition & 1 deletion Sources/CompletionScoring/Text/Pattern.swift
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ extension Pattern {
self.baseNameLength = baseNameLength ?? byteCount
}

func enumerate(body: (Range<Int>) -> ()) {
func enumerate(body: (Range<Int>) -> Void) {
var position = 0
for token in tokens {
body(position ..+ token.length)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ package struct BinaryEncoder {
/// - body: a closure accepting a `BinaryEncoder` that you can make `write(_:)` calls against to populate the
/// archive.
/// - Returns: a byte array that can be used with `BinaryDecoder`
static func encode(contentVersion: Int, _ body: (inout Self) -> ()) -> [UInt8] {
static func encode(contentVersion: Int, _ body: (inout Self) -> Void) -> [UInt8] {
var encoder = BinaryEncoder(contentVersion: contentVersion)
body(&encoder)
return encoder.stream
Expand Down
8 changes: 4 additions & 4 deletions Sources/CompletionScoring/Utilities/SwiftExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ protocol ContiguousZeroBasedIndexedCollection: Collection where Index == Int {
}

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

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

func concurrentForEach(body: @Sendable (Element) -> ()) where Self: Sendable {
func concurrentForEach(body: @Sendable (Element) -> Void) where Self: Sendable {
DispatchQueue.concurrentPerform(iterations: count) { index in
body(self[index])
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/CompletionScoringTestSupport/TestExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import XCTest
@inline(never)
package func drain<T>(_ value: T) {}

func duration(of body: () -> ()) -> TimeInterval {
func duration(of body: () -> Void) -> TimeInterval {
let start = ProcessInfo.processInfo.systemUptime
body()
return ProcessInfo.processInfo.systemUptime - start
Expand All @@ -30,7 +30,7 @@ extension RandomNumberGenerator {
}
}

package func withEachPermutation<T>(_ a: T, _ b: T, body: (T, T) -> ()) {
package func withEachPermutation<T>(_ a: T, _ b: T, body: (T, T) -> Void) {
body(a, b)
body(b, a)
}
Expand Down Expand Up @@ -134,7 +134,7 @@ extension XCTestCase {
/// Run `body()` `iterations`, gathering timing stats, and print them.
/// In between runs, coax for the machine into an arbitrary but consistent thermal state by either sleeping or doing
/// pointless work so that results are more comparable run to run, no matter else is happening on the machine.
package func gaugeTiming(iterations: Int = 1, testName: String = #function, _ body: () -> ()) {
package func gaugeTiming(iterations: Int = 1, testName: String = #function, _ body: () -> Void) {
let logFD = tryOrFailTest(try Self.openPerformanceLog(), message: "Failed to open performance log")
var timings = Timings()
for iteration in 0..<iterations {
Expand Down
2 changes: 1 addition & 1 deletion Sources/CompletionScoringTestSupport/Timings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ package struct Timings {
}

extension Optional {
mutating func mutateWrappedValue(mutator: (inout Wrapped) -> ()) {
mutating func mutateWrappedValue(mutator: (inout Wrapped) -> Void) {
if var wrapped = self {
self = nil // Avoid COW for clients.
mutator(&wrapped)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ final class DocCReferenceResolutionService: DocumentationService, Sendable {

func process(
_ message: DocumentationServer.Message,
completion: @escaping (DocumentationServer.Message) -> ()
completion: @escaping (DocumentationServer.Message) -> Void
) {
do {
let response = try process(message)
Expand Down
2 changes: 1 addition & 1 deletion Sources/SourceKitD/SourceKitD.swift
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ package actor SourceKitD {

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

struct WeakSKDNotificationHandler: Sendable {
Expand Down
2 changes: 1 addition & 1 deletion Sources/SourceKitLSP/Swift/SwiftLanguageService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ package actor SwiftLanguageService: LanguageService, Sendable {
}

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

Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftSourceKitPlugin/Plugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ final class RequestHandler: Sendable {
}
}

func sourcekitdProducesResult(body: @escaping @Sendable () async -> ()) -> HandleRequestResult {
func sourcekitdProducesResult(body: @escaping @Sendable () async -> Void) -> HandleRequestResult {
requestHandlingQueue.async {
await body()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ fileprivate var pathSeparator: String {

private func checkCompilationDatabaseBuildSystem(
_ compdb: String,
block: @Sendable (JSONCompilationDatabaseBuildSystem) async throws -> ()
block: @Sendable (JSONCompilationDatabaseBuildSystem) async throws -> Void
) async throws {
try await withTestScratchDir { tempDir in
let configPath = tempDir.appendingPathComponent(JSONCompilationDatabaseBuildSystem.dbName)
Expand Down
2 changes: 1 addition & 1 deletion Tests/CompletionScoringTests/TopKTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class TopKTests: XCTestCase {
}

func testSelectTopKExhaustively() throws {
func allCombinations(count: Int, body: ([Int]) -> ()) {
func allCombinations(count: Int, body: ([Int]) -> Void) {
var array = [Int](repeating: 0, count: count)
func enumerate(slot: Int) {
if slot == array.count {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ extension XCTestCase {
}

extension String {
func enumeratePrefixes(includeLowercased: Bool, body: (String) -> ()) {
func enumeratePrefixes(includeLowercased: Bool, body: (String) -> Void) {
for length in 1..<count {
body(String(prefix(length)))
if includeLowercased {
Expand Down
8 changes: 4 additions & 4 deletions Tests/SourceKitLSPTests/ExpectedIndexTaskTracker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ actor ExpectedIndexTaskTracker {
)
}

func preparationTaskDidStart(taskDescription: PreparationTaskDescription) -> Void {
func preparationTaskDidStart(taskDescription: PreparationTaskDescription) {
guard let expectedPreparations else {
return
}
Expand All @@ -160,7 +160,7 @@ actor ExpectedIndexTaskTracker {
}
}

func preparationTaskDidFinish(taskDescription: PreparationTaskDescription) -> Void {
func preparationTaskDidFinish(taskDescription: PreparationTaskDescription) {
guard let expectedPreparations else {
return
}
Expand Down Expand Up @@ -191,7 +191,7 @@ actor ExpectedIndexTaskTracker {
}
}

func updateIndexStoreTaskDidStart(taskDescription: UpdateIndexStoreTaskDescription) -> Void {
func updateIndexStoreTaskDidStart(taskDescription: UpdateIndexStoreTaskDescription) {
if Task.isCancelled {
logger.debug(
"""
Expand All @@ -212,7 +212,7 @@ actor ExpectedIndexTaskTracker {
}
}

func updateIndexStoreTaskDidFinish(taskDescription: UpdateIndexStoreTaskDescription) -> Void {
func updateIndexStoreTaskDidFinish(taskDescription: UpdateIndexStoreTaskDescription) {
guard let expectedIndexStoreUpdates else {
return
}
Expand Down