@@ -26,27 +26,17 @@ extension sourcekitd_api_keys: @unchecked Sendable {}
26
26
extension sourcekitd_api_requests : @unchecked Sendable { }
27
27
extension sourcekitd_api_values : @unchecked Sendable { }
28
28
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
-
37
29
/// Wrapper for sourcekitd, taking care of initialization, shutdown, and notification handler
38
30
/// multiplexing.
39
31
///
40
32
/// Users of this class should not call the api functions `initialize`, `shutdown`, or
41
33
/// `set_notification_handler`, which are global state managed internally by this class.
42
34
public actor DynamicallyLoadedSourceKitD : SourceKitD {
43
35
/// The path to the sourcekitd dylib.
44
- private let path : AbsolutePath
36
+ public let path : AbsolutePath
45
37
46
38
/// The handle to the dylib.
47
- private let dylib : DLHandle
48
-
49
- public let testHooks : SourceKitDTestHooks
39
+ let dylib : DLHandle
50
40
51
41
/// The sourcekitd API functions.
52
42
public let api : sourcekitd_api_functions_t
@@ -65,23 +55,18 @@ public actor DynamicallyLoadedSourceKitD: SourceKitD {
65
55
/// List of notification handlers that will be called for each notification.
66
56
private var notificationHandlers : [ WeakSKDNotificationHandler ] = [ ]
67
57
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 {
73
59
try await SourceKitDRegistry . shared
74
- . getOrAdd ( dylibPath, create: { try DynamicallyLoadedSourceKitD ( dylib: dylibPath, testHooks : testHooks ) } )
60
+ . getOrAdd ( dylibPath, create: { try DynamicallyLoadedSourceKitD ( dylib: dylibPath) } )
75
61
}
76
62
77
- init ( dylib path: AbsolutePath , testHooks : SourceKitDTestHooks ) throws {
63
+ init ( dylib path: AbsolutePath ) throws {
78
64
self . path = path
79
65
#if os(Windows)
80
66
self . dylib = try dlopen ( path. pathString, mode: [ ] )
81
67
#else
82
68
self . dylib = try dlopen ( path. pathString, mode: [ . lazy, . local, . first] )
83
69
#endif
84
- self . testHooks = testHooks
85
70
self . api = try sourcekitd_api_functions_t ( self . dylib)
86
71
self . keys = sourcekitd_api_keys ( api: self . api)
87
72
self . requests = sourcekitd_api_requests ( api: self . api)
0 commit comments