Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit dd2cf96

Browse files
committed
Avoid coerce for PluginId and CommandId
1 parent 6da43ab commit dd2cf96

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

hie-plugin-api/Haskell/Ide/Engine/PluginsIdeMonads.hs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ import UnliftIO
105105
import Control.Applicative
106106

107107
import Data.Aeson hiding (defaultOptions)
108-
import Data.Coerce
109108
import qualified Data.ConstrainedDynamic as CD
110109
import Data.Default
111110
import qualified Data.List as List
@@ -189,9 +188,9 @@ allLspCmdIds (IdePlugins m) = concat <$> mapM go (Map.toList (pluginCommands <$>
189188
go (plid, cmds) = mapM (mkLspCmdId plid . commandId) cmds
190189

191190
mkLspCmdId :: HasPidCache m => PluginId -> CommandId -> m T.Text
192-
mkLspCmdId plid cid = do
191+
mkLspCmdId (PluginId plid) (CommandId cid) = do
193192
pid <- T.pack . show <$> getPidCache
194-
return $ pid <> ":" <> coerce plid <> ":" <> coerce cid
193+
return $ pid <> ":" <> plid <> ":" <> cid
195194

196195
-- ---------------------------------------------------------------------
197196
-- Plugins
@@ -309,16 +308,18 @@ toDynJSON = CD.toDyn
309308
runPluginCommand :: PluginId -> CommandId -> Value
310309
-> IdeGhcM (IdeResult DynamicJSON)
311310
runPluginCommand p com arg = do
311+
let PluginId p' = p
312+
CommandId com' = com
312313
IdePlugins m <- getPlugins
313314
case Map.lookup p m of
314315
Nothing -> return $
315-
IdeResultFail $ IdeError UnknownPlugin ("Plugin " <> coerce p <> " doesn't exist") Null
316+
IdeResultFail $ IdeError UnknownPlugin ("Plugin " <> p' <> " doesn't exist") Null
316317
Just PluginDescriptor { pluginCommands = xs } -> case List.find ((com ==) . commandId) xs of
317318
Nothing -> return $ IdeResultFail $
318-
IdeError UnknownCommand ("Command " <> coerce com <> " isn't defined for plugin " <> coerce p <> ". Legal commands are: " <> T.pack(show $ map commandId xs)) Null
319+
IdeError UnknownCommand ("Command " <> com' <> " isn't defined for plugin " <> p' <> ". Legal commands are: " <> T.pack(show $ map commandId xs)) Null
319320
Just (PluginCommand _ f) -> case fromJSON arg of
320321
Error err -> return $ IdeResultFail $
321-
IdeError ParameterError ("error while parsing args for " <> coerce com <> " in plugin " <> coerce p <> ": " <> T.pack err) Null
322+
IdeError ParameterError ("error while parsing args for " <> com' <> " in plugin " <> p' <> ": " <> T.pack err) Null
322323
Success a -> do
323324
res <- f a
324325
return $ fmap toDynJSON res

src/Haskell/Ide/Engine/Server.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ requestDiagnostics DiagnosticsRequest{trigger, file, trackingNumber, documentVer
854854
forM_ dss $ \(pid,ds) -> do
855855
debugm $ "requestDiagnostics: calling diagFunc for plugin:" ++ show pid
856856
let
857-
pid' = coerce pid
857+
PluginId pid' = pid
858858
enabled = Map.findWithDefault True pid dpsEnabled
859859
publishDiagnosticsIO = Core.publishDiagnosticsFunc lf
860860
maxToSend = maxNumberOfProblems clientConfig

0 commit comments

Comments
 (0)