@@ -13,6 +13,7 @@ import qualified Data.Text as T
1313import Data.Default
1414import GHC ( TypecheckedModule )
1515import GHC.Generics
16+ import Haskell.Ide.Engine.Ghc
1617import Haskell.Ide.Engine.MonadTypes
1718import Haskell.Ide.Engine.PluginUtils
1819import Haskell.Ide.Engine.Scheduler
@@ -33,7 +34,6 @@ import System.IO
3334import Haskell.Ide.Engine.Plugin.ApplyRefact
3435import Haskell.Ide.Engine.Plugin.Example2
3536-- import Haskell.Ide.Engine.Plugin.HaRe
36- import Haskell.Ide.Engine.Plugin.Bios
3737import Haskell.Ide.Engine.Plugin.Generic
3838
3939{-# ANN module ("HLint: ignore Redundant do" :: String) #-}
@@ -64,7 +64,6 @@ plugins :: IdePlugins
6464plugins = pluginDescToIdePlugins
6565 [applyRefactDescriptor " applyrefact"
6666 ,example2Descriptor " eg2"
67- ,biosDescriptor " bios"
6867 ]
6968
7069startServer :: IO (Scheduler IO , TChan LogVal , ThreadId )
@@ -90,17 +89,17 @@ logToChan c t = atomically $ writeTChan c t
9089
9190-- ---------------------------------------------------------------------
9291
93- dispatchGhcRequest :: ToJSON a
92+ dispatchGhcRequest :: ( Typeable a , ToJSON a )
9493 => TrackingNumber -> Maybe Uri -> String -> Int
9594 -> Scheduler IO -> TChan LogVal
96- -> PluginId -> CommandName -> a -> IO ()
97- dispatchGhcRequest tn uri ctx n scheduler lc plugin com arg = do
95+ -> IdeGhcM ( IdeResult a ) -> IO ()
96+ dispatchGhcRequest tn uri ctx n scheduler lc f = do
9897 let
9998 logger :: RequestCallback IO DynamicJSON
10099 logger x = logToChan lc (ctx, Right x)
101100
102101 let req = GReq tn " plugin-command" uri Nothing (Just (IdInt n)) logger (toDynJSON (Nothing :: Maybe () )) $
103- runPluginCommand plugin com (toJSON arg)
102+ fmap toDynJSON <$> f
104103 sendRequest scheduler req
105104
106105
@@ -163,7 +162,7 @@ funcSpec = describe "functional dispatch" $ do
163162 show rrr `shouldBe` " Nothing"
164163
165164 -- need to typecheck the module to trigger deferred response
166- dispatchGhcRequest 2 (Just testUri) " req2" 2 scheduler logChan " bios " " check " (toJSON testUri)
165+ dispatchGhcRequest 2 (Just testUri) " req2" 2 scheduler logChan $ setTypecheckedModule testUri
167166
168167 -- And now we get the deferred response (once the module is loaded)
169168 (" req1" ,Right res) <- atomically $ readTChan logChan
@@ -245,7 +244,7 @@ funcSpec = describe "functional dispatch" $ do
245244
246245 it " returns hints as diagnostics" $ do
247246
248- dispatchGhcRequest 5 (Just testUri) " r5" 5 scheduler logChan " applyrefact " " lint" testUri
247+ dispatchGhcRequest 5 (Just testUri) " r5" 5 scheduler logChan $ lint testUri
249248
250249 hr5 <- atomically $ readTChan logChan
251250 unpackRes hr5 `shouldBe` (" r5" ,
@@ -275,7 +274,7 @@ funcSpec = describe "functional dispatch" $ do
275274 -- (Just $ H.singleton r6uri textEdits)
276275 -- Nothing
277276 -- ))
278- dispatchGhcRequest 6 (Just testUri) " r6" 6 scheduler logChan " bios " " check " (toJSON testUri)
277+ dispatchGhcRequest 6 (Just testUri) " r6" 6 scheduler logChan $ setTypecheckedModule testUri
279278 hr6 <- atomically $ readTChan logChan
280279 unpackRes hr6 `shouldBe` (" r6" ,Nothing :: Maybe Int )
281280
@@ -285,7 +284,7 @@ funcSpec = describe "functional dispatch" $ do
285284
286285 dispatchIdeRequest 7 " req7" scheduler logChan (IdInt 7 ) $ findDef testFailUri (Position 1 2 )
287286
288- dispatchGhcRequest 8 (Just testUri) " req8" 8 scheduler logChan " bios " " check " (toJSON testFailUri)
287+ dispatchGhcRequest 8 (Just testUri) " req8" 8 scheduler logChan $ setTypecheckedModule testFailUri
289288
290289 hr7 <- atomically $ readTChan logChan
291290 unpackRes hr7 `shouldBe` (" req7" , Just ([] :: [Location ]))
0 commit comments