@@ -58,7 +58,9 @@ import Development.IDE.Test (Cursor,
5858 standardizeQuotes ,
5959 waitForAction ,
6060 waitForGC ,
61- waitForTypecheck )
61+ waitForTypecheck ,
62+ isReferenceReady ,
63+ referenceReady )
6264import Development.IDE.Test.Runfiles
6365import qualified Development.IDE.Types.Diagnostics as Diagnostics
6466import Development.IDE.Types.Location
@@ -5543,11 +5545,7 @@ simpleMultiDefTest = testCase "simple-multi-def-test" $ runWithExtraFiles "multi
55435545 adoc <- liftIO $ runInDir dir $ do
55445546 aSource <- liftIO $ readFileUtf8 aPath
55455547 adoc <- createDoc aPath " haskell" aSource
5546- ~ () <- skipManyTill anyMessage $ satisfyMaybe $ \ case
5547- FromServerMess (SCustomMethod " ghcide/reference/ready" ) (NotMess NotificationMessage {_params = fp}) -> do
5548- A. Success fp' <- pure $ fromJSON fp
5549- if equalFilePath fp' aPath then pure () else Nothing
5550- _ -> Nothing
5548+ skipManyTill anyMessage $ isReferenceReady aPath
55515549 closeDoc adoc
55525550 pure adoc
55535551 bSource <- liftIO $ readFileUtf8 bPath
@@ -5578,18 +5576,15 @@ bootTests = testGroup "boot"
55785576 -- `ghcide/reference/ready` notification.
55795577 -- Once we receive one of the above, we wait for the other that we
55805578 -- haven't received yet.
5581- -- If we don't wait for the `ready` notification it is possible
5582- -- that the `getDefinitions` request/response in the outer ghcide
5579+ -- If we don't wait for the `ready` notification it is possible
5580+ -- that the `getDefinitions` request/response in the outer ghcide
55835581 -- session will find no definitions.
55845582 let hoverParams = HoverParams cDoc (Position 4 3 ) Nothing
55855583 hoverRequestId <- sendRequest STextDocumentHover hoverParams
5586- let parseReadyMessage = satisfy $ \ case
5587- FromServerMess (SCustomMethod " ghcide/reference/ready" ) (NotMess NotificationMessage {_params = params})
5588- | A. Success fp <- fromJSON params -> equalFilePath fp cPath
5589- _ -> False
5584+ let parseReadyMessage = isReferenceReady cPath
55905585 let parseHoverResponse = responseForId STextDocumentHover hoverRequestId
55915586 hoverResponseOrReadyMessage <- skipManyTill anyMessage ((Left <$> parseHoverResponse) <|> (Right <$> parseReadyMessage))
5592- _ <- skipManyTill anyMessage $
5587+ _ <- skipManyTill anyMessage $
55935588 case hoverResponseOrReadyMessage of
55945589 Left _ -> void parseReadyMessage
55955590 Right _ -> void parseHoverResponse
@@ -6002,11 +5997,7 @@ referenceTestSession name thisDoc docs' f = testSessionWithExtraFiles "reference
60025997 loop :: [FilePath ] -> Session ()
60035998 loop [] = pure ()
60045999 loop docs = do
6005- doc <- skipManyTill anyMessage $ satisfyMaybe $ \ case
6006- FromServerMess (SCustomMethod " ghcide/reference/ready" ) (NotMess NotificationMessage {_params = fp}) -> do
6007- A. Success fp' <- pure $ fromJSON fp
6008- find (fp' == ) docs
6009- _ -> Nothing
6000+ doc <- skipManyTill anyMessage $ referenceReady (`elem` docs)
60106001 loop (delete doc docs)
60116002 loop docs
60126003 f dir
0 commit comments