projects
/
lsp-test.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #84 from wz1000/progress
[lsp-test.git]
/
src
/
Language
/
Haskell
/
LSP
/
Test.hs
diff --git
a/src/Language/Haskell/LSP/Test.hs
b/src/Language/Haskell/LSP/Test.hs
index 761151e8ac9f282d9b8652f4b70a0ee29fbf4cbe..19baf9671458b8540cbaa7683cd68c6afac6a6e1 100644
(file)
--- a/
src/Language/Haskell/LSP/Test.hs
+++ b/
src/Language/Haskell/LSP/Test.hs
@@
-56,6
+56,7
@@
module Language.Haskell.LSP.Test
, waitForDiagnosticsSource
, noDiagnostics
, getCurrentDiagnostics
, waitForDiagnosticsSource
, noDiagnostics
, getCurrentDiagnostics
+ , getIncompleteProgressSessions
-- ** Commands
, executeCommand
-- ** Code Actions
-- ** Commands
, executeCommand
-- ** Code Actions
@@
-93,6
+94,7
@@
import Control.Monad.IO.Class
import Control.Exception
import Control.Lens hiding ((.=), List)
import qualified Data.Map.Strict as Map
import Control.Exception
import Control.Lens hiding ((.=), List)
import qualified Data.Map.Strict as Map
+import qualified Data.Set as Set
import qualified Data.Text as T
import qualified Data.Text.IO as T
import Data.Aeson
import qualified Data.Text as T
import qualified Data.Text.IO as T
import Data.Aeson
@@
-399,7
+401,7
@@
createDoc file languageId contents = do
when shouldSend $
sendNotification WorkspaceDidChangeWatchedFiles $ DidChangeWatchedFilesParams $
when shouldSend $
sendNotification WorkspaceDidChangeWatchedFiles $ DidChangeWatchedFilesParams $
- List [ FileEvent (filePathToUri
file
) FcCreated ]
+ List [ FileEvent (filePathToUri
(rootDir </> file)
) FcCreated ]
openDoc' file languageId contents
-- | Opens a text document that /exists on disk/, and sends a
openDoc' file languageId contents
-- | Opens a text document that /exists on disk/, and sends a
@@
-517,6
+519,10
@@
getCodeActionContext doc = do
getCurrentDiagnostics :: TextDocumentIdentifier -> Session [Diagnostic]
getCurrentDiagnostics doc = fromMaybe [] . Map.lookup (toNormalizedUri $ doc ^. uri) . curDiagnostics <$> get
getCurrentDiagnostics :: TextDocumentIdentifier -> Session [Diagnostic]
getCurrentDiagnostics doc = fromMaybe [] . Map.lookup (toNormalizedUri $ doc ^. uri) . curDiagnostics <$> get
+-- | Returns the tokens of all progress sessions that have started but not yet ended.
+getIncompleteProgressSessions :: Session (Set.Set ProgressToken)
+getIncompleteProgressSessions = curProgressSessions <$> get
+
-- | Executes a command.
executeCommand :: Command -> Session ()
executeCommand cmd = do
-- | Executes a command.
executeCommand :: Command -> Session ()
executeCommand cmd = do
@@
-611,9
+617,12
@@
getDefinitions doc pos = do
getTypeDefinitions :: TextDocumentIdentifier -- ^ The document the term is in.
-> Position -- ^ The position the term is at.
-> Session [Location] -- ^ The location(s) of the definitions
getTypeDefinitions :: TextDocumentIdentifier -- ^ The document the term is in.
-> Position -- ^ The position the term is at.
-> Session [Location] -- ^ The location(s) of the definitions
-getTypeDefinitions doc pos =
+getTypeDefinitions doc pos =
do
let params = TextDocumentPositionParams doc pos Nothing
let params = TextDocumentPositionParams doc pos Nothing
- in getResponseResult <$> request TextDocumentTypeDefinition params
+ rsp <- request TextDocumentTypeDefinition params :: Session TypeDefinitionResponse
+ case getResponseResult rsp of
+ SingleLoc loc -> pure [loc]
+ MultiLoc locs -> pure locs
-- | Renames the term at the specified position.
rename :: TextDocumentIdentifier -> Position -> String -> Session ()
-- | Renames the term at the specified position.
rename :: TextDocumentIdentifier -> Position -> String -> Session ()
@@
-661,6
+670,7
@@
formatRange doc opts range = do
applyTextEdits :: TextDocumentIdentifier -> List TextEdit -> Session ()
applyTextEdits doc edits =
let wEdit = WorkspaceEdit (Just (HashMap.singleton (doc ^. uri) edits)) Nothing
applyTextEdits :: TextDocumentIdentifier -> List TextEdit -> Session ()
applyTextEdits doc edits =
let wEdit = WorkspaceEdit (Just (HashMap.singleton (doc ^. uri) edits)) Nothing
+ -- Send a dummy message to updateState so it can do bookkeeping
req = RequestMessage "" (IdInt 0) WorkspaceApplyEdit (ApplyWorkspaceEditParams wEdit)
in updateState (ReqApplyWorkspaceEdit req)
req = RequestMessage "" (IdInt 0) WorkspaceApplyEdit (ApplyWorkspaceEditParams wEdit)
in updateState (ReqApplyWorkspaceEdit req)