File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -145,6 +145,9 @@ module Language.LSP.Test (
145145 getWorkspaceSymbols ,
146146 resolveWorkspaceSymbols ,
147147
148+ -- ** Document Links
149+ getDocumentLinks ,
150+
148151 -- ** Capabilities
149152 getRegisteredCapabilities ,
150153) where
@@ -1063,6 +1066,11 @@ resolveWorkspaceSymbols item = do
10631066 rsp <- request SMethod_WorkspaceSymbolResolve item
10641067 pure $ getResponseResult rsp
10651068
1069+ getDocumentLinks :: TextDocumentIdentifier -> Session (Maybe [DocumentLink ])
1070+ getDocumentLinks doc =
1071+ let params = DocumentLinkParams Nothing Nothing doc
1072+ in nullToMaybe . getResponseResult <$> request SMethod_TextDocumentDocumentLink params
1073+
10661074{- | Returns a list of capabilities that the server has requested to /dynamically/
10671075 register during the 'Session'.
10681076
Original file line number Diff line number Diff line change @@ -284,4 +284,14 @@ handlers =
284284 Success start = fromJSON data_
285285 ih = InlayHint {_data_ = Nothing , _tooltip = Just $ InL $ " start at " <> T. pack (show start), .. }
286286 resp $ Right ih
287+ , requestHandler SMethod_TextDocumentDocumentLink $ \ _req resp -> do
288+ resp $
289+ Right $
290+ InL
291+ [ DocumentLink
292+ (mkRange 0 0 0 5 )
293+ (Just (Uri " file://..." ))
294+ Nothing
295+ Nothing
296+ ]
287297 ]
Original file line number Diff line number Diff line change @@ -470,3 +470,9 @@ main = hspec $ around withDummyServer $ do
470470 doc <- openDoc " test/data/renamePass/Desktop/simple.hs" " haskell"
471471 inlayHints <- getAndResolveInlayHints doc (Range (Position 1 2 ) (Position 3 4 ))
472472 liftIO $ head inlayHints ^. L. tooltip `shouldBe` Just (InL $ " start at " <> T. pack (show (Position 1 2 )))
473+
474+ describe " getDocumentLinks" $
475+ it " works" $ \ (hin, hout) -> runSessionWithHandles hin hout def fullLatestClientCaps " ." $ do
476+ let doc = TextDocumentIdentifier (Uri " " )
477+ documentLinks <- getDocumentLinks doc
478+ liftIO $ documentLinks `shouldSatisfy` isJust
You can’t perform that action at this time.
0 commit comments