Skip to content

Commit 4b9ad3d

Browse files
committed
Allow client request handlers specified on TestSourceKitLSPClient to be executed in any order
1 parent 3436abb commit 4b9ad3d

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

Sources/SKTestSupport/TestSourceKitLSPClient.swift

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -290,18 +290,19 @@ public final class TestSourceKitLSPClient: MessageHandler {
290290
id: LanguageServerProtocol.RequestID,
291291
reply: @escaping (LSPResult<Request.Response>) -> Void
292292
) {
293-
guard let requestHandler = requestHandlers.first else {
294-
reply(.failure(.methodNotFound(Request.method)))
295-
return
296-
}
297-
guard let requestHandler = requestHandler as? RequestHandler<Request> else {
298-
print("\(RequestHandler<Request>.self)")
299-
XCTFail("Received request of unexpected type \(Request.method)")
293+
let requestHandlerAndIndex = requestHandlers.enumerated().compactMap {
294+
(index, handler) -> (RequestHandler<Request>, Int)? in
295+
guard let handler = handler as? RequestHandler<Request> else {
296+
return nil
297+
}
298+
return (handler, index)
299+
}.first
300+
guard let (requestHandler, index) = requestHandlerAndIndex else {
300301
reply(.failure(.methodNotFound(Request.method)))
301302
return
302303
}
303304
reply(.success(requestHandler(params)))
304-
requestHandlers.removeFirst()
305+
requestHandlers.remove(at: index)
305306
}
306307

307308
// MARK: - Convenience functions

Sources/SemanticIndex/UpdateIndexStoreTaskDescription.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public struct UpdateIndexStoreTaskDescription: IndexTaskDescription {
4949
}
5050

5151
public var redactedDescription: String {
52-
return "indexing-\(id)"
52+
return "update-indexstore-\(id)"
5353
}
5454

5555
init(

0 commit comments

Comments
 (0)