@@ -83,6 +83,8 @@ public final class TestSourceKitLSPClient: MessageHandler {
83
83
/// - capabilities: The test client's capabilities.
84
84
/// - usePullDiagnostics: Whether to use push diagnostics or use push-based diagnostics
85
85
/// - workspaceFolders: Workspace folders to open.
86
+ /// - preInitialization: A closure that is called after the test client is created but before SourceKit-LSP is
87
+ /// initialized. This can be used to eg. register request handlers.
86
88
/// - cleanUp: A closure that is called when the `TestSourceKitLSPClient` is destructed.
87
89
/// This allows e.g. a `IndexedSingleSwiftFileTestProject` to delete its temporary files when they are no longer
88
90
/// needed.
@@ -94,6 +96,7 @@ public final class TestSourceKitLSPClient: MessageHandler {
94
96
capabilities: ClientCapabilities = ClientCapabilities ( ) ,
95
97
usePullDiagnostics: Bool = true ,
96
98
workspaceFolders: [ WorkspaceFolder ] ? = nil ,
99
+ preInitialization: ( ( TestSourceKitLSPClient ) -> Void ) ? = nil ,
97
100
cleanUp: @escaping ( ) -> Void = { }
98
101
) async throws {
99
102
if !useGlobalModuleCache {
@@ -135,7 +138,7 @@ public final class TestSourceKitLSPClient: MessageHandler {
135
138
guard capabilities. textDocument!. diagnostic == nil else {
136
139
struct ConflictingDiagnosticsError : Error , CustomStringConvertible {
137
140
var description : String {
138
- " usePushDiagnostics = false is not supported if capabilities already contain diagnostic options"
141
+ " usePullDiagnostics = false is not supported if capabilities already contain diagnostic options"
139
142
}
140
143
}
141
144
throw ConflictingDiagnosticsError ( )
@@ -145,6 +148,7 @@ public final class TestSourceKitLSPClient: MessageHandler {
145
148
XCTAssertEqual ( request. registrations. only? . method, DocumentDiagnosticsRequest . method)
146
149
return VoidResponse ( )
147
150
}
151
+ preInitialization ? ( self )
148
152
}
149
153
if initialize {
150
154
_ = try await self . send (
0 commit comments