From: Luke Lau Date: Tue, 17 Jul 2018 12:35:54 +0000 (+0100) Subject: Add getHighlights X-Git-Url: http://git.lukelau.me/?p=opengl.git;a=commitdiff_plain;h=52fa38c9702407f58aeea09c6bded442d672d7fd Add getHighlights --- diff --git a/src/Language/Haskell/LSP/Test.hs b/src/Language/Haskell/LSP/Test.hs index 403c0e1..e47109e 100644 --- a/src/Language/Haskell/LSP/Test.hs +++ b/src/Language/Haskell/LSP/Test.hs @@ -71,6 +71,8 @@ module Language.Haskell.LSP.Test , rename -- ** Hover , getHover + -- ** Highlights + , getHighlights -- ** Edits , applyEdit ) where @@ -463,9 +465,14 @@ rename doc pos newName = do -- ^ Returns the hover information at the specified position. getHover :: TextDocumentIdentifier -> Position -> Session (Maybe Hover) -getHover doc pos = do +getHover doc pos = let params = TextDocumentPositionParams doc pos - getResponseResult <$> sendRequest TextDocumentHover params + in getResponseResult <$> sendRequest TextDocumentHover params + +getHighlights :: TextDocumentIdentifier -> Position -> Session [DocumentHighlight] +getHighlights doc pos = + let params = TextDocumentPositionParams doc pos + in getResponseResult <$> sendRequest TextDocumentDocumentHighlight params -- | Checks the response for errors and throws an exception if needed. -- Returns the result if successful. diff --git a/test/Test.hs b/test/Test.hs index e342440..a17be20 100644 --- a/test/Test.hs +++ b/test/Test.hs @@ -267,6 +267,12 @@ main = hspec $ do skipManyTill loggingNotification $ count 2 noDiagnostics hover <- getHover doc (Position 45 9) -- putStrLn liftIO $ hover `shouldSatisfy` isJust + describe "getHighlights" $ + it "works" $ runSession "hie --lsp" "test/data/renamePass" $ do + doc <- openDoc "Desktop/simple.hs" "haskell" + skipManyTill loggingNotification $ count 2 noDiagnostics + highlights <- getHighlights doc (Position 27 4) -- addItem + liftIO $ length highlights `shouldBe` 4 mkRange sl sc el ec = Range (Position sl sc) (Position el ec)