@@ -27,7 +27,8 @@ module Test.Hls
2727 waitForBuildQueue ,
2828 waitForTypecheck ,
2929 waitForAction ,
30- sendConfigurationChanged )
30+ sendConfigurationChanged ,
31+ getLastBuildKeys )
3132where
3233
3334import Control.Applicative.Combinators
@@ -47,7 +48,7 @@ import Development.IDE (IdeState, noLogging)
4748import Development.IDE.Graph (ShakeOptions (shakeThreads ))
4849import Development.IDE.Main
4950import qualified Development.IDE.Main as Ghcide
50- import Development.IDE.Plugin.Test (TestRequest (WaitForIdeRule , WaitForShakeQueue ),
51+ import Development.IDE.Plugin.Test (TestRequest (GetLastBuildKeys , WaitForIdeRule , WaitForShakeQueue ),
5152 WaitForIdeRuleResult (ideResultSuccess ))
5253import Development.IDE.Types.Options
5354import GHC.IO.Handle
@@ -216,20 +217,27 @@ waitForBuildQueue = do
216217 -- assume a ghcide binary lacking the WaitForShakeQueue method
217218 _ -> return 0
218219
219- waitForAction :: String -> TextDocumentIdentifier -> Session (Either ResponseError WaitForIdeRuleResult )
220- waitForAction key TextDocumentIdentifier {_uri} = do
220+ callTestPlugin :: ( A. FromJSON b ) => TestRequest -> Session (Either ResponseError b )
221+ callTestPlugin cmd = do
221222 let cm = SCustomMethod " test"
222- waitId <- sendRequest cm (A. toJSON $ WaitForIdeRule key _uri )
223+ waitId <- sendRequest cm (A. toJSON cmd )
223224 ResponseMessage {_result} <- skipManyTill anyMessage $ responseForId cm waitId
224225 return $ do
225226 e <- _result
226227 case A. fromJSON e of
227228 A. Error err -> Left $ ResponseError InternalError (T. pack err) Nothing
228229 A. Success a -> pure a
229230
231+ waitForAction :: String -> TextDocumentIdentifier -> Session (Either ResponseError WaitForIdeRuleResult )
232+ waitForAction key TextDocumentIdentifier {_uri} =
233+ callTestPlugin (WaitForIdeRule key _uri)
234+
230235waitForTypecheck :: TextDocumentIdentifier -> Session (Either ResponseError Bool )
231236waitForTypecheck tid = fmap ideResultSuccess <$> waitForAction " typecheck" tid
232237
238+ getLastBuildKeys :: Session (Either ResponseError [T. Text ])
239+ getLastBuildKeys = callTestPlugin GetLastBuildKeys
240+
233241sendConfigurationChanged :: Value -> Session ()
234242sendConfigurationChanged config =
235243 sendNotification SWorkspaceDidChangeConfiguration (DidChangeConfigurationParams config)
0 commit comments