Skip to content

Commit d12b258

Browse files
committed
Rename SourceKitDImpl to DynamicallyLoadedSourceKitD
This makes it clearer how exactly `SourceKitDImpl` interacts with sourcekitd.
1 parent 5f69147 commit d12b258

File tree

8 files changed

+15
-13
lines changed

8 files changed

+15
-13
lines changed

Sources/Diagnose/SourcekitdRequestCommand.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public struct SourceKitdRequestCommand: AsyncParsableCommand {
4040
public func run() async throws {
4141
let requestString = try String(contentsOf: URL(fileURLWithPath: sourcekitdRequestPath))
4242

43-
let sourcekitd = try SourceKitDImpl.getOrCreate(
43+
let sourcekitd = try DynamicallyLoadedSourceKitD.getOrCreate(
4444
dylibPath: try! AbsolutePath(validating: sourcekitdPath)
4545
)
4646

Sources/SourceKitD/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ add_library(SourceKitD STATIC
66
SKDResponseArray.swift
77
SKDResponseDictionary.swift
88
SourceKitD.swift
9-
SourceKitDImpl.swift
9+
DynamicallyLoadedSourceKitD.swift
1010
SourceKitDRegistry.swift
1111
sourcekitd_functions.swift
1212
sourcekitd_uids.swift)

Sources/SourceKitD/SourceKitDImpl.swift renamed to Sources/SourceKitD/DynamicallyLoadedSourceKitD.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import struct TSCBasic.AbsolutePath
2121
///
2222
/// Users of this class should not call the api functions `initialize`, `shutdown`, or
2323
/// `set_notification_handler`, which are global state managed internally by this class.
24-
public final class SourceKitDImpl: SourceKitD {
24+
public final class DynamicallyLoadedSourceKitD: SourceKitD {
2525

2626
/// The path to the sourcekitd dylib.
2727
public let path: AbsolutePath
@@ -49,7 +49,7 @@ public final class SourceKitDImpl: SourceKitD {
4949

5050
public static func getOrCreate(dylibPath: AbsolutePath) throws -> SourceKitD {
5151
try SourceKitDRegistry.shared
52-
.getOrAdd(dylibPath, create: { try SourceKitDImpl(dylib: dylibPath) })
52+
.getOrAdd(dylibPath, create: { try DynamicallyLoadedSourceKitD(dylib: dylibPath) })
5353
}
5454

5555
init(dylib path: AbsolutePath) throws {

Sources/SourceKitD/SourceKitD.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,6 @@ extension SourceKitD {
112112

113113
return dict
114114
}
115-
116-
public func log(request: SKDRequestDictionary) {}
117-
public func log(response: SKDResponse) {}
118-
public func log(crashedRequest: SKDRequestDictionary, fileContents: String?) {}
119115
}
120116

121117
/// A sourcekitd notification handler in a class to allow it to be uniquely referenced.

Sources/SourceKitLSP/Swift/SwiftLanguageServer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public actor SwiftLanguageServer: ToolchainLanguageServer {
158158
guard let sourcekitd = toolchain.sourcekitd else { return nil }
159159
self.sourceKitServer = sourceKitServer
160160
self.swiftFormat = toolchain.swiftFormat
161-
self.sourcekitd = try SourceKitDImpl.getOrCreate(dylibPath: sourcekitd)
161+
self.sourcekitd = try DynamicallyLoadedSourceKitD.getOrCreate(dylibPath: sourcekitd)
162162
self.capabilityRegistry = workspace.capabilityRegistry
163163
self.serverOptions = options
164164
self.documentManager = DocumentManager()

Tests/DiagnoseTests/DiagnoseTests.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,9 @@ private struct InProcessSourceKitRequestExecutor: SourceKitRequestExecutor {
204204
func run(request requestYaml: String) async throws -> SourceKitDRequestResult {
205205
logger.info("Sending request: \(requestYaml)")
206206

207-
let sourcekitd = try SourceKitDImpl.getOrCreate(dylibPath: try! AbsolutePath(validating: sourcekitd.path))
207+
let sourcekitd = try DynamicallyLoadedSourceKitD.getOrCreate(
208+
dylibPath: try! AbsolutePath(validating: sourcekitd.path)
209+
)
208210
let response = try await sourcekitd.run(requestYaml: requestYaml)
209211

210212
logger.info("Received response: \(response.description)")

Tests/SourceKitDTests/SourceKitDRegistryTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,8 @@ final class FakeSourceKitD: SourceKitD {
7575
static func getOrCreate(_ path: AbsolutePath, in registry: SourceKitDRegistry) -> SourceKitD {
7676
return registry.getOrAdd(path, create: { Self.init() })
7777
}
78+
79+
public func log(request: SKDRequestDictionary) {}
80+
public func log(response: SKDResponse) {}
81+
public func log(crashedRequest: SKDRequestDictionary, fileContents: String?) {}
7882
}

Tests/SourceKitDTests/SourceKitDTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import class TSCBasic.Process
2828
final class SourceKitDTests: XCTestCase {
2929
func testMultipleNotificationHandlers() async throws {
3030
let sourcekitdPath = await ToolchainRegistry.forTesting.default!.sourcekitd!
31-
let sourcekitd = try SourceKitDImpl.getOrCreate(dylibPath: sourcekitdPath)
31+
let sourcekitd = try DynamicallyLoadedSourceKitD.getOrCreate(dylibPath: sourcekitdPath)
3232
let keys = sourcekitd.keys
3333
let path = DocumentURI.for(.swift).pseudoPath
3434

@@ -47,7 +47,7 @@ final class SourceKitDTests: XCTestCase {
4747
expectation1.fulfill()
4848
}
4949
}
50-
// SourceKitDImpl weakly references handlers
50+
// DynamicallyLoadedSourceKitD weakly references handlers
5151
defer {
5252
_fixLifetime(handler1)
5353
}
@@ -59,7 +59,7 @@ final class SourceKitDTests: XCTestCase {
5959
expectation2.fulfill()
6060
}
6161
}
62-
// SourceKitDImpl weakly references handlers
62+
// DynamicallyLoadedSourceKitD weakly references handlers
6363
defer {
6464
_fixLifetime(handler2)
6565
}

0 commit comments

Comments
 (0)