From e7a888628391e9b245c61e1a5a01c4965ab0396f Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Sun, 28 Apr 2019 20:15:27 +0100 Subject: [PATCH 01/16] Update haskell-lsp bounds --- lsp-test.cabal | 6 +++--- src/Language/Haskell/LSP/Test/Decoding.hs | 1 - src/Language/Haskell/LSP/Test/Messages.hs | 2 +- stack.yaml | 4 ++-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lsp-test.cabal b/lsp-test.cabal index f5822d9..947aadd 100644 --- a/lsp-test.cabal +++ b/lsp-test.cabal @@ -1,5 +1,5 @@ name: lsp-test -version: 0.5.1.3 +version: 0.5.1.4 synopsis: Functional test framework for LSP servers. description: A test framework for writing tests against @@ -36,7 +36,7 @@ library , parser-combinators:Control.Applicative.Combinators default-language: Haskell2010 build-depends: base >= 4.10 && < 5 - , haskell-lsp >= 0.10 && < 0.11 + , haskell-lsp == 0.11.* , aeson , aeson-pretty , ansi-terminal @@ -78,7 +78,7 @@ test-suite tests build-depends: base >= 4.10 && < 5 , hspec , lens - , haskell-lsp >= 0.10 && < 0.11 + , haskell-lsp >= 0.10 && < 0.12 , lsp-test , data-default , aeson diff --git a/src/Language/Haskell/LSP/Test/Decoding.hs b/src/Language/Haskell/LSP/Test/Decoding.hs index 43810bb..337dee3 100644 --- a/src/Language/Haskell/LSP/Test/Decoding.hs +++ b/src/Language/Haskell/LSP/Test/Decoding.hs @@ -134,7 +134,6 @@ decodeFromServerMsg reqMap bytes = WindowProgressStart -> NotProgressStart $ fromJust $ decode bytes WindowProgressReport -> NotProgressReport $ fromJust $ decode bytes WindowProgressDone -> NotProgressDone $ fromJust $ decode bytes - WindowProgressCancel -> NotProgressCancel $ fromJust $ decode bytes TelemetryEvent -> NotTelemetry $ fromJust $ decode bytes WindowShowMessageRequest -> ReqShowMessage $ fromJust $ decode bytes ClientRegisterCapability -> ReqRegisterCapability $ fromJust $ decode bytes diff --git a/src/Language/Haskell/LSP/Test/Messages.hs b/src/Language/Haskell/LSP/Test/Messages.hs index 258f91b..1a3805f 100644 --- a/src/Language/Haskell/LSP/Test/Messages.hs +++ b/src/Language/Haskell/LSP/Test/Messages.hs @@ -93,7 +93,6 @@ handleServerMessage request response notification msg = case msg of (NotProgressStart m) -> notification m (NotProgressReport m) -> notification m (NotProgressDone m) -> notification m - (NotProgressCancel m) -> notification m (NotTelemetry m) -> notification m (NotCancelRequestFromServer m) -> notification m @@ -145,4 +144,5 @@ handleClientMessage request response notification msg = case msg of (NotDidSaveTextDocument m) -> notification m (NotDidChangeWatchedFiles m) -> notification m (NotDidChangeWorkspaceFolders m) -> notification m + (NotProgressCancel m) -> notification m (UnknownFromClientMessage m) -> error $ "Unknown message sent from client: " ++ show m diff --git a/stack.yaml b/stack.yaml index 57f3658..be001f8 100644 --- a/stack.yaml +++ b/stack.yaml @@ -3,5 +3,5 @@ packages: - . extra-deps: - - haskell-lsp-0.10.0.0 - - haskell-lsp-types-0.10.0.0 + - haskell-lsp-0.11.0.0 + - haskell-lsp-types-0.11.0.0 -- 2.30.2 From 14c48f727d1c049f33cd9b3e1e485a6ae1d6f574 Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Sun, 28 Apr 2019 20:27:46 +0100 Subject: [PATCH 02/16] Update bounds for haskell-lsp --- lsp-test.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lsp-test.cabal b/lsp-test.cabal index 947aadd..dd90f8b 100644 --- a/lsp-test.cabal +++ b/lsp-test.cabal @@ -78,7 +78,7 @@ test-suite tests build-depends: base >= 4.10 && < 5 , hspec , lens - , haskell-lsp >= 0.10 && < 0.12 + , haskell-lsp == 0.11.* , lsp-test , data-default , aeson -- 2.30.2 From ae9d99b56df5468816e476059f59537da18fab9c Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Sun, 28 Apr 2019 23:46:51 +0100 Subject: [PATCH 03/16] Export satisfy --- ChangeLog.md | 4 ++++ lsp-test.cabal | 2 +- src/Language/Haskell/LSP/Test.hs | 2 +- src/Language/Haskell/LSP/Test/Parsing.hs | 8 ++++++-- src/Language/Haskell/LSP/Test/Session.hs | 9 +++++---- test/Test.hs | 7 +++++++ 6 files changed, 24 insertions(+), 8 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 3af75a6..9397bfd 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,9 @@ # Revision history for lsp-test +## 0.5.2.0 -- 2019-04-28 + +* Add `satisfy` parser combinator + ## 0.5.1.0 -- 2019-04-22 * Fix unhandled `window/progress` server notifications diff --git a/lsp-test.cabal b/lsp-test.cabal index dd90f8b..a55bc40 100644 --- a/lsp-test.cabal +++ b/lsp-test.cabal @@ -1,5 +1,5 @@ name: lsp-test -version: 0.5.1.4 +version: 0.5.2.0 synopsis: Functional test framework for LSP servers. description: A test framework for writing tests against diff --git a/src/Language/Haskell/LSP/Test.hs b/src/Language/Haskell/LSP/Test.hs index 1b24fb7..4a1936d 100644 --- a/src/Language/Haskell/LSP/Test.hs +++ b/src/Language/Haskell/LSP/Test.hs @@ -351,7 +351,7 @@ waitForDiagnosticsSource src = do matches d = d ^. source == Just (T.pack src) -- | Expects a 'PublishDiagnosticsNotification' and throws an --- 'UnexpectedDiagnosticsException' if there are any diagnostics +-- 'UnexpectedDiagnostics' exception if there are any diagnostics -- returned. noDiagnostics :: Session () noDiagnostics = do diff --git a/src/Language/Haskell/LSP/Test/Parsing.hs b/src/Language/Haskell/LSP/Test/Parsing.hs index 1fd394f..09006b6 100644 --- a/src/Language/Haskell/LSP/Test/Parsing.hs +++ b/src/Language/Haskell/LSP/Test/Parsing.hs @@ -5,7 +5,8 @@ module Language.Haskell.LSP.Test.Parsing ( -- $receiving - message + satisfy + , message , anyRequest , anyResponse , anyNotification @@ -60,6 +61,9 @@ import Language.Haskell.LSP.Test.Session -- anyResponse -- @ +-- | Consumes and returns the next message, if it satisfies the specified predicate. +-- +-- @since 0.5.2.0 satisfy :: (FromServerMessage -> Bool) -> Session FromServerMessage satisfy pred = do @@ -85,7 +89,7 @@ satisfy pred = do return x else empty --- | Matches a message of type 'a'. +-- | Matches a message of type @a@. message :: forall a. (Typeable a, FromJSON a) => Session a message = let parser = decode . encodeMsg :: FromServerMessage -> Maybe a diff --git a/src/Language/Haskell/LSP/Test/Session.hs b/src/Language/Haskell/LSP/Test/Session.hs index 700d9cc..291a3e0 100644 --- a/src/Language/Haskell/LSP/Test/Session.hs +++ b/src/Language/Haskell/LSP/Test/Session.hs @@ -68,9 +68,10 @@ import System.IO -- | A session representing one instance of launching and connecting to a server. -- --- You can send and receive messages to the server within 'Session' via 'getMessage', --- 'sendRequest' and 'sendNotification'. --- +-- You can send and receive messages to the server within 'Session' via +-- 'Language.Haskell.LSP.Test.message', +-- 'Language.Haskell.LSP.Test.sendRequest' and +-- 'Language.Haskell.LSP.Test.sendNotification'. type Session = ParserStateReader FromServerMessage SessionState SessionContext IO @@ -296,7 +297,7 @@ sendMessage msg = do logMsg LogClient msg liftIO $ B.hPut h (addHeader $ encode msg) --- | Execute a block f that will throw a 'TimeoutException' +-- | Execute a block f that will throw a 'Timeout' exception -- after duration seconds. This will override the global timeout -- for waiting for messages to arrive defined in 'SessionConfig'. withTimeout :: Int -> Session a -> Session a diff --git a/test/Test.hs b/test/Test.hs index 0fc2f53..377bb6d 100644 --- a/test/Test.hs +++ b/test/Test.hs @@ -319,6 +319,13 @@ main = hspec $ do documentContents doc >>= liftIO . print in sesh `shouldThrow` anyException + describe "satisfy" $ + it "works" $ runSession "hie" fullCaps "test/data" $ do + openDoc "Format.hs" "haskell" + let pred (NotLogMessage _) = True + pred _ = False + void $ satisfy pred + mkRange sl sc el ec = Range (Position sl sc) (Position el ec) didChangeCaps :: ClientCapabilities -- 2.30.2 From 59380ca81c003f777fdfd48b92fbe873474fb9a8 Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Sun, 5 May 2019 22:10:09 +0100 Subject: [PATCH 04/16] Update haskell-lsp --- lsp-test.cabal | 12 ++++++------ src/Language/Haskell/LSP/Test.hs | 2 +- stack.yaml | 7 ++++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lsp-test.cabal b/lsp-test.cabal index a55bc40..7997540 100644 --- a/lsp-test.cabal +++ b/lsp-test.cabal @@ -1,5 +1,5 @@ name: lsp-test -version: 0.5.2.0 +version: 0.5.2.1 synopsis: Functional test framework for LSP servers. description: A test framework for writing tests against @@ -21,11 +21,11 @@ build-type: Simple cabal-version: 2.0 extra-source-files: README.md , ChangeLog.md -tested-with: GHC == 8.2.2 , GHC == 8.4.2 , GHC == 8.4.3, GHC == 8.6.4 +tested-with: GHC == 8.2.2 , GHC == 8.4.2 , GHC == 8.4.3, GHC == 8.6.4, GHC == 8.6.5 source-repository head type: git - location: https://github.com/bubba/haskell-lsp-test/ + location: https://github.com/bubba/lsp-test/ library hs-source-dirs: src @@ -36,7 +36,7 @@ library , parser-combinators:Control.Applicative.Combinators default-language: Haskell2010 build-depends: base >= 4.10 && < 5 - , haskell-lsp == 0.11.* + , haskell-lsp == 0.12.* , aeson , aeson-pretty , ansi-terminal @@ -52,10 +52,10 @@ library , mtl , parser-combinators , process + , rope-utf16-splay , text , transformers , unordered-containers - , yi-rope if os(windows) build-depends: Win32 else @@ -78,7 +78,7 @@ test-suite tests build-depends: base >= 4.10 && < 5 , hspec , lens - , haskell-lsp == 0.11.* + , haskell-lsp == 0.12.* , lsp-test , data-default , aeson diff --git a/src/Language/Haskell/LSP/Test.hs b/src/Language/Haskell/LSP/Test.hs index 4a1936d..696f84a 100644 --- a/src/Language/Haskell/LSP/Test.hs +++ b/src/Language/Haskell/LSP/Test.hs @@ -108,7 +108,7 @@ import Language.Haskell.LSP.Test.Server import System.IO import System.Directory import System.FilePath -import qualified Yi.Rope as Rope +import qualified Data.Rope.UTF16 as Rope -- | Starts a new session. -- diff --git a/stack.yaml b/stack.yaml index be001f8..90c3122 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,7 +1,8 @@ -resolver: lts-13.15 +resolver: nightly-2019-05-05 packages: - . extra-deps: - - haskell-lsp-0.11.0.0 - - haskell-lsp-types-0.11.0.0 + - haskell-lsp-0.12.0.0 + - haskell-lsp-types-0.12.0.0 + - rope-utf16-splay-0.2.0.0 -- 2.30.2 From 8cd3d41fef5b055ee1c79e6d83858d70c599367b Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Sun, 5 May 2019 22:31:25 +0100 Subject: [PATCH 05/16] Fix getTypeDefinitions test --- test/Test.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Test.hs b/test/Test.hs index 09f8b34..2372cbe 100644 --- a/test/Test.hs +++ b/test/Test.hs @@ -264,7 +264,7 @@ main = hspec $ do doc <- openDoc "Desktop/simple.hs" "haskell" let pos = Position 20 23 -- Quit value defs <- getTypeDefinitions doc pos - liftIO $ defs `shouldBe` [Location (doc ^. uri) (mkRange 10 0 15 19)] -- Type definition + liftIO $ defs `shouldBe` [Location (doc ^. uri) (mkRange 10 0 14 19)] -- Type definition describe "waitForDiagnosticsSource" $ it "works" $ runSession "hie" fullCaps "test/data" $ do -- 2.30.2 From d54524be6dd2b0b2d20530afd7049f22b33129d5 Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Tue, 7 May 2019 22:52:35 +0200 Subject: [PATCH 06/16] Adapt to new VirtualFile structure --- src/Language/Haskell/LSP/Test.hs | 2 +- src/Language/Haskell/LSP/Test/Session.hs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Language/Haskell/LSP/Test.hs b/src/Language/Haskell/LSP/Test.hs index 696f84a..6156b00 100644 --- a/src/Language/Haskell/LSP/Test.hs +++ b/src/Language/Haskell/LSP/Test.hs @@ -436,7 +436,7 @@ getVersionedDoc (TextDocumentIdentifier uri) = do fs <- vfs <$> get let ver = case fs Map.!? uri of - Just (VirtualFile v _) -> Just v + Just (VirtualFile v _ _) -> Just v _ -> Nothing return (VersionedTextDocumentIdentifier uri ver) diff --git a/src/Language/Haskell/LSP/Test/Session.hs b/src/Language/Haskell/LSP/Test/Session.hs index 291a3e0..a3ba35b 100644 --- a/src/Language/Haskell/LSP/Test/Session.hs +++ b/src/Language/Haskell/LSP/Test/Session.hs @@ -256,7 +256,7 @@ updateState (ReqApplyWorkspaceEdit r) = do forM_ bumpedVersions $ \(VersionedTextDocumentIdentifier uri v) -> modify $ \s -> let oldVFS = vfs s - update (VirtualFile oldV t) = VirtualFile (fromMaybe oldV v) t + update (VirtualFile oldV t mf) = VirtualFile (fromMaybe oldV v) t mf newVFS = Map.adjust update uri oldVFS in s { vfs = newVFS } -- 2.30.2 From e2ba182ddcc4e3763552e9ee1b85492c3d084ba5 Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Thu, 9 May 2019 09:18:57 +0100 Subject: [PATCH 07/16] Update haskell-lsp bounds --- lsp-test.cabal | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lsp-test.cabal b/lsp-test.cabal index 7997540..9969500 100644 --- a/lsp-test.cabal +++ b/lsp-test.cabal @@ -1,5 +1,5 @@ name: lsp-test -version: 0.5.2.1 +version: 0.5.2.2 synopsis: Functional test framework for LSP servers. description: A test framework for writing tests against @@ -36,7 +36,7 @@ library , parser-combinators:Control.Applicative.Combinators default-language: Haskell2010 build-depends: base >= 4.10 && < 5 - , haskell-lsp == 0.12.* + , haskell-lsp >= 0.12.1 && < 0.13 , aeson , aeson-pretty , ansi-terminal @@ -78,7 +78,7 @@ test-suite tests build-depends: base >= 4.10 && < 5 , hspec , lens - , haskell-lsp == 0.12.* + , haskell-lsp >= 0.12.1 && < 0.13 , lsp-test , data-default , aeson -- 2.30.2 From 752e8e9fbd04ae38e92c1fdbc32738addfc6ca0d Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Thu, 9 May 2019 09:39:13 +0100 Subject: [PATCH 08/16] Update stack extra-deps --- stack.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stack.yaml b/stack.yaml index 90c3122..b2386bc 100644 --- a/stack.yaml +++ b/stack.yaml @@ -3,6 +3,6 @@ packages: - . extra-deps: - - haskell-lsp-0.12.0.0 - - haskell-lsp-types-0.12.0.0 + - haskell-lsp-0.12.1.0 + - haskell-lsp-types-0.12.1.0 - rope-utf16-splay-0.2.0.0 -- 2.30.2 From 29ab0c9fff516595ad2c5fcbd62761229e70b6d9 Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Thu, 9 May 2019 10:14:27 +0100 Subject: [PATCH 09/16] Update stack.yaml --- stack.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack.yaml b/stack.yaml index b2386bc..5045e7f 100644 --- a/stack.yaml +++ b/stack.yaml @@ -5,4 +5,4 @@ packages: extra-deps: - haskell-lsp-0.12.1.0 - haskell-lsp-types-0.12.1.0 - - rope-utf16-splay-0.2.0.0 + - rope-utf16-splay-0.3.1.0 -- 2.30.2 From 89860a8cf94fed0f2773eebfd5d3ff7710ae3bb9 Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Sat, 18 May 2019 13:42:28 +0200 Subject: [PATCH 10/16] Bump haskell-lsp to 0.13.0.0 --- lsp-test.cabal | 4 ++-- stack.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lsp-test.cabal b/lsp-test.cabal index 9969500..a26562a 100644 --- a/lsp-test.cabal +++ b/lsp-test.cabal @@ -36,7 +36,7 @@ library , parser-combinators:Control.Applicative.Combinators default-language: Haskell2010 build-depends: base >= 4.10 && < 5 - , haskell-lsp >= 0.12.1 && < 0.13 + , haskell-lsp >= 0.13.0 && < 0.14 , aeson , aeson-pretty , ansi-terminal @@ -78,7 +78,7 @@ test-suite tests build-depends: base >= 4.10 && < 5 , hspec , lens - , haskell-lsp >= 0.12.1 && < 0.13 + , haskell-lsp >= 0.13.0 && < 0.14 , lsp-test , data-default , aeson diff --git a/stack.yaml b/stack.yaml index 5045e7f..d072777 100644 --- a/stack.yaml +++ b/stack.yaml @@ -3,6 +3,6 @@ packages: - . extra-deps: - - haskell-lsp-0.12.1.0 - - haskell-lsp-types-0.12.1.0 + - haskell-lsp-0.13.0.0 + - haskell-lsp-types-0.13.0.0 - rope-utf16-splay-0.3.1.0 -- 2.30.2 From 84da82290f9d2527400b62af36db85fd639d0965 Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Sat, 18 May 2019 14:55:53 +0100 Subject: [PATCH 11/16] Bump to 0.5.2.3 --- lsp-test.cabal | 2 +- stack.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lsp-test.cabal b/lsp-test.cabal index a26562a..aca12b0 100644 --- a/lsp-test.cabal +++ b/lsp-test.cabal @@ -1,5 +1,5 @@ name: lsp-test -version: 0.5.2.2 +version: 0.5.2.3 synopsis: Functional test framework for LSP servers. description: A test framework for writing tests against diff --git a/stack.yaml b/stack.yaml index d072777..26a1ba2 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,4 +1,4 @@ -resolver: nightly-2019-05-05 +resolver: lts-13.21 packages: - . -- 2.30.2 From 01cfd5ae44e86182adf1cee0a3e5769e3f1586d3 Mon Sep 17 00:00:00 2001 From: Moritz Kiefer Date: Tue, 4 Jun 2019 16:23:23 +0200 Subject: [PATCH 12/16] Support TextDocumentDidChange and add non-file based openDoc --- src/Language/Haskell/LSP/Test.hs | 42 +++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/src/Language/Haskell/LSP/Test.hs b/src/Language/Haskell/LSP/Test.hs index 6156b00..15cb2a1 100644 --- a/src/Language/Haskell/LSP/Test.hs +++ b/src/Language/Haskell/LSP/Test.hs @@ -41,7 +41,9 @@ module Language.Haskell.LSP.Test , initializeResponse -- ** Documents , openDoc + , openDoc' , closeDoc + , changeDoc , documentContents , getDocumentEdit , getDocUri @@ -283,6 +285,15 @@ sendNotification TextDocumentDidClose params = do modify (\s -> s { vfs = newVFS }) sendMessage n +sendNotification TextDocumentDidChange params = do + let params' = fromJust $ decode $ encode params + n :: DidChangeTextDocumentNotification + n = NotificationMessage "2.0" TextDocumentDidChange params' + oldVFS <- vfs <$> get + newVFS <- liftIO $ changeFromClientVFS oldVFS n + modify (\s -> s { vfs = newVFS }) + sendMessage n + sendNotification method params = sendMessage (NotificationMessage "2.0" method params) -- | Sends a response to the server. @@ -298,19 +309,20 @@ initializeResponse = initRsp <$> ask >>= (liftIO . readMVar) -- | Opens a text document and sends a notification to the client. openDoc :: FilePath -> String -> Session TextDocumentIdentifier openDoc file languageId = do - item <- getDocItem file languageId - sendNotification TextDocumentDidOpen (DidOpenTextDocumentParams item) - TextDocumentIdentifier <$> getDocUri file - where - -- | Reads in a text document as the first version. - getDocItem :: FilePath -- ^ The path to the text document to read in. - -> String -- ^ The language ID, e.g "haskell" for .hs files. - -> Session TextDocumentItem - getDocItem file languageId = do context <- ask let fp = rootDir context file contents <- liftIO $ T.readFile fp - return $ TextDocumentItem (filePathToUri fp) (T.pack languageId) 0 contents + openDoc' file languageId contents + +-- | This is a variant of `openDoc` that takes the file content as an argument. +openDoc' :: FilePath -> String -> T.Text -> Session TextDocumentIdentifier +openDoc' file languageId contents = do + context <- ask + let fp = rootDir context file + uri = filePathToUri fp + item = TextDocumentItem uri (T.pack languageId) 0 contents + sendNotification TextDocumentDidOpen (DidOpenTextDocumentParams item) + pure $ TextDocumentIdentifier uri -- | Closes a text document and sends a notification to the client. closeDoc :: TextDocumentIdentifier -> Session () @@ -318,10 +330,12 @@ closeDoc docId = do let params = DidCloseTextDocumentParams (TextDocumentIdentifier (docId ^. uri)) sendNotification TextDocumentDidClose params - oldVfs <- vfs <$> get - let notif = NotificationMessage "" TextDocumentDidClose params - newVfs <- liftIO $ closeVFS oldVfs notif - modify $ \s -> s { vfs = newVfs } +-- | Changes a text document and sends a notification to the client +changeDoc :: TextDocumentIdentifier -> [TextDocumentContentChangeEvent] -> Session () +changeDoc docId changes = do + verDoc <- getVersionedDoc docId + let params = DidChangeTextDocumentParams (verDoc & version . non 0 +~ 1) (List changes) + sendNotification TextDocumentDidChange params -- | Gets the Uri for the file corrected to the session directory. getDocUri :: FilePath -> Session Uri -- 2.30.2 From 3c7aa3a876b2142ceae3b649fbb5bd80e95aff77 Mon Sep 17 00:00:00 2001 From: Moritz Kiefer Date: Wed, 5 Jun 2019 13:58:20 +0200 Subject: [PATCH 13/16] Fix various issues encountered on Windows MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit There are a few things going on here, some specific to Windows and some are race conditions that are just easier to hit on Windows but can be reproduced on Linux if you add some delays. 1. You can’t kill threads on Windows that are blocked in an hGet. So what you have to do is to make the hGet fail somehow, e.g., by terminating the process that the hGet is reading from which will make hGet fail. 2. You already terminate the process by sending the exit notification. However, there is a race condition where listenServer will throw an UnexpectedServerTermination exception after the server has terminated as a result of the exit notification. On Linux, you usually get lucky and end up killing the listenServer thread first but due to 1 you always hit this on Windows. If you add a delay after sending the exit notification you can also reproduce this on Linux. 3. You need to set the handles to binary mode. Otherwise you end up with newline conversions turning \r\n into \n which will cause parse errors. --- lsp-test.cabal | 1 + src/Language/Haskell/LSP/Test.hs | 15 ++++++++++++++- src/Language/Haskell/LSP/Test/Server.hs | 16 ++++++---------- src/Language/Haskell/LSP/Test/Session.hs | 4 ++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/lsp-test.cabal b/lsp-test.cabal index aca12b0..f1035b2 100644 --- a/lsp-test.cabal +++ b/lsp-test.cabal @@ -40,6 +40,7 @@ library , aeson , aeson-pretty , ansi-terminal + , async , bytestring , conduit , conduit-parse diff --git a/src/Language/Haskell/LSP/Test.hs b/src/Language/Haskell/LSP/Test.hs index 15cb2a1..bc04845 100644 --- a/src/Language/Haskell/LSP/Test.hs +++ b/src/Language/Haskell/LSP/Test.hs @@ -92,6 +92,7 @@ import qualified Data.Text.IO as T import Data.Aeson import Data.Default import qualified Data.HashMap.Strict as HashMap +import Data.IORef import qualified Data.Map as Map import Data.Maybe import Language.Haskell.LSP.Types @@ -135,6 +136,8 @@ runSessionWithConfig :: SessionConfig -- ^ Configuration options for the session -> Session a -- ^ The session to run. -> IO a runSessionWithConfig config serverExe caps rootDir session = do + -- We use this IORef to make exception non-fatal when the server is supposed to shutdown. + exitOk <- newIORef False pid <- getCurrentProcessID absRootDir <- canonicalizePath rootDir @@ -146,7 +149,7 @@ runSessionWithConfig config serverExe caps rootDir session = do (Just TraceOff) Nothing withServer serverExe (logStdErr config) $ \serverIn serverOut _ -> - runSessionWithHandles serverIn serverOut listenServer config caps rootDir $ do + runSessionWithHandles serverIn serverOut (\h c -> catchWhenTrue exitOk $ listenServer h c) config caps rootDir $ do -- Wrap the session around initialize and shutdown calls initRspMsg <- request Initialize initializeParams :: Session InitializeResponse @@ -165,12 +168,22 @@ runSessionWithConfig config serverExe caps rootDir session = do -- Run the actual test result <- session + liftIO $ atomicWriteIORef exitOk True sendNotification Exit ExitParams return result where + catchWhenTrue :: IORef Bool -> IO () -> IO () + catchWhenTrue exitOk a = + a `catch` (\e -> do + x <- readIORef exitOk + unless x $ throw (e :: SomeException)) + -- | Listens to the server output, makes sure it matches the record and -- signals any semaphores + -- Note that on Windows, we cannot kill a thread stuck in getNextMessage. + -- So we have to wait for the exit notification to kill the process first + -- and then getNextMessage will fail. listenServer :: Handle -> SessionContext -> IO () listenServer serverOut context = do msgBytes <- getNextMessage serverOut diff --git a/src/Language/Haskell/LSP/Test/Server.hs b/src/Language/Haskell/LSP/Test/Server.hs index bd5bdb9..5449dfb 100644 --- a/src/Language/Haskell/LSP/Test/Server.hs +++ b/src/Language/Haskell/LSP/Test/Server.hs @@ -1,7 +1,6 @@ module Language.Haskell.LSP.Test.Server (withServer) where -import Control.Concurrent -import Control.Exception +import Control.Concurrent.Async import Control.Monad import Language.Haskell.LSP.Test.Compat import System.IO @@ -13,15 +12,12 @@ withServer serverExe logStdErr f = do -- separate command and arguments let cmd:args = words serverExe createProc = (proc cmd args) { std_in = CreatePipe, std_out = CreatePipe, std_err = CreatePipe } - (Just serverIn, Just serverOut, Just serverErr, serverProc) <- createProcess createProc - + withCreateProcess createProc $ \(Just serverIn) (Just serverOut) (Just serverErr) serverProc -> do -- Need to continuously consume to stderr else it gets blocked -- Can't pass NoStream either to std_err hSetBuffering serverErr NoBuffering - errSinkThread <- forkIO $ forever $ hGetLine serverErr >>= when logStdErr . putStrLn - + hSetBinaryMode serverErr True + let errSinkThread = forever $ hGetLine serverErr >>= when logStdErr . putStrLn + withAsync errSinkThread $ \_ -> do pid <- getProcessID serverProc - - finally (f serverIn serverOut pid) $ do - killThread errSinkThread - terminateProcess serverProc + f serverIn serverOut pid diff --git a/src/Language/Haskell/LSP/Test/Session.hs b/src/Language/Haskell/LSP/Test/Session.hs index a3ba35b..ab09726 100644 --- a/src/Language/Haskell/LSP/Test/Session.hs +++ b/src/Language/Haskell/LSP/Test/Session.hs @@ -197,6 +197,10 @@ runSessionWithHandles serverIn serverOut serverHandler config caps rootDir sessi hSetBuffering serverIn NoBuffering hSetBuffering serverOut NoBuffering + -- This is required to make sure that we don’t get any + -- newline conversion or weird encoding issues. + hSetBinaryMode serverIn True + hSetBinaryMode serverOut True reqMap <- newMVar newRequestMap messageChan <- newChan -- 2.30.2 From f80008bd828a5dd64ecb5d88cd4b6803abb5aef1 Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Mon, 10 Jun 2019 15:48:54 +0100 Subject: [PATCH 14/16] Squashed commit of the following: commit c42b0636ef8d2c3ebd44e15ba2c933dc08e397d3 Author: Luke Lau Date: Mon Jun 10 13:51:36 2019 +0100 Add npm folder to path, use stages for deploy commit 4eb9facea670edaf5c35aca45b434cde086abfb0 Author: Luke Lau Date: Mon Jun 10 11:40:30 2019 +0100 Update .travis.yml commit 98e56e42106597f5bdc84369bbcc73bf2ac74910 Author: Luke Lau Date: Mon Jun 10 11:23:52 2019 +0100 Only deploy on linux commit ead63f3029ae0550da8e7cd937a621b853042ff2 Author: Luke Lau Date: Mon Jun 10 11:17:57 2019 +0100 Update .travis.yml commit 154b27b2b5497c41d8e3004e1960102bc3d6b79d Author: Luke Lau Date: Mon Jun 10 10:55:05 2019 +0100 Update .travis.yml commit 07fddfb038d4d8c9385f6f350cbfc8f530926c73 Author: Luke Lau Date: Mon Jun 10 07:44:26 2019 +0100 Update .travis.yml commit 2a2a23bcf8fff91d275518bcee99dc8d6e8f41d1 Author: Luke Lau Date: Mon Jun 10 02:16:23 2019 +0100 Update .travis.yml commit 300a6c32acb0e4c6c075b0281b967bb57a291379 Author: Luke Lau Date: Sun Jun 9 13:26:26 2019 +0100 Explicitly specify copy on windows commit e673e7a122aae9995a94764d41e46d23e1191b2b Author: Luke Lau Date: Sun Jun 9 01:16:58 2019 +0100 Don't install cabal with ghc on choco commit 62984542160f77c5f82e74b57099bbb0a53cc3b4 Author: Luke Lau Date: Sun Jun 9 00:50:23 2019 +0100 Use copying on windows commit 49cf0e92944f3e3d043420056cfcf2101ebabbc2 Author: Luke Lau Date: Sat Jun 8 22:49:43 2019 +0100 Add cabal-head source commit ed60b9859b80372ecc6280d24f9e4e3f0408c192 Author: Luke Lau Date: Sat Jun 8 22:31:52 2019 +0100 Use cabal-head commit 12410701a2516fa6f72634810eab7cb2f64868ae Author: Luke Lau Date: Sat Jun 8 22:18:04 2019 +0100 Use cabal nightly on windows commit d6b41645f54661b5b317ab36641c4243ecee3334 Author: Luke Lau Date: Sat Jun 8 20:26:26 2019 +0100 Try manually adding ghc to path on windows commit 9530a8d8b10247e881b8d514a305f2f8c0ebcda0 Author: Luke Lau Date: Sat Jun 8 20:13:04 2019 +0100 Revert back to just osx and linux builds commit 27b8dd29b4330f76f6d03c570b973acd601e8e08 Author: Luke Lau Date: Sat Jun 8 19:50:18 2019 +0100 Whittle down the install steps commit 3efde86ce929fa43348929f41127b4a47633872a Author: Luke Lau Date: Sat Jun 8 19:28:45 2019 +0100 Move ghc version commit 4caf116cc37287e9a13032b913e626f8a21d70f8 Author: Luke Lau Date: Sat Jun 8 18:56:32 2019 +0100 Debug why windows isn't working commit 62b3ab2ef05a86c02cef7a80ce18ba7ce63486dc Author: Luke Lau Date: Sat Jun 8 18:41:39 2019 +0100 Add ghc/cabal to path on linux commit 67a10d32f425d6bc4d37aa3046f051a4b7e66e26 Author: Luke Lau Date: Sat Jun 8 18:34:08 2019 +0100 Update cabal commit 0390ef572976516a3360dbe2b3ad8375260e580a Author: Luke Lau Date: Sat Jun 8 18:13:11 2019 +0100 Update homebrew commit 79db6a5b2825f47f386098ce696003553204a856 Author: Luke Lau Date: Sat Jun 8 18:10:49 2019 +0100 Install packages on all OSs commit 49c803688253352a92d0d1bce2685bef38c43196 Author: Luke Lau Date: Sat Jun 8 18:01:48 2019 +0100 Try out other operating systems commit 7ca8d96479f8ee8711e774b9a74ab5f27e150d1f Author: Luke Lau Date: Sat Jun 8 17:17:53 2019 +0100 Try to fix further timeout messages commit ea0b53220519e178ca27e23c2a3be47fcf819afa Author: Luke Lau Date: Sat Jun 8 17:01:39 2019 +0100 Figure out whats going on with failing test commit a986ed6b44d62079476dadb07388b43847c5d724 Author: Luke Lau Date: Sat Jun 8 12:49:24 2019 +0100 Try fixing tests and debug commit 4d68c322be54d7016d19d1bfd714eb272864a21f Author: Luke Lau Date: Thu Jun 6 22:22:52 2019 +0100 Overwrite commit 8749cec613c3d3e7f3c3b305d07dd295ba59958d Author: Luke Lau Date: Thu Jun 6 21:36:49 2019 +0100 Use old install for Cabal library commit 749953cb3ab08f2278e6badda8b1bd3550f06da6 Author: Luke Lau Date: Thu Jun 6 07:50:28 2019 +0100 Update .travis.yml commit cdf9bb2af734ed3473c4ad7cc1e5825a812791c0 Author: Luke Lau Date: Wed Jun 5 10:59:47 2019 +0100 Update .travis.yml commit fa801802a9f0c5c034b6a55de9c5d65016a795d0 Author: Luke Lau Date: Wed Jun 5 10:28:11 2019 +0100 Install cabal library globally commit 1941f747e139f0b904fb065216e194fdf240c2a4 Author: Luke Lau Date: Wed Jun 5 07:51:39 2019 +0100 Debug tests commit 5468fbe3b35330fa3a2dc5bec82e45ae2644abf2 Author: Luke Lau Date: Wed Jun 5 01:08:56 2019 +0100 Add cabal bin directory to path commit 04d18137900c9c3eb5e2837cbe59ae6fedbdc584 Author: Luke Lau Date: Wed Jun 5 01:03:19 2019 +0100 Bump number of jobs to two commit b906d381f30e1a6e79d051cfdee2751f2ab39cb0 Author: Luke Lau Date: Wed Jun 5 01:01:04 2019 +0100 Add deployment to Hackage and GitHub commit 88d77c7483e0497cf249db0e65e583ebe21dfbe2 Author: Luke Lau Date: Tue Jun 4 23:00:41 2019 +0100 Try out v2 builds again --- .travis.yml | 110 ++++++++++++++++++++++++++++++++++++++++++--------- stack.yaml | 2 +- test/Test.hs | 6 ++- 3 files changed, 97 insertions(+), 21 deletions(-) diff --git a/.travis.yml b/.travis.yml index c1cf11b..2666b25 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,37 +1,109 @@ language: c - sudo: false +os: +- linux +- osx +- windows + +dist: xenial + +ghc: +- 8.6.5 +cabal: '2.4' + cache: directories: - - .stack-work - - $HOME/.stack - - $HOME/haskell-ide-engine/.stack-work - timeout: 1000 + - "$HOME/.cabal" + - "$HOME/.ghc" + - "$HOME/haskell-ide-engine/dist-newstyle" + - "dist-newstyle" addons: apt: + sources: + - sourceline: ppa:hvr/ghc + packages: + - npm + - ghc-8.6.5 + - cabal-install-2.4 + homebrew: packages: + - ghc + - cabal-install - npm + update: true before_install: - - mkdir -p ~/.local/bin - - export PATH=$HOME/.local/bin:$PATH - - travis_retry curl -L https://get.haskellstack.org/stable/linux-x86_64.tar.gz | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack' - - mkdir -p haskell-ide-engine - - cd $HOME/haskell-ide-engine +- | + if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then + choco source add -n mistuke -s https://www.myget.org/F/mistuke/api/v2 + choco install cabal-head -pre + choco install ghc --ignore-dependencies + choco install nodejs.install + /C/ProgramData/chocolatey/bin/RefreshEnv.cmd + + # ghc/cabal paths + export PATH=/C/ProgramData/chocolatey/lib/ghc/tools/ghc-8.6.5/bin:${PATH} + export PATH=${APPDATA}/cabal/bin:${PATH} + # nodejs paths + export PATH=/C/Program\ Files/nodejs:${PATH} + export PATH=${APPDATA}/npm:${PATH} + fi +# these are taken from the haskell language setup +- export PATH=/opt/ghc/8.6.5/bin:${PATH} +- export PATH=/opt/cabal/2.4/bin:${PATH} +- export PATH=$HOME/.cabal/bin:${PATH} +- npm update +- npm i -g javascript-typescript-langserver +- mkdir -p $HOME/haskell-ide-engine +- pushd $HOME/haskell-ide-engine - git init - git remote add origin https://github.com/haskell/haskell-ide-engine.git - git pull origin master - - git checkout 47b5281d9d8ffe7348f7f7fcb3ce36b4eabd4f06 - - git submodule init - - git submodule sync +- git checkout abdb097f39e135deaf321a604c95f16cbda32678 - git submodule update --init - - stack --no-terminal --skip-ghc-check -j2 install - - stack exec hoogle generate - - cd $TRAVIS_BUILD_DIR - - npm update - - npm i -g javascript-typescript-langserver +- cabal v2-update +- | + if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then + cabal v2-install hie -j2 --overwrite-policy=always --install-method=copy + else + cabal v2-install hie -j2 --overwrite-policy=always + fi +- | + if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then + cabal v2-install hoogle -j2 --overwrite-policy=always --install-method=copy + else + cabal v2-install hoogle -j2 --overwrite-policy=always + fi +- hoogle generate +- popd +# needs to be old-install for cabal-helper to find it +- cabal v1-install Cabal --constraint "Cabal == 2.4.1.0" +install: +- cabal v2-build script: - - stack test +# until cabal v2-test supports streaming results +- cabal v2-run lsp-test:test:tests + +jobs: + include: + - stage: deploy + deploy: + - provider: hackage + username: bubba + password: + secure: M95r2TETDB9ndhqV0xCA9XSRw9k3tBj1xgTTAvB9b/aK3198XekZTak24a+etDNeq8cUke8wmWbN7UfBBlXiDmYYK+DfUFj5ilrkNRO+cAHQzx6TQ+yGr4GhTGhu76zA0g9PZLwMoaZdUELdOkNtRDh0EjC/PVMIp84ZKn2hBLJrptkeBbI5XDArd9I6gvu9mEuPjQ595GdHkKQdQJNEDyr1BQ9BwqUxCHj3HbUjkkfpdgujxE93wzj82/HMzGncYxeH5m5YWvK3ayX22cY3ZXK3D6jgZFB/wdp3uGwoUl1HGaVjAl6XbyV0ALMQkGTWOPrfI3HWqOtOcs349poMckDFseG1LmTXtWa3cG+8bcdzZtCbbo4pLu57e6DULivmvOw64R/tPPUx/evBRhstYVevYLrN0hJLwP3jWYl4BheHSCoDsv8cTFPaNYI/f0LgHF2NaUNBK89pOiR8kmue7oGoCUF/gBRKgqswG0xEji0YvkSIfPV/7qmfL2uoLFCZ/YpMQ8F80KjxsaA5qA3ktt0fVj14QNtsHl4+Qkwj5dtalre2zw5eHyZTe8svlD9Fp4pBaHMuazLDDyv/Aor4JYfInlfIR6oTtn6ty09eX0KjA2OhFi4hE4/jClt6ASDm3Dfv7bnFJJEBQLxfwFcQCFmAsI0EyUrAFmLON07hsm4= + on: + tags: true + branch: master + repo: bubba/lsp-test + - provider: github + api_key: + secure: JKjHWJ/ikW15Y/ZfnlREUeTj2Nw+QHzuc7yC3Bw+AOYQo8gKLCpZiN2iqPaw9xJifGoadutLaKKl2SSup7sZ8CGNW5brttqtGEgxJZci+rjR/b/5RHlyOM10RUg4rwKE0oRo8qXpbRuw6x8cWsREjworMBewZCyF6ToUuTzzMaHqvE/mxwIxoW3b30Xt+TytD6rRlbk/MNiRSZpJeA1TyNiPmpGTqSBc8LBhh8H3IOaZDL3bxlENTEuTJFW67vCQSsoH4/9JKeJ/M3WiwBVza4CTTMfQAxijYOqVGqYcoFtqMXDv4q+IhnBVSYpVo24Ii7zS2I4uQsWDNf5mdtUmfF5MJh9kKRnlp8464VWcLeRWJNsJMz09+rFiUQnl8ovPiu6bwv6GCwsBLzrYdrMx4w/F8FMuB05DsORPWqAcGjSw94seIJcTRTEZg8MbFswNSNptMIf0/PPYDAzoxpAmmS8kigJBL0ymw/QrPgyVKz1hiN2u/OOxmkjM0mrSB2fUGKghyHg0MGIIS8bx6H/pFuX7/WmuQHcUbk5Z6S64YXrb2Vqb3l6Ua0Tz7uwRWrWI8YyTb7KMyhAeYChK5zEWlMBIAv7T602qFJWerU+Eor4lLJmd7CunUah3voPJ4JL8LhhOcVlrWpke+1S+JB6LPOTjQZTjxN3qeR9uGMdl/Zk= + draft: true + on: + tags: true + branch: master + repo: bubba/lsp-test diff --git a/stack.yaml b/stack.yaml index 26a1ba2..9790aba 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,4 +1,4 @@ -resolver: lts-13.21 +resolver: lts-13.24 packages: - . diff --git a/test/Test.hs b/test/Test.hs index 380c98b..cdcdf5d 100644 --- a/test/Test.hs +++ b/test/Test.hs @@ -62,8 +62,12 @@ main = hspec $ do it "further timeout messages are ignored" $ runSession "hie" fullCaps "test/data/renamePass" $ do doc <- openDoc "Desktop/simple.hs" "haskell" + -- warm up the cache + getDocumentSymbols doc + -- shouldn't timeout withTimeout 3 $ getDocumentSymbols doc - liftIO $ threadDelay 5000000 + -- longer than the original timeout + liftIO $ threadDelay (5 * 10^6) -- shouldn't throw an exception getDocumentSymbols doc return () -- 2.30.2 From 2440adccbc46f22e5d1221bacc3d39512a0251cd Mon Sep 17 00:00:00 2001 From: Moritz Kiefer Date: Tue, 4 Jun 2019 11:21:19 +0200 Subject: [PATCH 15/16] Adapt to custom methods changes in haskell-lsp --- cabal.project | 11 +++++++++++ src/Language/Haskell/LSP/Test/Decoding.hs | 7 ++++++- src/Language/Haskell/LSP/Test/Messages.hs | 6 +++++- stack.yaml | 7 +++++-- 4 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 cabal.project diff --git a/cabal.project b/cabal.project new file mode 100644 index 0000000..ac9b511 --- /dev/null +++ b/cabal.project @@ -0,0 +1,11 @@ +packages: + ./. +source-repository-package + type: git + location: https://github.com/alanz/haskell-lsp.git + tag: 491d8d2e33572b3868078f57a3375b2ac621f958 +source-repository-package + type: git + location: https://github.com/alanz/haskell-lsp.git + tag: 491d8d2e33572b3868078f57a3375b2ac621f958 + subdir: haskell-lsp-types diff --git a/src/Language/Haskell/LSP/Test/Decoding.hs b/src/Language/Haskell/LSP/Test/Decoding.hs index 337dee3..27c7770 100644 --- a/src/Language/Haskell/LSP/Test/Decoding.hs +++ b/src/Language/Haskell/LSP/Test/Decoding.hs @@ -123,7 +123,7 @@ matchResponseMsgType req = case req of decodeFromServerMsg :: RequestMap -> B.ByteString -> FromServerMessage decodeFromServerMsg reqMap bytes = - case HM.lookup "method" (fromJust $ decode bytes :: Object) of + case HM.lookup "method" obj of Just methodStr -> case fromJSON methodStr of Success method -> case method of -- We can work out the type of the message @@ -141,6 +141,10 @@ decodeFromServerMsg reqMap bytes = WorkspaceApplyEdit -> ReqApplyWorkspaceEdit $ fromJust $ decode bytes WorkspaceWorkspaceFolders -> error "ReqWorkspaceFolders not supported yet" WorkspaceConfiguration -> error "ReqWorkspaceConfiguration not supported yet" + CustomServerMethod _ + | "id" `HM.member` obj && "method" `HM.member` obj -> ReqCustomServer $ fromJust $ decode bytes + | "id" `HM.member` obj -> RspCustomServer $ fromJust $ decode bytes + | otherwise -> NotCustomServer $ fromJust $ decode bytes Error e -> error e @@ -149,3 +153,4 @@ decodeFromServerMsg reqMap bytes = Just req -> matchResponseMsgType req bytes -- try to decode it to more specific type Nothing -> error "Couldn't match up response with request" Nothing -> error "Couldn't decode message" + where obj = fromJust $ decode bytes :: Object diff --git a/src/Language/Haskell/LSP/Test/Messages.hs b/src/Language/Haskell/LSP/Test/Messages.hs index 1a3805f..16813e2 100644 --- a/src/Language/Haskell/LSP/Test/Messages.hs +++ b/src/Language/Haskell/LSP/Test/Messages.hs @@ -59,6 +59,7 @@ handleServerMessage request response notification msg = case msg of (ReqApplyWorkspaceEdit m) -> request m (ReqShowMessage m) -> request m (ReqUnregisterCapability m) -> request m + (ReqCustomServer m) -> request m (RspInitialize m) -> response m (RspShutdown m) -> response m (RspHover m) -> response m @@ -87,6 +88,7 @@ handleServerMessage request response notification msg = case msg of (RspDocumentColor m) -> response m (RspColorPresentation m) -> response m (RspFoldingRange m) -> response m + (RspCustomServer m) -> response m (NotPublishDiagnostics m) -> notification m (NotLogMessage m) -> notification m (NotShowMessage m) -> notification m @@ -95,6 +97,7 @@ handleServerMessage request response notification msg = case msg of (NotProgressDone m) -> notification m (NotTelemetry m) -> notification m (NotCancelRequestFromServer m) -> notification m + (NotCustomServer m) -> notification m handleClientMessage :: forall a. @@ -145,4 +148,5 @@ handleClientMessage request response notification msg = case msg of (NotDidChangeWatchedFiles m) -> notification m (NotDidChangeWorkspaceFolders m) -> notification m (NotProgressCancel m) -> notification m - (UnknownFromClientMessage m) -> error $ "Unknown message sent from client: " ++ show m + (ReqCustomClient m) -> request m + (NotCustomClient m) -> notification m diff --git a/stack.yaml b/stack.yaml index 9790aba..855f4e9 100644 --- a/stack.yaml +++ b/stack.yaml @@ -3,6 +3,9 @@ packages: - . extra-deps: - - haskell-lsp-0.13.0.0 - - haskell-lsp-types-0.13.0.0 + - git: https://github.com/alanz/haskell-lsp.git + commit: 491d8d2e33572b3868078f57a3375b2ac621f958 + subdirs: + - . + - haskell-lsp-types - rope-utf16-splay-0.3.1.0 -- 2.30.2 From c1dbd1ae5ac33bd7cdf838981a4b9358e028ed11 Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Thu, 13 Jun 2019 01:24:32 +0100 Subject: [PATCH 16/16] Use haskell-lsp from hackage and bump --- cabal.project | 11 ----------- lsp-test.cabal | 6 +++--- stack.yaml | 7 ++----- 3 files changed, 5 insertions(+), 19 deletions(-) delete mode 100644 cabal.project diff --git a/cabal.project b/cabal.project deleted file mode 100644 index ac9b511..0000000 --- a/cabal.project +++ /dev/null @@ -1,11 +0,0 @@ -packages: - ./. -source-repository-package - type: git - location: https://github.com/alanz/haskell-lsp.git - tag: 491d8d2e33572b3868078f57a3375b2ac621f958 -source-repository-package - type: git - location: https://github.com/alanz/haskell-lsp.git - tag: 491d8d2e33572b3868078f57a3375b2ac621f958 - subdir: haskell-lsp-types diff --git a/lsp-test.cabal b/lsp-test.cabal index f1035b2..f5b8f97 100644 --- a/lsp-test.cabal +++ b/lsp-test.cabal @@ -1,5 +1,5 @@ name: lsp-test -version: 0.5.2.3 +version: 0.5.3.0 synopsis: Functional test framework for LSP servers. description: A test framework for writing tests against @@ -36,7 +36,7 @@ library , parser-combinators:Control.Applicative.Combinators default-language: Haskell2010 build-depends: base >= 4.10 && < 5 - , haskell-lsp >= 0.13.0 && < 0.14 + , haskell-lsp == 0.14.* , aeson , aeson-pretty , ansi-terminal @@ -79,7 +79,7 @@ test-suite tests build-depends: base >= 4.10 && < 5 , hspec , lens - , haskell-lsp >= 0.13.0 && < 0.14 + , haskell-lsp == 0.14.* , lsp-test , data-default , aeson diff --git a/stack.yaml b/stack.yaml index 855f4e9..502afa8 100644 --- a/stack.yaml +++ b/stack.yaml @@ -3,9 +3,6 @@ packages: - . extra-deps: - - git: https://github.com/alanz/haskell-lsp.git - commit: 491d8d2e33572b3868078f57a3375b2ac621f958 - subdirs: - - . - - haskell-lsp-types + - haskell-lsp-0.14.0.0 + - haskell-lsp-types-0.14.0.0 - rope-utf16-splay-0.3.1.0 -- 2.30.2