@@ -27,7 +27,8 @@ module Test.Hls
27
27
waitForBuildQueue ,
28
28
waitForTypecheck ,
29
29
waitForAction ,
30
- sendConfigurationChanged )
30
+ sendConfigurationChanged ,
31
+ getLastBuildKeys )
31
32
where
32
33
33
34
import Control.Applicative.Combinators
@@ -47,7 +48,7 @@ import Development.IDE (IdeState, noLogging)
47
48
import Development.IDE.Graph (ShakeOptions (shakeThreads ))
48
49
import Development.IDE.Main
49
50
import 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 ),
51
52
WaitForIdeRuleResult (ideResultSuccess ))
52
53
import Development.IDE.Types.Options
53
54
import GHC.IO.Handle
@@ -216,20 +217,27 @@ waitForBuildQueue = do
216
217
-- assume a ghcide binary lacking the WaitForShakeQueue method
217
218
_ -> return 0
218
219
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
221
222
let cm = SCustomMethod " test"
222
- waitId <- sendRequest cm (A. toJSON $ WaitForIdeRule key _uri )
223
+ waitId <- sendRequest cm (A. toJSON cmd )
223
224
ResponseMessage {_result} <- skipManyTill anyMessage $ responseForId cm waitId
224
225
return $ do
225
226
e <- _result
226
227
case A. fromJSON e of
227
228
A. Error err -> Left $ ResponseError InternalError (T. pack err) Nothing
228
229
A. Success a -> pure a
229
230
231
+ waitForAction :: String -> TextDocumentIdentifier -> Session (Either ResponseError WaitForIdeRuleResult )
232
+ waitForAction key TextDocumentIdentifier {_uri} =
233
+ callTestPlugin (WaitForIdeRule key _uri)
234
+
230
235
waitForTypecheck :: TextDocumentIdentifier -> Session (Either ResponseError Bool )
231
236
waitForTypecheck tid = fmap ideResultSuccess <$> waitForAction " typecheck" tid
232
237
238
+ getLastBuildKeys :: Session (Either ResponseError [T. Text ])
239
+ getLastBuildKeys = callTestPlugin GetLastBuildKeys
240
+
233
241
sendConfigurationChanged :: Value -> Session ()
234
242
sendConfigurationChanged config =
235
243
sendNotification SWorkspaceDidChangeConfiguration (DidChangeConfigurationParams config)
0 commit comments