Skip to content

Commit c05e9b8

Browse files
authored
Merge pull request swiftlang#18 from yhkaplan/cleanup-syntax
Cleanup syntax
2 parents 1a076bb + 22a4941 commit c05e9b8

File tree

10 files changed

+23
-24
lines changed

10 files changed

+23
-24
lines changed

Sources/LanguageServerProtocol/Request.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ public final class Request<R: RequestType> {
4141
public let cancellationToken: CancellationToken
4242

4343
public init(_ request: Params, id: RequestID, clientID: ObjectIdentifier, cancellation: CancellationToken, reply: @escaping (LSPResult<Response>) -> ()) {
44-
4544
self.id = id
4645
self.clientID = clientID
4746
self.params = request

Sources/LanguageServerProtocolJSONRPC/JSONRPCConnection.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ public final class JSONRPCConection {
4848
/// The set of currently outstanding outgoing requests along with information about how to decode and handle their responses.
4949
var outstandingRequests: [RequestID: OutstandingRequest] = [:]
5050

51-
var closeHandler: () -> ()
51+
var closeHandler: () -> Void
5252

53-
public init(inFD: Int32, outFD: Int32, closeHandler: @escaping () -> () = {}) {
53+
public init(inFD: Int32, outFD: Int32, closeHandler: @escaping () -> Void = {}) {
5454
state = .created
5555
self.closeHandler = closeHandler
5656

Sources/SKCore/Toolchain.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ extension Toolchain {
118118
}
119119

120120
/// Search `path` for tools, returning true if any are found.
121+
@discardableResult
121122
func searchForTools(_ path: AbsolutePath, _ fs: FileSystem = localFileSystem) -> Bool {
122123
return
123124
searchForTools(binPath: path, fs) ||

Sources/SKSupport/Cancellation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public final class CancellationToken {
1717

1818
public init() {}
1919

20-
public func addCancellationHandler(_ handler: @escaping () -> ()) {
20+
public func addCancellationHandler(_ handler: @escaping () -> Void) {
2121

2222
}
2323

Sources/SKSupport/Platform.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ extension Platform {
1818
public var dynamicLibraryExtension: String {
1919
switch self {
2020
case .darwin: return "dylib"
21-
case .linux(_): return "so"
21+
case .linux: return "so"
2222
}
2323
}
2424
}

Sources/SKSwiftPMWorkspace/SwiftPMWorkspace.swift

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public final class SwiftPMWorkspace {
6767
self.packageRoot = packageRoot
6868
self.fs = fileSystem
6969

70-
guard var swiftpmToolchain = toolchainRegistry.swiftpmHost else {
70+
guard var swiftpmToolchain = toolchainRegistry.swiftPMHost else {
7171
throw Error.cannotDetermineHostToolchain
7272
}
7373

@@ -244,7 +244,7 @@ extension SwiftPMWorkspace {
244244
workingDirectory: workspacePath.asString
245245
)
246246

247-
case (.clang(_), .swift):
247+
case (.clang, .swift):
248248
return nil
249249

250250
case (.clang(let td), _):
@@ -309,13 +309,12 @@ extension SwiftPMWorkspace {
309309
}
310310

311311
func packageDescriptionSettings(_ path: AbsolutePath) -> FileBuildSettings? {
312-
for package in packageGraph.packages {
313-
if path == package.manifest.path {
312+
for package in packageGraph.packages where path == package.manifest.path {
313+
let compilerArgs = workspace.interpreterFlags(for: package.path) + [path.asString]
314314
return FileBuildSettings(
315315
preferredToolchain: nil,
316-
compilerArguments:
317-
workspace.interpreterFlags(for: package.path) + [path.asString])
318-
}
316+
compilerArguments: compilerArgs
317+
)
319318
}
320319
return nil
321320
}
@@ -348,7 +347,7 @@ private struct SwiftPMToolchain: Build.Toolchain, ManifestResourceProvider {
348347
extension ToolchainRegistry {
349348

350349
/// A toolchain appropriate for using to load swiftpm manifests.
351-
fileprivate var swiftpmHost: SwiftPMToolchain? {
350+
fileprivate var swiftPMHost: SwiftPMToolchain? {
352351
var swiftc: AbsolutePath? = self.default?.swiftc
353352
var clang: AbsolutePath? = self.default?.clang
354353
if swiftc == nil {

Sources/SourceKit/SourceKitServer.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ public final class SourceKitServer: LanguageServer {
3838

3939
let fs: FileSystem
4040

41-
let onExit: () -> ()
41+
let onExit: () -> Void
4242

4343
/// Creates a language server for the given client.
44-
public init(client: Connection, fileSystem: FileSystem = localFileSystem, onExit: @escaping () -> () = {}) {
44+
public init(client: Connection, fileSystem: FileSystem = localFileSystem, onExit: @escaping () -> Void = {}) {
4545

4646
self.fs = fileSystem
4747
self.toolchainRegistry = ToolchainRegistry.shared

Sources/SourceKit/sourcekitd/SwiftLanguageServer.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ public final class SwiftLanguageServer: LanguageServer {
2626
// FIXME: ideally we wouldn't need separate management from a parent server in the same process.
2727
var documentManager: DocumentManager
2828

29-
let onExit: () -> ()
29+
let onExit: () -> Void
3030

3131
var api: sourcekitd_functions_t { return sourcekitd.api }
3232
var keys: sourcekitd_keys { return sourcekitd.keys }
3333
var requests: sourcekitd_requests { return sourcekitd.requests }
3434
var values: sourcekitd_values { return sourcekitd.values }
3535

3636
/// Creates a language server for the given client using the sourcekitd dylib at the specified path.
37-
public init(client: Connection, sourcekitd: AbsolutePath, buildSystem: BuildSystem, onExit: @escaping () -> () = {}) throws {
37+
public init(client: Connection, sourcekitd: AbsolutePath, buildSystem: BuildSystem, onExit: @escaping () -> Void = {}) throws {
3838

3939
self.sourcekitd = try SwiftSourceKitFramework(dylib: sourcekitd)
4040
self.buildSystem = buildSystem
@@ -328,7 +328,7 @@ extension SwiftLanguageServer {
328328

329329
var result = CompletionList(isIncomplete: false, items: [])
330330

331-
let cancelled = !completions.forEach({ (i, value) -> Bool in
331+
let cancelled = !completions.forEach { (i, value) -> Bool in
332332
// Check for cancellation periodically when there are many results.
333333
if i % 100 == 0, req.isCancelled {
334334
req.reply(LSPResult.failure(.cancelled))
@@ -357,7 +357,7 @@ extension SwiftLanguageServer {
357357
))
358358

359359
return true
360-
})
360+
}
361361

362362
if !cancelled {
363363
req.reply(result)
@@ -527,7 +527,7 @@ extension SwiftLanguageServer {
527527

528528
var highlights: [DocumentHighlight] = []
529529

530-
results.forEach { i, value in
530+
results.forEach { _, value in
531531
if let offset: Int = value[self.keys.offset],
532532
let start: Position = snapshot.positionOf(utf8Offset: offset),
533533
let length: Int = value[self.keys.length],

Sources/sourcekit-lsp/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ let clientConnection = JSONRPCConection(inFD: STDIN_FILENO, outFD: STDOUT_FILENO
2424
exit(0)
2525
})
2626

27-
Logger.shared.addLogHandler { message, level in
27+
Logger.shared.addLogHandler { message, _ in
2828
clientConnection.send(LogMessage(type: .log, message: message))
2929
}
3030

Tests/LanguageServerProtocolJSONRPCTests/ConnectionPerfTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class ConnectionPerfTests: XCTestCase {
3232
self.measureMetrics([.wallClockTime], automaticallyStartMeasuring: false) {
3333
let expectation = self.expectation(description: "response received")
3434
self.startMeasuring()
35-
_ = client.send(EchoRequest(string: "hello!")) { resp in
35+
_ = client.send(EchoRequest(string: "hello!")) { _ in
3636
self.stopMeasuring()
3737
expectation.fulfill()
3838
}
@@ -46,7 +46,7 @@ class ConnectionPerfTests: XCTestCase {
4646
let sema = DispatchSemaphore(value: 0)
4747
self.measure {
4848
for _ in 1...100 {
49-
_ = client.send(EchoRequest(string: "hello!")) { resp in
49+
_ = client.send(EchoRequest(string: "hello!")) { _ in
5050
sema.signal()
5151
}
5252
XCTAssertEqual(sema.wait(timeout: .now() + .seconds(10)), .success)
@@ -59,7 +59,7 @@ class ConnectionPerfTests: XCTestCase {
5959
let sema = DispatchSemaphore(value: 0)
6060
self.measure {
6161
DispatchQueue.concurrentPerform(iterations: 100, execute: { _ in
62-
_ = client.send(EchoRequest(string: "hello!")) { resp in
62+
_ = client.send(EchoRequest(string: "hello!")) { _ in
6363
sema.signal()
6464
}
6565
})

0 commit comments

Comments
 (0)