projects
/
opengl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #20 from Bubba/haskell-lsp-0.6
[opengl.git]
/
src
/
Language
/
Haskell
/
LSP
/
Test.hs
diff --git
a/src/Language/Haskell/LSP/Test.hs
b/src/Language/Haskell/LSP/Test.hs
index ed60e585822a9c51da7b4a63e35252b2d2179f3b..04fcc21a7f9510a10f4acc0c0eb012a24321db21 100644
(file)
--- a/
src/Language/Haskell/LSP/Test.hs
+++ b/
src/Language/Haskell/LSP/Test.hs
@@
-23,7
+23,7
@@
module Language.Haskell.LSP.Test
, runSessionWithConfig
, SessionConfig(..)
, defaultConfig
, runSessionWithConfig
, SessionConfig(..)
, defaultConfig
- , module Language.Haskell.LSP.T
est
.Capabilities
+ , module Language.Haskell.LSP.T
ypes
.Capabilities
-- ** Exceptions
, module Language.Haskell.LSP.Test.Exceptions
, withTimeout
-- ** Exceptions
, module Language.Haskell.LSP.Test.Exceptions
, withTimeout
@@
-91,10
+91,9
@@
import qualified Data.Map as Map
import Data.Maybe
import Language.Haskell.LSP.Types hiding (id, capabilities, message)
import qualified Language.Haskell.LSP.Types as LSP
import Data.Maybe
import Language.Haskell.LSP.Types hiding (id, capabilities, message)
import qualified Language.Haskell.LSP.Types as LSP
-import
qualified Language.Haskell.LSP.Types.Capabilities as LSP
+import
Language.Haskell.LSP.Types.Capabilities
import Language.Haskell.LSP.Messages
import Language.Haskell.LSP.VFS
import Language.Haskell.LSP.Messages
import Language.Haskell.LSP.VFS
-import Language.Haskell.LSP.Test.Capabilities
import Language.Haskell.LSP.Test.Compat
import Language.Haskell.LSP.Test.Decoding
import Language.Haskell.LSP.Test.Exceptions
import Language.Haskell.LSP.Test.Compat
import Language.Haskell.LSP.Test.Decoding
import Language.Haskell.LSP.Test.Exceptions
@@
-115,7
+114,7
@@
import qualified Yi.Rope as Rope
-- > params = TextDocumentPositionParams doc
-- > hover <- request TextDocumentHover params
runSession :: String -- ^ The command to run the server.
-- > params = TextDocumentPositionParams doc
-- > hover <- request TextDocumentHover params
runSession :: String -- ^ The command to run the server.
- ->
LSP.
ClientCapabilities -- ^ The capabilities that the client should declare.
+ -> ClientCapabilities -- ^ The capabilities that the client should declare.
-> FilePath -- ^ The filepath to the root directory for the session.
-> Session a -- ^ The session to run.
-> IO a
-> FilePath -- ^ The filepath to the root directory for the session.
-> Session a -- ^ The session to run.
-> IO a
@@
-124,7
+123,7
@@
runSession = runSessionWithConfig def
-- | Starts a new sesion with a custom configuration.
runSessionWithConfig :: SessionConfig -- ^ Configuration options for the session.
-> String -- ^ The command to run the server.
-- | Starts a new sesion with a custom configuration.
runSessionWithConfig :: SessionConfig -- ^ Configuration options for the session.
-> String -- ^ The command to run the server.
- ->
LSP.
ClientCapabilities -- ^ The capabilities that the client should declare.
+ -> ClientCapabilities -- ^ The capabilities that the client should declare.
-> FilePath -- ^ The filepath to the root directory for the session.
-> Session a -- ^ The session to run.
-> IO a
-> FilePath -- ^ The filepath to the root directory for the session.
-> Session a -- ^ The session to run.
-> IO a
@@
-350,17
+349,19
@@
noDiagnostics = do
when (diagsNot ^. params . LSP.diagnostics /= List []) $ liftIO $ throw UnexpectedDiagnostics
-- | Returns the symbols in a document.
when (diagsNot ^. params . LSP.diagnostics /= List []) $ liftIO $ throw UnexpectedDiagnostics
-- | Returns the symbols in a document.
-getDocumentSymbols :: TextDocumentIdentifier -> Session
[SymbolInformation]
+getDocumentSymbols :: TextDocumentIdentifier -> Session
(Either [DocumentSymbol] [SymbolInformation])
getDocumentSymbols doc = do
getDocumentSymbols doc = do
- ResponseMessage _ rspLid mRes mErr <- request TextDocumentDocumentSymbol (DocumentSymbolParams doc)
+ ResponseMessage _ rspLid mRes mErr <- request TextDocumentDocumentSymbol (DocumentSymbolParams doc)
:: Session DocumentSymbolsResponse
maybe (return ()) (throw . UnexpectedResponseError rspLid) mErr
maybe (return ()) (throw . UnexpectedResponseError rspLid) mErr
- let (Just (List symbols)) = mRes
- return symbols
+ case mRes of
+ Just (DSDocumentSymbols (List xs)) -> return (Left xs)
+ Just (DSSymbolInformation (List xs)) -> return (Right xs)
+ Nothing -> Prelude.error "No result and no error in DocumentSymbolsResponse"
-- | Returns all the code actions in a document by
-- querying the code actions at each of the current
-- diagnostics' positions.
-- | Returns all the code actions in a document by
-- querying the code actions at each of the current
-- diagnostics' positions.
-getAllCodeActions :: TextDocumentIdentifier -> Session [C
ommandOrCodeAction
]
+getAllCodeActions :: TextDocumentIdentifier -> Session [C
AResult
]
getAllCodeActions doc = do
curDiags <- fromMaybe [] . Map.lookup (doc ^. uri) . curDiagnostics <$> get
let ctx = CodeActionContext (List curDiags) Nothing
getAllCodeActions doc = do
curDiags <- fromMaybe [] . Map.lookup (doc ^. uri) . curDiagnostics <$> get
let ctx = CodeActionContext (List curDiags) Nothing
@@
-368,7
+369,7
@@
getAllCodeActions doc = do
foldM (go ctx) [] curDiags
where
foldM (go ctx) [] curDiags
where
- go :: CodeActionContext -> [C
ommandOrCodeAction] -> Diagnostic -> Session [CommandOrCodeAction
]
+ go :: CodeActionContext -> [C
AResult] -> Diagnostic -> Session [CAResult
]
go ctx acc diag = do
ResponseMessage _ rspLid mRes mErr <- request TextDocumentCodeAction (CodeActionParams doc (diag ^. range) ctx)
go ctx acc diag = do
ResponseMessage _ rspLid mRes mErr <- request TextDocumentCodeAction (CodeActionParams doc (diag ^. range) ctx)
@@
-419,9
+420,9
@@
applyEdit doc edit = do
caps <- asks sessionCapabilities
let supportsDocChanges = fromMaybe False $ do
caps <- asks sessionCapabilities
let supportsDocChanges = fromMaybe False $ do
- let
LSP.
ClientCapabilities mWorkspace _ _ = caps
-
LSP.WorkspaceClientCapabilities _ mEdit
_ _ _ _ <- mWorkspace
-
LSP.
WorkspaceEditClientCapabilities mDocChanges <- mEdit
+ let ClientCapabilities mWorkspace _ _ = caps
+
WorkspaceClientCapabilities _ mEdit _ _
_ _ _ _ <- mWorkspace
+ WorkspaceEditClientCapabilities mDocChanges <- mEdit
mDocChanges
let wEdit = if supportsDocChanges
mDocChanges
let wEdit = if supportsDocChanges