Skip to content

Add signature help request to lsp-test #621

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lsp-test/src/Language/LSP/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ module Language.LSP.Test (
-- ** Hover
getHover,

-- ** Signature Help
getSignatureHelp,

-- ** Highlights
getHighlights,

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

-- | Returns the signature help at the specified position.
getSignatureHelp :: TextDocumentIdentifier -> Position -> Session (Maybe SignatureHelp)
getSignatureHelp doc pos =
let params = SignatureHelpParams doc pos Nothing Nothing
in nullToMaybe . getResponseResult <$> request SMethod_TextDocumentSignatureHelp params

-- | Returns the highlighted occurrences of the term at the specified position
getHighlights :: TextDocumentIdentifier -> Position -> Session [DocumentHighlight]
getHighlights doc pos =
Expand Down
6 changes: 6 additions & 0 deletions lsp-test/test/DummyServer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ handlers =
Right $
InL $
Hover (InL (MarkupContent MarkupKind_PlainText "hello")) Nothing
, requestHandler SMethod_TextDocumentSignatureHelp $
\_req responder ->
responder $
Right $
InL $
SignatureHelp [] Nothing Nothing
, requestHandler SMethod_TextDocumentDocumentSymbol $
\_req responder ->
responder $
Expand Down
6 changes: 6 additions & 0 deletions lsp-test/test/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,12 @@ main = hspec $ around withDummyServer $ do
hover <- getHover doc (Position 45 9)
liftIO $ hover `shouldSatisfy` isJust

describe "getSignatureHelp" $
it "works" $ \(hin, hout) -> runSessionWithHandles hin hout def fullLatestClientCaps "." $ do
doc <- openDoc "test/data/renamePass/Desktop/simple.hs" "haskell"
signatureHelp <- getSignatureHelp doc (Position 22 32)
liftIO $ signatureHelp `shouldSatisfy` isJust

-- describe "getHighlights" $
-- it "works" $ \(hin, hout) -> runSessionWithHandles hin hout def fullLatestClientCaps "." $ do
-- doc <- openDoc "test/data/renamePass/Desktop/simple.hs" "haskell"
Expand Down
Loading