From bdc9afec813d121fbf8d4dccdf95998f428fa485 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Tue, 2 Jul 2019 16:44:41 +0200 Subject: [PATCH] Upgrading to haskell-lsp 0.15 --- lsp-test.cabal | 4 ++-- src/Language/Haskell/LSP/Test.hs | 6 +++--- src/Language/Haskell/LSP/Test/Session.hs | 10 +++++----- stack.yaml | 7 ++++--- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/lsp-test.cabal b/lsp-test.cabal index 79e256e..ca027ff 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.14.* + , haskell-lsp == 0.15.* , aeson , aeson-pretty , ansi-terminal @@ -79,7 +79,7 @@ test-suite tests build-depends: base >= 4.10 && < 5 , hspec , lens - , haskell-lsp == 0.14.* + , haskell-lsp == 0.15.* , lsp-test , data-default , aeson diff --git a/src/Language/Haskell/LSP/Test.hs b/src/Language/Haskell/LSP/Test.hs index 1c425fb..e946cb7 100644 --- a/src/Language/Haskell/LSP/Test.hs +++ b/src/Language/Haskell/LSP/Test.hs @@ -201,7 +201,7 @@ runSessionWithConfig config serverExe caps rootDir session = do documentContents :: TextDocumentIdentifier -> Session T.Text documentContents doc = do vfs <- vfs <$> get - let file = vfs Map.! (doc ^. uri) + let file = vfs Map.! toNormalizedUri (doc ^. uri) return $ Rope.toText $ Language.Haskell.LSP.VFS._text file -- | Parses an ApplyEditRequest, checks that it is for the passed document @@ -435,7 +435,7 @@ getCodeActionContext doc = do -- | Returns the current diagnostics that have been sent to the client. -- Note that this does not wait for more to come in. getCurrentDiagnostics :: TextDocumentIdentifier -> Session [Diagnostic] -getCurrentDiagnostics doc = fromMaybe [] . Map.lookup (doc ^. uri) . curDiagnostics <$> get +getCurrentDiagnostics doc = fromMaybe [] . Map.lookup (toNormalizedUri $ doc ^. uri) . curDiagnostics <$> get -- | Executes a command. executeCommand :: Command -> Session () @@ -464,7 +464,7 @@ getVersionedDoc :: TextDocumentIdentifier -> Session VersionedTextDocumentIdenti getVersionedDoc (TextDocumentIdentifier uri) = do fs <- vfs <$> get let ver = - case fs Map.!? uri of + case fs Map.!? toNormalizedUri uri of 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 ab09726..46155f0 100644 --- a/src/Language/Haskell/LSP/Test/Session.hs +++ b/src/Language/Haskell/LSP/Test/Session.hs @@ -128,7 +128,7 @@ data SessionState = SessionState { curReqId :: LspId , vfs :: VFS - , curDiagnostics :: Map.Map Uri [Diagnostic] + , curDiagnostics :: Map.Map NormalizedUri [Diagnostic] , curTimeoutId :: Int , overridingTimeout :: Bool -- ^ The last received message from the server. @@ -227,7 +227,7 @@ updateState (NotPublishDiagnostics n) = do let List diags = n ^. params . diagnostics doc = n ^. params . uri modify (\s -> - let newDiags = Map.insert doc diags (curDiagnostics s) + let newDiags = Map.insert (toNormalizedUri doc) diags (curDiagnostics s) in s { curDiagnostics = newDiags }) updateState (ReqApplyWorkspaceEdit r) = do @@ -246,7 +246,7 @@ updateState (ReqApplyWorkspaceEdit r) = do newVFS <- liftIO $ changeFromServerVFS (vfs s) r return $ s { vfs = newVFS } - let groupedParams = groupBy (\a b -> (a ^. textDocument == b ^. textDocument)) allChangeParams + let groupedParams = groupBy (\a b -> a ^. textDocument == b ^. textDocument) allChangeParams mergedParams = map mergeParams groupedParams -- TODO: Don't do this when replaying a session @@ -261,7 +261,7 @@ updateState (ReqApplyWorkspaceEdit r) = do modify $ \s -> let oldVFS = vfs s update (VirtualFile oldV t mf) = VirtualFile (fromMaybe oldV v) t mf - newVFS = Map.adjust update uri oldVFS + newVFS = Map.adjust update (toNormalizedUri uri) oldVFS in s { vfs = newVFS } where checkIfNeedsOpened uri = do @@ -269,7 +269,7 @@ updateState (ReqApplyWorkspaceEdit r) = do ctx <- ask -- if its not open, open it - unless (uri `Map.member` oldVFS) $ do + unless (toNormalizedUri uri `Map.member` oldVFS) $ do let fp = fromJust $ uriToFilePath uri contents <- liftIO $ T.readFile fp let item = TextDocumentItem (filePathToUri fp) "" 0 contents diff --git a/stack.yaml b/stack.yaml index 502afa8..aa3b5ca 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,8 +1,9 @@ -resolver: lts-13.24 +resolver: lts-13.26 +allow-newer: true packages: - . extra-deps: - - haskell-lsp-0.14.0.0 - - haskell-lsp-types-0.14.0.0 - rope-utf16-splay-0.3.1.0 + - haskell-lsp-0.15.0.0 + - haskell-lsp-types-0.15.0.0 -- 2.30.2