@@ -22,6 +22,15 @@ extension SourceKitLSPServer {
22
22
23
23
/// Configuration options for the SourceKitServer.
24
24
public struct Options : Sendable {
25
+ /// Callbacks that allow inspection of internal state modifications during testing.
26
+ public struct TestHooks : Sendable {
27
+ /// A callback that is called when an index task finishes.
28
+ public var indexTaskDidFinish : ( @Sendable ( ) -> Void ) ?
29
+
30
+ public init ( indexTaskDidFinish: ( @Sendable ( ) -> Void ) ? = nil ) {
31
+ self . indexTaskDidFinish = indexTaskDidFinish
32
+ }
33
+ }
25
34
26
35
/// Additional compiler flags (e.g. `-Xswiftc` for SwiftPM projects) and other build-related
27
36
/// configuration.
@@ -49,10 +58,7 @@ extension SourceKitLSPServer {
49
58
/// notification when running unit tests.
50
59
public var swiftPublishDiagnosticsDebounceDuration : TimeInterval
51
60
52
- /// A callback that is called when an index task finishes.
53
- ///
54
- /// Intended for testing purposes.
55
- public var indexTaskDidFinish : ( @Sendable ( ) -> Void ) ?
61
+ public var testHooks : TestHooks
56
62
57
63
public init (
58
64
buildSetup: BuildSetup = . default,
@@ -61,7 +67,8 @@ extension SourceKitLSPServer {
61
67
indexOptions: IndexOptions = . init( ) ,
62
68
completionOptions: SKCompletionOptions = . init( ) ,
63
69
generatedInterfacesPath: AbsolutePath = defaultDirectoryForGeneratedInterfaces,
64
- swiftPublishDiagnosticsDebounceDuration: TimeInterval = 2 /* 2s */
70
+ swiftPublishDiagnosticsDebounceDuration: TimeInterval = 2 , /* 2s */
71
+ testHooks: TestHooks = TestHooks ( )
65
72
) {
66
73
self . buildSetup = buildSetup
67
74
self . clangdOptions = clangdOptions
@@ -70,6 +77,7 @@ extension SourceKitLSPServer {
70
77
self . completionOptions = completionOptions
71
78
self . generatedInterfacesPath = generatedInterfacesPath
72
79
self . swiftPublishDiagnosticsDebounceDuration = swiftPublishDiagnosticsDebounceDuration
80
+ self . testHooks = testHooks
73
81
}
74
82
}
75
83
}
0 commit comments