[LIGO-40] Move LSP request handlers to Capabilities directory

This commit is contained in:
Anton Myasnikov 2020-08-25 19:15:02 +03:00
parent 0b1590e324
commit 7c43cd9574
No known key found for this signature in database
GPG Key ID: FEB685E6DAA0A95F
6 changed files with 23 additions and 12 deletions

View File

@ -1,9 +1,7 @@
-- | The "all things AST"-module.
module AST (module M) where
import AST.Completion as M
import AST.Find as M
import AST.Folding as M
import AST.Capabilities as M
import AST.Parser as M
import AST.Scope as M
import AST.Skeleton as M

View File

@ -0,0 +1,7 @@
-- | Module that exports all capabilities.
module AST.Capabilities (module Exports) where
import AST.Capabilities.Completion as Exports
import AST.Capabilities.Find as Exports
import AST.Capabilities.Folding as Exports
import AST.Capabilities.Hover as Exports

View File

@ -1,6 +1,4 @@
{-# LANGUAGE RecordWildCards #-}
module AST.Completion where
module AST.Capabilities.Completion where
import Language.Haskell.LSP.Types (CompletionDoc (..), CompletionItem (..), CompletionItemKind (..))
@ -49,7 +47,11 @@ complete r tree = do
$ scope
toCompletionItem :: Completion -> CompletionItem
toCompletionItem c@Completion{..} = CompletionItem
toCompletionItem c@Completion
{ cName = cName
, cType = cType
, cDoc = _cDoc
} = CompletionItem
{ _label = cName
, _kind = Just $ CiFunction -- TODO
, _detail = Just $ ":: " <> cType -- TODO: more elaborate info
@ -68,7 +70,11 @@ toCompletionItem c@Completion{..} = CompletionItem
}
mkDoc :: Completion -> CompletionDoc
mkDoc Completion {..} = CompletionDocString $
mkDoc Completion
{ cName = cName
, cType = cType
, cDoc = cDoc
} = CompletionDocString $
cName <> " is of type " <> cType <> ". " <> cDoc
asCompletion :: ScopedDecl -> Completion

View File

@ -1,5 +1,5 @@
module AST.Find where
module AST.Capabilities.Find where
import Control.Monad

View File

@ -2,7 +2,7 @@
-- | Code folding utilities
module AST.Folding where
module AST.Capabilities.Folding where
import qualified Language.Haskell.LSP.Types as J

View File

@ -13,7 +13,7 @@ import AST.Skeleton
import Duplo.Pretty
import Product
import Range
import Data.Text (intercalate)
import Data.Text (pack, intercalate)
hoverDecl
:: CanSearch xs
@ -32,7 +32,7 @@ mkContents ScopedDecl
{ _sdType = ppToText -> _sdType
, _sdName = ppToText -> _sdName
, _sdDoc = ppToText -> _sdDoc
, _sdOrigin = ppToText -> _sdOrigin
, _sdOrigin = pack . show -> _sdOrigin
-- TODO: more documentation
} = LSP.HoverContents $ LSP.MarkupContent
{ _kind = LSP.MkMarkdown