Skip to content

Commit c839c03

Browse files
committed
Add signature help request to lsp-test
1 parent f893e8d commit c839c03

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

lsp-test/src/Language/LSP/Test.hs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ module Language.LSP.Test (
110110
-- ** Hover
111111
getHover,
112112

113+
-- ** Signature Help
114+
getSignatureHelp,
115+
113116
-- ** Highlights
114117
getHighlights,
115118

@@ -933,6 +936,12 @@ getHover doc pos =
933936
let params = HoverParams doc pos Nothing
934937
in nullToMaybe . getResponseResult <$> request SMethod_TextDocumentHover params
935938

939+
-- | Returns the signature help at the specified position.
940+
getSignatureHelp :: TextDocumentIdentifier -> Position -> Session (Maybe SignatureHelp)
941+
getSignatureHelp doc pos =
942+
let params = SignatureHelpParams doc pos Nothing Nothing
943+
in nullToMaybe . getResponseResult <$> request SMethod_TextDocumentSignatureHelp params
944+
936945
-- | Returns the highlighted occurrences of the term at the specified position
937946
getHighlights :: TextDocumentIdentifier -> Position -> Session [DocumentHighlight]
938947
getHighlights doc pos =

lsp-test/test/DummyServer.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ handlers =
7272
Right $
7373
InL $
7474
Hover (InL (MarkupContent MarkupKind_PlainText "hello")) Nothing
75+
, requestHandler SMethod_TextDocumentSignatureHelp $
76+
\_req responder ->
77+
responder $
78+
Right $
79+
InL $
80+
SignatureHelp [] Nothing Nothing
7581
, requestHandler SMethod_TextDocumentDocumentSymbol $
7682
\_req responder ->
7783
responder $

lsp-test/test/Test.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,12 @@ main = hspec $ around withDummyServer $ do
307307
hover <- getHover doc (Position 45 9)
308308
liftIO $ hover `shouldSatisfy` isJust
309309

310+
describe "getSignatureHelp" $
311+
it "works" $ \(hin, hout) -> runSessionWithHandles hin hout def fullLatestClientCaps "." $ do
312+
doc <- openDoc "test/data/renamePass/Desktop/simple.hs" "haskell"
313+
signatureHelp <- getSignatureHelp doc (Position 22 32)
314+
liftIO $ signatureHelp `shouldSatisfy` isJust
315+
310316
-- describe "getHighlights" $
311317
-- it "works" $ \(hin, hout) -> runSessionWithHandles hin hout def fullLatestClientCaps "." $ do
312318
-- doc <- openDoc "test/data/renamePass/Desktop/simple.hs" "haskell"

0 commit comments

Comments
 (0)