projects
/
lsp-test.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
66d495a
)
Fix getDefinitions for SingleLoc and add getCodeLenses
author
Moritz Kiefer
<moritz.kiefer@purelyfunctional.org>
Tue, 11 Jun 2019 08:19:18 +0000
(10:19 +0200)
committer
Luke Lau
<luke_lau@icloud.com>
Thu, 13 Jun 2019 08:32:12 +0000
(09:32 +0100)
src/Language/Haskell/LSP/Test.hs
patch
|
blob
|
history
diff --git
a/src/Language/Haskell/LSP/Test.hs
b/src/Language/Haskell/LSP/Test.hs
index bc04845f8d9774e4f5cd00c48e8cbe74153e1417..1c425fb89cc49aa0af526b99ab7d5753d261a679 100644
(file)
--- a/
src/Language/Haskell/LSP/Test.hs
+++ b/
src/Language/Haskell/LSP/Test.hs
@@
-79,6
+79,8
@@
module Language.Haskell.LSP.Test
, formatRange
-- ** Edits
, applyEdit
, formatRange
-- ** Edits
, applyEdit
+ -- ** Code lenses
+ , getCodeLenses
) where
import Control.Applicative.Combinators
) where
import Control.Applicative.Combinators
@@
-518,9
+520,12
@@
getReferences doc pos inclDecl =
getDefinitions :: TextDocumentIdentifier -- ^ The document the term is in.
-> Position -- ^ The position the term is at.
-> Session [Location] -- ^ The location(s) of the definitions
getDefinitions :: TextDocumentIdentifier -- ^ The document the term is in.
-> Position -- ^ The position the term is at.
-> Session [Location] -- ^ The location(s) of the definitions
-getDefinitions doc pos =
+getDefinitions doc pos =
do
let params = TextDocumentPositionParams doc pos
let params = TextDocumentPositionParams doc pos
- in getResponseResult <$> request TextDocumentDefinition params
+ rsp <- request TextDocumentDefinition params :: Session DefinitionResponse
+ case getResponseResult rsp of
+ SingleLoc loc -> pure [loc]
+ MultiLoc locs -> pure locs
-- | Returns the type definition(s) for the term at the specified position.
getTypeDefinitions :: TextDocumentIdentifier -- ^ The document the term is in.
-- | Returns the type definition(s) for the term at the specified position.
getTypeDefinitions :: TextDocumentIdentifier -- ^ The document the term is in.
@@
-577,3
+582,10
@@
applyTextEdits doc edits =
let wEdit = WorkspaceEdit (Just (HashMap.singleton (doc ^. uri) edits)) Nothing
req = RequestMessage "" (IdInt 0) WorkspaceApplyEdit (ApplyWorkspaceEditParams wEdit)
in updateState (ReqApplyWorkspaceEdit req)
let wEdit = WorkspaceEdit (Just (HashMap.singleton (doc ^. uri) edits)) Nothing
req = RequestMessage "" (IdInt 0) WorkspaceApplyEdit (ApplyWorkspaceEditParams wEdit)
in updateState (ReqApplyWorkspaceEdit req)
+
+-- | Returns the code lenses for the specified document.
+getCodeLenses :: TextDocumentIdentifier -> Session [CodeLens]
+getCodeLenses tId = do
+ rsp <- request TextDocumentCodeLens (CodeLensParams tId) :: Session CodeLensResponse
+ case getResponseResult rsp of
+ List res -> pure res