From c839c03691054c1ae29d78ff81c8906a1534c6b5 Mon Sep 17 00:00:00 2001 From: Lin Jian Date: Fri, 22 Aug 2025 04:33:03 +0800 Subject: [PATCH] Add signature help request to lsp-test --- lsp-test/src/Language/LSP/Test.hs | 9 +++++++++ lsp-test/test/DummyServer.hs | 6 ++++++ lsp-test/test/Test.hs | 6 ++++++ 3 files changed, 21 insertions(+) diff --git a/lsp-test/src/Language/LSP/Test.hs b/lsp-test/src/Language/LSP/Test.hs index 41466edd..b4d7ec92 100644 --- a/lsp-test/src/Language/LSP/Test.hs +++ b/lsp-test/src/Language/LSP/Test.hs @@ -110,6 +110,9 @@ module Language.LSP.Test ( -- ** Hover getHover, + -- ** Signature Help + getSignatureHelp, + -- ** Highlights getHighlights, @@ -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 = diff --git a/lsp-test/test/DummyServer.hs b/lsp-test/test/DummyServer.hs index bd36551e..c6f3ab47 100644 --- a/lsp-test/test/DummyServer.hs +++ b/lsp-test/test/DummyServer.hs @@ -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 $ diff --git a/lsp-test/test/Test.hs b/lsp-test/test/Test.hs index 00b51212..e953a77e 100644 --- a/lsp-test/test/Test.hs +++ b/lsp-test/test/Test.hs @@ -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"