module Ide.Plugin.Class (descriptor, Log(..)) where

import           Development.IDE             (IdeState, Recorder, WithPriority)
import           Ide.Plugin.Class.CodeAction
import           Ide.Plugin.Class.CodeLens
import           Ide.Plugin.Class.Types
import           Ide.Types
import           Language.LSP.Types

descriptor :: Recorder (WithPriority Log) -> PluginId -> PluginDescriptor IdeState
descriptor :: Recorder (WithPriority Log)
-> PluginId -> PluginDescriptor IdeState
descriptor Recorder (WithPriority Log)
recorder PluginId
plId = (forall ideState. PluginId -> PluginDescriptor ideState
defaultPluginDescriptor PluginId
plId)
    { pluginCommands :: [PluginCommand IdeState]
pluginCommands = PluginId -> [PluginCommand IdeState]
commands PluginId
plId
    , pluginRules :: Rules ()
pluginRules = Recorder (WithPriority Log) -> Rules ()
rules Recorder (WithPriority Log)
recorder
    , pluginHandlers :: PluginHandlers IdeState
pluginHandlers = forall (m :: Method 'FromClient 'Request) ideState.
PluginRequestMethod m =>
SClientMethod m
-> PluginMethodHandler ideState m -> PluginHandlers ideState
mkPluginHandler SMethod 'TextDocumentCodeAction
STextDocumentCodeAction (Recorder (WithPriority Log)
-> PluginMethodHandler IdeState 'TextDocumentCodeAction
codeAction Recorder (WithPriority Log)
recorder)
        forall a. Semigroup a => a -> a -> a
<> forall (m :: Method 'FromClient 'Request) ideState.
PluginRequestMethod m =>
SClientMethod m
-> PluginMethodHandler ideState m -> PluginHandlers ideState
mkPluginHandler SMethod 'TextDocumentCodeLens
STextDocumentCodeLens PluginMethodHandler IdeState 'TextDocumentCodeLens
codeLens
    }

commands :: PluginId -> [PluginCommand IdeState]
commands :: PluginId -> [PluginCommand IdeState]
commands PluginId
plId
  = [ forall ideState a.
FromJSON a =>
CommandId
-> Text -> CommandFunction ideState a -> PluginCommand ideState
PluginCommand CommandId
codeActionCommandId
        Text
"add placeholders for minimal methods" (PluginId -> CommandFunction IdeState AddMinimalMethodsParams
addMethodPlaceholders PluginId
plId)
    , forall ideState a.
FromJSON a =>
CommandId
-> Text -> CommandFunction ideState a -> PluginCommand ideState
PluginCommand CommandId
typeLensCommandId
        Text
"add type signatures for instance methods" CommandFunction IdeState WorkspaceEdit
codeLensCommandHandler
    ]