@@ -58,7 +58,9 @@ import Development.IDE.Test (Cursor,
58
58
standardizeQuotes ,
59
59
waitForAction ,
60
60
waitForGC ,
61
- waitForTypecheck )
61
+ waitForTypecheck ,
62
+ isReferenceReady ,
63
+ referenceReady )
62
64
import Development.IDE.Test.Runfiles
63
65
import qualified Development.IDE.Types.Diagnostics as Diagnostics
64
66
import Development.IDE.Types.Location
@@ -5543,11 +5545,7 @@ simpleMultiDefTest = testCase "simple-multi-def-test" $ runWithExtraFiles "multi
5543
5545
adoc <- liftIO $ runInDir dir $ do
5544
5546
aSource <- liftIO $ readFileUtf8 aPath
5545
5547
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
5551
5549
closeDoc adoc
5552
5550
pure adoc
5553
5551
bSource <- liftIO $ readFileUtf8 bPath
@@ -5578,18 +5576,15 @@ bootTests = testGroup "boot"
5578
5576
-- `ghcide/reference/ready` notification.
5579
5577
-- Once we receive one of the above, we wait for the other that we
5580
5578
-- 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
5583
5581
-- session will find no definitions.
5584
5582
let hoverParams = HoverParams cDoc (Position 4 3 ) Nothing
5585
5583
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
5590
5585
let parseHoverResponse = responseForId STextDocumentHover hoverRequestId
5591
5586
hoverResponseOrReadyMessage <- skipManyTill anyMessage ((Left <$> parseHoverResponse) <|> (Right <$> parseReadyMessage))
5592
- _ <- skipManyTill anyMessage $
5587
+ _ <- skipManyTill anyMessage $
5593
5588
case hoverResponseOrReadyMessage of
5594
5589
Left _ -> void parseReadyMessage
5595
5590
Right _ -> void parseHoverResponse
@@ -6002,11 +5997,7 @@ referenceTestSession name thisDoc docs' f = testSessionWithExtraFiles "reference
6002
5997
loop :: [FilePath ] -> Session ()
6003
5998
loop [] = pure ()
6004
5999
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)
6010
6001
loop (delete doc docs)
6011
6002
loop docs
6012
6003
f dir
0 commit comments