Upgrading to haskell-lsp 0.15
authorJose Lorenzo Rodriguez <jose.zap@gmail.com>
Tue, 2 Jul 2019 14:44:41 +0000 (16:44 +0200)
committerJose Lorenzo Rodriguez <jose.zap@gmail.com>
Tue, 2 Jul 2019 14:44:41 +0000 (16:44 +0200)
lsp-test.cabal
src/Language/Haskell/LSP/Test.hs
src/Language/Haskell/LSP/Test/Session.hs
stack.yaml

index 79e256e505d193323e11af3725ee37dbfc765869..ca027ffe86ff02bc6b5f8834042eddd7c00f7658 100644 (file)
@@ -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
index 1c425fb89cc49aa0af526b99ab7d5753d261a679..e946cb79a8f61a8bef6bbf2474d07ab1f6a6d8fc 100644 (file)
@@ -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)
index ab09726f2ef5490654d4a41099ed53e42f03b608..46155f0607cfa1b752b541b755a761b1551b4b30 100644 (file)
@@ -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
index 502afa8d9d0054d2849890167547f5fc9d621103..aa3b5ca965a54c58da0329ab000d7493dc0f14f5 100644 (file)
@@ -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