{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE OverloadedStrings #-}
module Development.IDE.Plugin.HLS.GhcIde
(
descriptors
) where
import Development.IDE
import Development.IDE.LSP.HoverDefinition
import Development.IDE.LSP.Outline
import Ide.Types
import Language.LSP.Types
import Language.LSP.Server (LspM)
import Text.Regex.TDFA.Text()
import qualified Development.IDE.Plugin.CodeAction as CodeAction
import qualified Development.IDE.Plugin.Completions as Completions
import qualified Development.IDE.Plugin.TypeLenses as TypeLenses
import Control.Monad.IO.Class
descriptors :: [PluginDescriptor IdeState]
descriptors :: [PluginDescriptor IdeState]
descriptors =
[ PluginId -> PluginDescriptor IdeState
descriptor PluginId
"ghcide-hover-and-symbols",
PluginId -> PluginDescriptor IdeState
CodeAction.descriptor PluginId
"ghcide-code-actions",
PluginId -> PluginDescriptor IdeState
Completions.descriptor PluginId
"ghcide-completions",
PluginId -> PluginDescriptor IdeState
TypeLenses.descriptor PluginId
"ghcide-type-lenses"
]
descriptor :: PluginId -> PluginDescriptor IdeState
descriptor :: PluginId -> PluginDescriptor IdeState
descriptor PluginId
plId = (PluginId -> PluginDescriptor IdeState
forall ideState. PluginId -> PluginDescriptor ideState
defaultPluginDescriptor PluginId
plId)
{ pluginHandlers :: PluginHandlers IdeState
pluginHandlers = SClientMethod 'TextDocumentHover
-> PluginMethodHandler IdeState 'TextDocumentHover
-> PluginHandlers IdeState
forall (m :: Method 'FromClient 'Request) ideState.
PluginMethod m =>
SClientMethod m
-> PluginMethodHandler ideState m -> PluginHandlers ideState
mkPluginHandler SClientMethod 'TextDocumentHover
STextDocumentHover PluginMethodHandler IdeState 'TextDocumentHover
forall c.
IdeState
-> PluginId
-> HoverParams
-> LspM c (Either ResponseError (Maybe Hover))
hover'
PluginHandlers IdeState
-> PluginHandlers IdeState -> PluginHandlers IdeState
forall a. Semigroup a => a -> a -> a
<> SClientMethod 'TextDocumentDocumentSymbol
-> PluginMethodHandler IdeState 'TextDocumentDocumentSymbol
-> PluginHandlers IdeState
forall (m :: Method 'FromClient 'Request) ideState.
PluginMethod m =>
SClientMethod m
-> PluginMethodHandler ideState m -> PluginHandlers ideState
mkPluginHandler SClientMethod 'TextDocumentDocumentSymbol
STextDocumentDocumentSymbol PluginMethodHandler IdeState 'TextDocumentDocumentSymbol
forall c.
IdeState
-> PluginId
-> DocumentSymbolParams
-> LspM
c
(Either
ResponseError (List DocumentSymbol |? List SymbolInformation))
symbolsProvider
}
hover' :: IdeState -> PluginId -> HoverParams -> LspM c (Either ResponseError (Maybe Hover))
hover' :: IdeState
-> PluginId
-> HoverParams
-> LspM c (Either ResponseError (Maybe Hover))
hover' IdeState
ideState PluginId
_ HoverParams{Maybe ProgressToken
TextDocumentIdentifier
Position
$sel:_textDocument:HoverParams :: HoverParams -> TextDocumentIdentifier
$sel:_position:HoverParams :: HoverParams -> Position
$sel:_workDoneToken:HoverParams :: HoverParams -> Maybe ProgressToken
_workDoneToken :: Maybe ProgressToken
_position :: Position
_textDocument :: TextDocumentIdentifier
..} = do
IO () -> LspT c IO ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> LspT c IO ()) -> IO () -> LspT c IO ()
forall a b. (a -> b) -> a -> b
$ Logger -> Text -> IO ()
logDebug (IdeState -> Logger
ideLogger IdeState
ideState) Text
"GhcIde.hover entered (ideLogger)"
IdeState
-> TextDocumentPositionParams
-> LspM c (Either ResponseError (Maybe Hover))
forall c.
IdeState
-> TextDocumentPositionParams
-> LspM c (Either ResponseError (Maybe Hover))
hover IdeState
ideState TextDocumentPositionParams :: TextDocumentIdentifier -> Position -> TextDocumentPositionParams
TextDocumentPositionParams{TextDocumentIdentifier
Position
$sel:_textDocument:TextDocumentPositionParams :: TextDocumentIdentifier
$sel:_position:TextDocumentPositionParams :: Position
_position :: Position
_textDocument :: TextDocumentIdentifier
..}
symbolsProvider :: IdeState -> PluginId -> DocumentSymbolParams -> LspM c (Either ResponseError (List DocumentSymbol |? List SymbolInformation))
symbolsProvider :: IdeState
-> PluginId
-> DocumentSymbolParams
-> LspM
c
(Either
ResponseError (List DocumentSymbol |? List SymbolInformation))
symbolsProvider IdeState
ide PluginId
_ DocumentSymbolParams
params = IdeState
-> DocumentSymbolParams
-> LspM
c
(Either
ResponseError (List DocumentSymbol |? List SymbolInformation))
forall c.
IdeState
-> DocumentSymbolParams
-> LspM
c
(Either
ResponseError (List DocumentSymbol |? List SymbolInformation))
moduleOutline IdeState
ide DocumentSymbolParams
params