Skip to content
Merged
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
8 changes: 8 additions & 0 deletions lsp-test/src/Language/LSP/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ module Language.LSP.Test (
getWorkspaceSymbols,
resolveWorkspaceSymbols,

-- ** Document Links
getDocumentLinks,

-- ** Capabilities
getRegisteredCapabilities,
) where
Expand Down Expand Up @@ -1063,6 +1066,11 @@ resolveWorkspaceSymbols item = do
rsp <- request SMethod_WorkspaceSymbolResolve item
pure $ getResponseResult rsp

getDocumentLinks :: TextDocumentIdentifier -> Session (Maybe [DocumentLink])
getDocumentLinks doc =
let params = DocumentLinkParams Nothing Nothing doc
in nullToMaybe . getResponseResult <$> request SMethod_TextDocumentDocumentLink params

{- | Returns a list of capabilities that the server has requested to /dynamically/
register during the 'Session'.

Expand Down
10 changes: 10 additions & 0 deletions lsp-test/test/DummyServer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -284,4 +284,14 @@ handlers =
Success start = fromJSON data_
ih = InlayHint{_data_ = Nothing, _tooltip = Just $ InL $ "start at " <> T.pack (show start), ..}
resp $ Right ih
, requestHandler SMethod_TextDocumentDocumentLink $ \_req resp -> do
resp $
Right $
InL
[ DocumentLink
(mkRange 0 0 0 5)
(Just (Uri "file://..."))
Nothing
Nothing
]
]
6 changes: 6 additions & 0 deletions lsp-test/test/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -470,3 +470,9 @@ main = hspec $ around withDummyServer $ do
doc <- openDoc "test/data/renamePass/Desktop/simple.hs" "haskell"
inlayHints <- getAndResolveInlayHints doc (Range (Position 1 2) (Position 3 4))
liftIO $ head inlayHints ^. L.tooltip `shouldBe` Just (InL $ "start at " <> T.pack (show (Position 1 2)))

describe "getDocumentLinks" $
it "works" $ \(hin, hout) -> runSessionWithHandles hin hout def fullLatestClientCaps "." $ do
let doc = TextDocumentIdentifier (Uri "")
documentLinks <- getDocumentLinks doc
liftIO $ documentLinks `shouldSatisfy` isJust
Loading