Update haskell-lsp to 0.17

Together with haskell-lsp-types and lsp-test

This now supports LSP spec 3.15
This commit is contained in:
Alan Zimmerman 2019-10-20 21:53:27 +01:00
parent 414bbee3b6
commit 60c0df26d1
18 changed files with 83 additions and 70 deletions

View File

@ -71,8 +71,8 @@ library
, gitrev >= 1.1
, haddock-api
, haddock-library
, haskell-lsp == 0.16.*
, haskell-lsp-types == 0.16.*
, haskell-lsp == 0.17.*
, haskell-lsp-types == 0.17.*
, haskell-src-exts
, hie-plugin-api
, hoogle >= 5.0.13
@ -199,7 +199,7 @@ test-suite unit-test
, free
, ghc
, haskell-ide-engine
, haskell-lsp-types == 0.16.*
, haskell-lsp-types == 0.17.*
, hie-test-utils
, hie-plugin-api
, hoogle > 5.0.11
@ -285,10 +285,10 @@ test-suite func-test
, data-default
, directory
, filepath
, lsp-test >= 0.6.0.0
, lsp-test >= 0.8.0.0
, haskell-ide-engine
, haskell-lsp-types == 0.16.*
, haskell-lsp == 0.16.*
, haskell-lsp-types == 0.17.*
, haskell-lsp == 0.17.*
, hie-test-utils
, hie-plugin-api
, hspec

View File

@ -45,7 +45,7 @@ library
, ghc
, ghc-mod-core >= 5.9.0.0
, ghc-project-types >= 5.9.0.0
, haskell-lsp == 0.16.*
, haskell-lsp == 0.17.*
, hslogger
, monad-control
, mtl

View File

@ -20,14 +20,14 @@ extra-deps:
- ghc-exactprint-0.5.8.2
- haddock-api-2.18.1
- haddock-library-1.4.4
- haskell-lsp-0.16.0.0
- haskell-lsp-types-0.16.0.0
- haskell-lsp-0.17.0.0
- haskell-lsp-types-0.17.0.0
- haskell-src-exts-1.21.0
- haskell-src-exts-util-0.2.5
- hlint-2.1.17 # last hlint supporting GHC 8.2
- hoogle-5.0.17.9
- hsimport-0.8.8
- lsp-test-0.7.0.0
- lsp-test-0.8.0.0
- monad-dijkstra-0.1.1.2
- pretty-show-1.8.2
- rope-utf16-splay-0.3.1.0

View File

@ -19,14 +19,14 @@ extra-deps:
- ghc-lib-parser-8.8.0.20190723
- haddock-api-2.20.0
- haddock-library-1.6.0
- haskell-lsp-0.16.0.0
- haskell-lsp-types-0.16.0.0
- haskell-lsp-0.17.0.0
- haskell-lsp-types-0.17.0.0
- haskell-src-exts-1.21.0
- haskell-src-exts-util-0.2.5
- hlint-2.2.2
- hoogle-5.0.17.9
- hsimport-0.10.0
- lsp-test-0.7.0.0
- lsp-test-0.8.0.0
- monad-dijkstra-0.1.1.2
- pretty-show-1.8.2
- rope-utf16-splay-0.3.1.0

View File

@ -19,14 +19,14 @@ extra-deps:
- ghc-lib-parser-8.8.0.20190723
- haddock-api-2.20.0
- haddock-library-1.6.0
- haskell-lsp-0.16.0.0
- haskell-lsp-types-0.16.0.0
- haskell-lsp-0.17.0.0
- haskell-lsp-types-0.17.0.0
- haskell-src-exts-1.21.0
- haskell-src-exts-util-0.2.5
- hlint-2.2.2
- hoogle-5.0.17.9
- hsimport-0.10.0
- lsp-test-0.7.0.0
- lsp-test-0.8.0.0
- monad-dijkstra-0.1.1.2
- pretty-show-1.8.2
- rope-utf16-splay-0.3.1.0

View File

@ -18,14 +18,14 @@ extra-deps:
- ghc-lib-parser-8.8.0.20190723
- haddock-api-2.20.0
- haddock-library-1.6.0
- haskell-lsp-0.16.0.0
- haskell-lsp-types-0.16.0.0
- haskell-lsp-0.17.0.0
- haskell-lsp-types-0.17.0.0
- haskell-src-exts-1.21.0
- haskell-src-exts-util-0.2.5
- hlint-2.2.2
- hoogle-5.0.17.9
- hsimport-0.10.0
- lsp-test-0.7.0.0
- lsp-test-0.8.0.0
- monad-dijkstra-0.1.1.2
- optparse-simple-0.1.0
- pretty-show-1.9.5

View File

@ -21,14 +21,14 @@ extra-deps:
- floskell-0.10.0
- ghc-lib-parser-8.8.0.20190723
- haddock-api-2.21.0
- haskell-lsp-0.16.0.0
- haskell-lsp-types-0.16.0.0
- haskell-lsp-0.17.0.0
- haskell-lsp-types-0.17.0.0
- haskell-src-exts-1.21.0
- haskell-src-exts-util-0.2.5
- hlint-2.2.2
- hoogle-5.0.17.9
- hsimport-0.10.0
- lsp-test-0.7.0.0
- lsp-test-0.8.0.0
- monad-dijkstra-0.1.1.2
- monad-memo-0.4.1
- monoid-subclasses-0.4.6.1

View File

@ -17,14 +17,14 @@ extra-deps:
- floskell-0.10.0
- ghc-lib-parser-8.8.0.20190723
- haddock-api-2.21.0
- haskell-lsp-0.16.0.0
- haskell-lsp-types-0.16.0.0
- haskell-lsp-0.17.0.0
- haskell-lsp-types-0.17.0.0
- haskell-src-exts-1.21.0
- haskell-src-exts-util-0.2.5
- hlint-2.2.2
- hoogle-5.0.17.9
- hsimport-0.10.0
- lsp-test-0.7.0.0
- lsp-test-0.8.0.0
- monad-dijkstra-0.1.1.2
- monad-memo-0.4.1
- multistate-0.8.0.1

View File

@ -17,14 +17,14 @@ extra-deps:
- floskell-0.10.0
- ghc-lib-parser-8.8.0.20190723
- haddock-api-2.21.0
- haskell-lsp-0.16.0.0
- haskell-lsp-types-0.16.0.0
- haskell-lsp-0.17.0.0
- haskell-lsp-types-0.17.0.0
- haskell-src-exts-1.21.0
- haskell-src-exts-util-0.2.5
- hlint-2.2.2
- hoogle-5.0.17.9
- hsimport-0.10.0
- lsp-test-0.7.0.0
- lsp-test-0.8.0.0
- monad-dijkstra-0.1.1.2
- monad-memo-0.4.1
- multistate-0.8.0.1

View File

@ -17,13 +17,13 @@ extra-deps:
- floskell-0.10.0
- ghc-lib-parser-8.8.0.20190723
- haddock-api-2.22.0
- haskell-lsp-0.16.0.0
- haskell-lsp-types-0.16.0.0
- haskell-lsp-0.17.0.0
- haskell-lsp-types-0.17.0.0
- haskell-src-exts-1.21.0
- hlint-2.2.2
- hoogle-5.0.17.9
- hsimport-0.10.0
- lsp-test-0.7.0.0
- lsp-test-0.8.0.0
- monad-dijkstra-0.1.1.2@rev:1
- monad-memo-0.4.1
- multistate-0.8.0.1

View File

@ -17,13 +17,13 @@ extra-deps:
- floskell-0.10.0
- ghc-lib-parser-8.8.0.20190723
- haddock-api-2.22.0
- haskell-lsp-0.16.0.0
- haskell-lsp-types-0.16.0.0
- haskell-lsp-0.17.0.0
- haskell-lsp-types-0.17.0.0
- haskell-src-exts-1.21.0
- hlint-2.2.2
- hsimport-0.10.0
- hoogle-5.0.17.9
- lsp-test-0.7.0.0
- lsp-test-0.8.0.0
- monad-dijkstra-0.1.1.2@rev:1
- monad-memo-0.4.1
- multistate-0.8.0.1

View File

@ -18,11 +18,11 @@ extra-deps:
- floskell-0.10.1
- ghc-lib-parser-8.8.0.20190723
- haddock-api-2.22.0
- haskell-lsp-0.16.0.0
- haskell-lsp-types-0.16.0.0
- haskell-lsp-0.17.0.0
- haskell-lsp-types-0.17.0.0
- hlint-2.2.2
- hsimport-0.10.0
- lsp-test-0.7.0.0
- lsp-test-0.8.0.0
- monad-dijkstra-0.1.1.2@rev:1
- syz-0.2.0.0
- temporary-1.2.1.1

View File

@ -24,7 +24,7 @@ spec = describe "commands" $ do
it "get de-prefixed" $ runSession hieCommand fullCaps "test/testdata/" $ do
ResponseMessage _ _ _ (Just err) <- request
WorkspaceExecuteCommand
(ExecuteCommandParams "1234:package:add" (Just (List []))) :: Session ExecuteCommandResponse
(ExecuteCommandParams "1234:package:add" (Just (List [])) Nothing) :: Session ExecuteCommandResponse
let ResponseError _ msg _ = err
-- We expect an error message about the dud arguments, but should pickup "add" and "package"
liftIO $ msg `shouldSatisfy` T.isInfixOf "while parsing args for add in plugin package"

View File

@ -25,18 +25,18 @@ spec = do
it "do not affect hover requests" $ runSession hieCommand fullCaps "test/testdata" $ do
doc <- openDoc "FuncTest.hs" "haskell"
id1 <- sendRequest TextDocumentHover (TextDocumentPositionParams doc (Position 4 2))
id1 <- sendRequest TextDocumentHover (TextDocumentPositionParams doc (Position 4 2) Nothing)
skipMany anyNotification
hoverRsp <- message :: Session HoverResponse
liftIO $ hoverRsp ^? result . _Just . _Just . contents `shouldBe` Nothing
liftIO $ hoverRsp ^. LSP.id `shouldBe` responseId id1
id2 <- sendRequest TextDocumentDocumentSymbol (DocumentSymbolParams doc)
id2 <- sendRequest TextDocumentDocumentSymbol (DocumentSymbolParams doc Nothing)
symbolsRsp <- skipManyTill anyNotification message :: Session DocumentSymbolsResponse
liftIO $ symbolsRsp ^. LSP.id `shouldBe` responseId id2
id3 <- sendRequest TextDocumentHover (TextDocumentPositionParams doc (Position 4 2))
id3 <- sendRequest TextDocumentHover (TextDocumentPositionParams doc (Position 4 2) Nothing)
hoverRsp2 <- skipManyTill anyNotification message :: Session HoverResponse
liftIO $ hoverRsp2 ^. LSP.id `shouldBe` responseId id3
@ -44,8 +44,8 @@ spec = do
liftIO $ contents2 `shouldNotSatisfy` null
-- Now that we have cache the following request should be instant
let highlightParams = TextDocumentPositionParams doc (Position 7 0)
highlightRsp <- request TextDocumentDocumentHighlight highlightParams :: Session DocumentHighlightsResponse
let highlightParams = TextDocumentPositionParams doc (Position 7 0) Nothing
highlightRsp <- request TextDocumentDocumentHighlight highlightParams
let (Just (List locations)) = highlightRsp ^. result
liftIO $ locations `shouldBe` [ DocumentHighlight
{ _range = Range
@ -126,7 +126,7 @@ spec = do
let args' = H.fromList [("pos", toJSON (Position 7 0)), ("file", toJSON testUri)]
args = List [Object args']
executeRsp <- request WorkspaceExecuteCommand (ExecuteCommandParams "hare:demote" (Just args))
executeRsp <- request WorkspaceExecuteCommand (ExecuteCommandParams "hare:demote" (Just args) Nothing)
liftIO $ executeRsp ^. result `shouldBe` Just (Object H.empty)
editReq <- message :: Session ApplyWorkspaceEditRequest

View File

@ -30,7 +30,7 @@ spec = do
doc <- openDoc "Format.hs" "haskell"
formatRange doc (FormattingOptions 5 True) (Range (Position 4 0) (Position 7 19))
documentContents doc >>= liftIO . (`shouldBe` formattedRangeTabSize5)
describe "formatting provider" $ do
let formatLspConfig provider =
object [ "languageServerHaskell" .= object ["formattingProvider" .= (provider :: Value)] ]
@ -42,7 +42,7 @@ spec = do
formatDoc doc (FormattingOptions 2 True)
documentContents doc >>= liftIO . (`shouldBe` orig)
formatRange doc (FormattingOptions 2 True) (Range (Position 1 0) (Position 3 10))
documentContents doc >>= liftIO . (`shouldBe` orig)
@ -60,18 +60,18 @@ spec = do
sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (formatLspConfig "brittany"))
formatDoc doc (FormattingOptions 2 True)
documentContents doc >>= liftIO . (`shouldBe` formattedBrittanyPostFloskell)
describe "brittany" $ do
it "formats a document with LF endings" $ runSession hieCommand fullCaps "test/testdata" $ do
doc <- openDoc "BrittanyLF.hs" "haskell"
let opts = DocumentFormattingParams doc (FormattingOptions 4 True)
let opts = DocumentFormattingParams doc (FormattingOptions 4 True) Nothing
ResponseMessage _ _ (Just edits) _ <- request TextDocumentFormatting opts
liftIO $ edits `shouldBe` [TextEdit (Range (Position 0 0) (Position 3 0))
"foo :: Int -> String -> IO ()\nfoo x y = do\n print x\n return 42\n"]
it "formats a document with CRLF endings" $ runSession hieCommand fullCaps "test/testdata" $ do
doc <- openDoc "BrittanyCRLF.hs" "haskell"
let opts = DocumentFormattingParams doc (FormattingOptions 4 True)
let opts = DocumentFormattingParams doc (FormattingOptions 4 True) Nothing
ResponseMessage _ _ (Just edits) _ <- request TextDocumentFormatting opts
liftIO $ edits `shouldBe` [TextEdit (Range (Position 0 0) (Position 3 0))
"foo :: Int -> String -> IO ()\nfoo x y = do\n print x\n return 42\n"]
@ -79,7 +79,7 @@ spec = do
it "formats a range with LF endings" $ runSession hieCommand fullCaps "test/testdata" $ do
doc <- openDoc "BrittanyLF.hs" "haskell"
let range = Range (Position 1 0) (Position 2 22)
opts = DocumentRangeFormattingParams doc range (FormattingOptions 4 True)
opts = DocumentRangeFormattingParams doc range (FormattingOptions 4 True) Nothing
ResponseMessage _ _ (Just edits) _ <- request TextDocumentRangeFormatting opts
liftIO $ edits `shouldBe` [TextEdit (Range (Position 1 0) (Position 3 0))
"foo x y = do\n print x\n return 42\n"]
@ -87,7 +87,7 @@ spec = do
it "formats a range with CRLF endings" $ runSession hieCommand fullCaps "test/testdata" $ do
doc <- openDoc "BrittanyCRLF.hs" "haskell"
let range = Range (Position 1 0) (Position 2 22)
opts = DocumentRangeFormattingParams doc range (FormattingOptions 4 True)
opts = DocumentRangeFormattingParams doc range (FormattingOptions 4 True) Nothing
ResponseMessage _ _ (Just edits) _ <- request TextDocumentRangeFormatting opts
liftIO $ edits `shouldBe` [TextEdit (Range (Position 1 0) (Position 3 0))
"foo x y = do\n print x\n return 42\n"]

View File

@ -503,9 +503,9 @@ spec = describe "code actions" $ do
doc <- openDoc "CodeActionOnly.hs" "haskell"
_ <- count 2 waitForDiagnostics -- need to wait for both hlint and ghcmod
diags <- getCurrentDiagnostics doc
let params = CodeActionParams doc (Range (Position 2 10) (Position 4 0)) caContext
let params = CodeActionParams doc (Range (Position 2 10) (Position 4 0)) caContext Nothing
caContext = CodeActionContext (List diags) (Just (List [CodeActionRefactorInline]))
ResponseMessage _ _ (Just (List res)) _ <- request TextDocumentCodeAction params :: Session CodeActionResponse
ResponseMessage _ _ (Just (List res)) _ <- request TextDocumentCodeAction params
let cas = map fromAction res
kinds = map (^. L.kind) cas
liftIO $ do

View File

@ -16,7 +16,7 @@ import Test.Hspec
import TestUtils
spec :: Spec
spec = describe "window/progress" $ do
spec = describe "window/workDoneProgress" $ do
it "sends indefinite progress notifications" $
-- Testing that ghc-mod sends progress notifications
runSession hieCommand progressCaps "test/testdata" $ do
@ -27,13 +27,17 @@ spec = describe "window/progress" $ do
-- Initial hlint notifications
_ <- publishDiagnosticsNotification
startNotification <- message :: Session ProgressStartNotification
createRequest <- message :: Session WorkDoneProgressCreateRequest
liftIO $ do
startNotification ^. L.params . L.title `shouldBe` "Typechecking ApplyRefact2.hs"
startNotification ^. L.params . L.id `shouldBe` "0"
createRequest ^. L.params `shouldBe` WorkDoneProgressCreateParams (ProgressNumericToken 0)
doneNotification <- skipManyTill loggingNotification (message :: Session ProgressDoneNotification)
liftIO $ doneNotification ^. L.params . L.id `shouldBe` "0"
startNotification <- message :: Session WorkDoneProgressBeginNotification
liftIO $ do
startNotification ^. L.params . L.value . L.title `shouldBe` "Typechecking ApplyRefact2.hs"
startNotification ^. L.params . L.token `shouldBe` (ProgressNumericToken 0)
doneNotification <- skipManyTill loggingNotification (message :: Session WorkDoneProgressEndNotification)
liftIO $ doneNotification ^. L.params . L.token `shouldBe` (ProgressNumericToken 0)
-- the ghc-mod diagnostics
_ <- skipManyTill loggingNotification publishDiagnosticsNotification
@ -44,13 +48,17 @@ spec = describe "window/progress" $ do
-- hlint notifications
_ <- skipManyTill loggingNotification publishDiagnosticsNotification
startNotification' <- skipManyTill loggingNotification (message :: Session ProgressStartNotification)
createRequest' <- skipManyTill loggingNotification (message :: Session WorkDoneProgressCreateRequest)
liftIO $ do
startNotification' ^. L.params . L.title `shouldBe` "Typechecking ApplyRefact2.hs"
startNotification' ^. L.params . L.id `shouldBe` "1"
createRequest' ^. L.params `shouldBe` WorkDoneProgressCreateParams (ProgressNumericToken 1)
doneNotification' <- skipManyTill loggingNotification (message :: Session ProgressDoneNotification)
liftIO $ doneNotification' ^. L.params . L.id `shouldBe` "1"
startNotification' <- message :: Session WorkDoneProgressBeginNotification
liftIO $ do
startNotification' ^. L.params . L.value . L.title `shouldBe` "Typechecking ApplyRefact2.hs"
startNotification' ^. L.params . L.token `shouldBe` (ProgressNumericToken 1)
doneNotification' <- skipManyTill loggingNotification (message :: Session WorkDoneProgressEndNotification)
liftIO $ doneNotification' ^. L.params . L.token `shouldBe` (ProgressNumericToken 1)
-- the ghc-mod diagnostics
const () <$> skipManyTill loggingNotification publishDiagnosticsNotification
@ -65,8 +73,9 @@ spec = describe "window/progress" $ do
-- Initial hlint notifications
_ <- skipManyTill loggingNotification publishDiagnosticsNotification
_ <- message :: Session ProgressStartNotification
_ <- message :: Session ProgressDoneNotification
_ <- message :: Session WorkDoneProgressCreateRequest
_ <- message :: Session WorkDoneProgressBeginNotification
_ <- message :: Session WorkDoneProgressEndNotification
-- the ghc-mod diagnostics
_ <- skipManyTill loggingNotification publishDiagnosticsNotification
@ -81,11 +90,11 @@ spec = describe "window/progress" $ do
-- hlint notifications
_ <- skipManyTill loggingNotification publishDiagnosticsNotification
let startPred (NotProgressStart m) =
m ^. L.params . L.title == "Running Liquid Haskell on Evens.hs"
let startPred (NotWorkDoneProgressBegin m) =
m ^. L.params . L.value . L.title == "Running Liquid Haskell on Evens.hs"
startPred _ = False
let donePred (NotProgressDone _) = True
let donePred (NotWorkDoneProgressEnd _) = True
donePred _ = False
_ <- skipManyTill anyMessage $ between (satisfy startPred) (satisfy donePred) $

View File

@ -12,6 +12,7 @@ import Haskell.Ide.Engine.Plugin.GhcMod
import Haskell.Ide.Engine.Plugin.HaRe
import Haskell.Ide.Engine.Support.HieExtras
import Haskell.Ide.Engine.Config
import Language.Haskell.LSP.Types
import Data.Aeson
import Test.Hspec
@ -87,7 +88,10 @@ instance Arbitrary TextDocumentIdentifier where
arbitrary = TextDocumentIdentifier <$> arbitrary
instance Arbitrary TextDocumentPositionParams where
arbitrary = TextDocumentPositionParams <$> arbitrary <*> arbitrary
arbitrary = TextDocumentPositionParams <$> arbitrary <*> arbitrary <*> arbitrary
instance Arbitrary ProgressToken where
arbitrary = oneof [ProgressTextToken <$> arbitrary, ProgressNumericToken <$> arbitrary]
instance Arbitrary IdeErrorCode where
arbitrary = arbitraryBoundedEnum