@@ -6,6 +6,7 @@ open System.IO
66open System.Diagnostics
77open System.Text
88open System.Threading .Tasks
9+ open System.Threading
910
1011open NUnit.Framework
1112open Newtonsoft.Json .Linq
@@ -432,6 +433,26 @@ type ClientController (client: MailboxProcessor<ClientEvent>, projectFiles: Map<
432433 client.PostAndReply( fun rc -> InitializeRequest rc)
433434 logMessage " Initialize" " OK, InitializeRequest complete"
434435
436+ member __.WaitForProgressEnd ( message : string ) =
437+ let timeoutMS = 10 * 1000
438+ let start = DateTime.Now
439+
440+ let progressEndMatch m =
441+ m.Source = Server
442+ && ( m.Message.[ " method" ] |> string) = " $/progress"
443+ && ( m.Message.[ " params" ].[ " value" ].[ " kind" ] |> string) = " end"
444+ && ( m.Message.[ " params" ].[ " value" ].[ " message" ] |> string) = message
445+
446+ let mutable haveProgressEnd = false
447+ while ( not haveProgressEnd) do
448+ let rpcLog = client.PostAndReply( fun rc -> GetRpcLog rc)
449+ haveProgressEnd <- rpcLog |> Seq.exists progressEndMatch
450+
451+ if ( DateTime.Now - start) .TotalMilliseconds > timeoutMS then
452+ failwith ( sprintf " WaitForProgressEnd: no $/progress[end] received in %d ms"
453+ timeoutMS)
454+ Thread.Sleep( 25 )
455+
435456 member __.Shutdown () =
436457 client.Post( ShutdownRequest)
437458 client.Post( ExitRequest)
@@ -448,6 +469,13 @@ type ClientController (client: MailboxProcessor<ClientEvent>, projectFiles: Map<
448469 let rpcLog = client.PostAndReply( fun rc -> GetRpcLog rc)
449470 rpcLog |> Seq.exists ( fun m -> m.Source = Server && ( string m.Message[ " method" ]) = rpcMethod)
450471
472+ member __.ServerDidRespondTo ( rpcMethod : string ) =
473+ let rpcLog = client.PostAndReply( fun rc -> GetRpcLog rc)
474+ let invocation = rpcLog |> Seq.find ( fun m -> m.Source = Client && ( string m.Message[ " method" ]) = rpcMethod)
475+ rpcLog
476+ |> Seq.exists ( fun m -> m.Source = Client
477+ && ( m.Message.[ " id" ] |> string) = ( invocation.Message.[ " id" ] |> string)
478+ && ( m.Message.[ " method" ] |> string) = rpcMethod)
451479
452480let startAndMountServer ( projectFiles : Map < string , string >) ( enableLogging : bool ) =
453481 let initialState = { ClientState.Default with LoggingEnabled = enableLogging }
0 commit comments