@@ -26,27 +26,17 @@ extension sourcekitd_api_keys: @unchecked Sendable {}
2626extension sourcekitd_api_requests : @unchecked Sendable { }
2727extension sourcekitd_api_values : @unchecked Sendable { }
2828
29- public struct SourceKitDTestHooks : Sendable {
30- public var sourcekitdRequestDidStart : ( @Sendable ( SKDRequestDictionary ) -> Void ) ?
31-
32- public init ( sourcekitdRequestDidStart: ( @Sendable ( SKDRequestDictionary ) -> Void ) ? = nil ) {
33- self . sourcekitdRequestDidStart = sourcekitdRequestDidStart
34- }
35- }
36-
3729/// Wrapper for sourcekitd, taking care of initialization, shutdown, and notification handler
3830/// multiplexing.
3931///
4032/// Users of this class should not call the api functions `initialize`, `shutdown`, or
4133/// `set_notification_handler`, which are global state managed internally by this class.
4234public actor DynamicallyLoadedSourceKitD : SourceKitD {
4335 /// The path to the sourcekitd dylib.
44- private let path : AbsolutePath
36+ public let path : AbsolutePath
4537
4638 /// The handle to the dylib.
47- private let dylib : DLHandle
48-
49- public let testHooks : SourceKitDTestHooks
39+ let dylib : DLHandle
5040
5141 /// The sourcekitd API functions.
5242 public let api : sourcekitd_api_functions_t
@@ -65,23 +55,18 @@ public actor DynamicallyLoadedSourceKitD: SourceKitD {
6555 /// List of notification handlers that will be called for each notification.
6656 private var notificationHandlers : [ WeakSKDNotificationHandler ] = [ ]
6757
68- /// If there is already a `sourcekitd` instance from the given return it, otherwise create a new one.
69- ///
70- /// `testHooks` are only considered when an instance is being created. If a sourcekitd instance at the given path
71- /// already exists, its test hooks will be used.
72- public static func getOrCreate( dylibPath: AbsolutePath , testHooks: SourceKitDTestHooks ) async throws -> SourceKitD {
58+ public static func getOrCreate( dylibPath: AbsolutePath ) async throws -> SourceKitD {
7359 try await SourceKitDRegistry . shared
74- . getOrAdd ( dylibPath, create: { try DynamicallyLoadedSourceKitD ( dylib: dylibPath, testHooks : testHooks ) } )
60+ . getOrAdd ( dylibPath, create: { try DynamicallyLoadedSourceKitD ( dylib: dylibPath) } )
7561 }
7662
77- init ( dylib path: AbsolutePath , testHooks : SourceKitDTestHooks ) throws {
63+ init ( dylib path: AbsolutePath ) throws {
7864 self . path = path
7965 #if os(Windows)
8066 self . dylib = try dlopen ( path. pathString, mode: [ ] )
8167 #else
8268 self . dylib = try dlopen ( path. pathString, mode: [ . lazy, . local, . first] )
8369 #endif
84- self . testHooks = testHooks
8570 self . api = try sourcekitd_api_functions_t ( self . dylib)
8671 self . keys = sourcekitd_api_keys ( api: self . api)
8772 self . requests = sourcekitd_api_requests ( api: self . api)
0 commit comments