From 52fa38c9702407f58aeea09c6bded442d672d7fd Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Tue, 17 Jul 2018 13:35:54 +0100 Subject: [PATCH] Add getHighlights --- src/Language/Haskell/LSP/Test.hs | 11 +++++++++-- test/Test.hs | 6 ++++++ 2 files changed, 15 insertions(+), 2 deletions(-) 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) -- 2.30.2