Skip to content

Commit a159f38

Browse files
committed
Match changes in ghcide
Moving PluginCommand into hls.
1 parent c8212e6 commit a159f38

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

src/Ide/Plugin.hs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import qualified Data.Text as T
2828
import Development.IDE.Core.Rules
2929
import Development.IDE.Core.Shake
3030
import Development.IDE.LSP.Server
31-
import Development.IDE.Plugin hiding (pluginCommands, pluginRules)
31+
import Development.IDE.Plugin hiding (pluginRules)
3232
import Development.IDE.Types.Diagnostics as D
3333
import Development.IDE.Types.Logger
3434
import Development.Shake hiding ( Diagnostic, command )
@@ -89,12 +89,12 @@ allLspCmdIds' pid mp = mkPlugin (allLspCmdIds pid) (Just . pluginCommands)
8989
-- ---------------------------------------------------------------------
9090

9191
rulesPlugins :: [(PluginId, Rules ())] -> Plugin Config
92-
rulesPlugins rs = Plugin mempty rules mempty
92+
rulesPlugins rs = Plugin rules mempty
9393
where
9494
rules = mconcat $ map snd rs
9595

9696
codeActionPlugins :: [(PluginId, CodeActionProvider)] -> Plugin Config
97-
codeActionPlugins cas = Plugin mempty codeActionRules (codeActionHandlers cas)
97+
codeActionPlugins cas = Plugin codeActionRules (codeActionHandlers cas)
9898

9999
codeActionRules :: Rules ()
100100
codeActionRules = mempty
@@ -152,7 +152,7 @@ data FallbackCodeActionParams =
152152
-- -----------------------------------------------------------
153153

154154
codeLensPlugins :: [(PluginId, CodeLensProvider)] -> Plugin Config
155-
codeLensPlugins cas = Plugin mempty codeLensRules (codeLensHandlers cas)
155+
codeLensPlugins cas = Plugin codeLensRules (codeLensHandlers cas)
156156

157157
codeLensRules :: Rules ()
158158
codeLensRules = mempty
@@ -192,7 +192,7 @@ makeCodeLens cas _lf ideState params = do
192192
-- -----------------------------------------------------------
193193

194194
executeCommandPlugins :: [(PluginId, [PluginCommand])] -> Plugin Config
195-
executeCommandPlugins ecs = Plugin mempty mempty (executeCommandHandlers ecs)
195+
executeCommandPlugins ecs = Plugin mempty (executeCommandHandlers ecs)
196196

197197
executeCommandHandlers :: [(PluginId, [PluginCommand])] -> PartialHandlers Config
198198
executeCommandHandlers ecs = PartialHandlers $ \WithMessage{..} x -> return x{
@@ -370,7 +370,7 @@ allLspCmdIds pid commands = concat $ map go commands
370370
-- ---------------------------------------------------------------------
371371

372372
hoverPlugins :: [(PluginId, HoverProvider)] -> Plugin Config
373-
hoverPlugins hs = Plugin mempty hoverRules (hoverHandlers hs)
373+
hoverPlugins hs = Plugin hoverRules (hoverHandlers hs)
374374

375375
hoverRules :: Rules ()
376376
hoverRules = mempty
@@ -403,8 +403,7 @@ makeHover hps _lf ideState params
403403

404404
formatterPlugins :: [(PluginId, FormattingProvider IO)] -> Plugin Config
405405
formatterPlugins providers
406-
= Plugin mempty
407-
formatterRules
406+
= Plugin formatterRules
408407
(formatterHandlers (Map.fromList (("none",noneProvider):providers)))
409408

410409
formatterRules :: Rules ()

src/Ide/Types.hs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import qualified Data.Set as S
2525
import Data.String
2626
import qualified Data.Text as T
2727
import Development.IDE.Core.Rules
28-
import Development.IDE.Plugin
28+
-- import Development.IDE.Plugin
2929
import Development.IDE.Types.Diagnostics as D
3030
import Development.IDE.Types.Location
3131
import Development.Shake
@@ -70,6 +70,16 @@ data PluginDescriptor =
7070
-- , commandFunc :: a -> IO (Either ResponseError b)
7171
-- }
7272

73+
newtype CommandId = CommandId T.Text
74+
deriving (Show, Read, Eq, Ord)
75+
instance IsString CommandId where
76+
fromString = CommandId . T.pack
77+
78+
data PluginCommand = forall a. (FromJSON a) =>
79+
PluginCommand { commandId :: CommandId
80+
, commandDesc :: T.Text
81+
, commandFunc :: a -> IO (Either ResponseError Value, Maybe (ServerMethod, ApplyWorkspaceEditParams))
82+
}
7383
-- ---------------------------------------------------------------------
7484

7585
type CodeActionProvider = IdeState

0 commit comments

Comments
 (0)