X-Git-Url: http://git.lukelau.me/?a=blobdiff_plain;f=src%2FLanguage%2FHaskell%2FLSP%2FTest.hs;h=6156b003dd53876406a592e4278dbe88cfcd98f8;hb=d54524be6dd2b0b2d20530afd7049f22b33129d5;hp=1765c1f6a624ce7dee5aa571ee55109b3419e3fa;hpb=c11f5798ff6f9634e24c6521eb01d03a27e718ac;p=lsp-test.git diff --git a/src/Language/Haskell/LSP/Test.hs b/src/Language/Haskell/LSP/Test.hs index 1765c1f..6156b00 100644 --- a/src/Language/Haskell/LSP/Test.hs +++ b/src/Language/Haskell/LSP/Test.hs @@ -65,6 +65,7 @@ module Language.Haskell.LSP.Test , getReferences -- ** Definitions , getDefinitions + , getTypeDefinitions -- ** Renaming , rename -- ** Hover @@ -107,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. -- @@ -350,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 @@ -435,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) @@ -448,7 +449,7 @@ applyEdit doc edit = do caps <- asks sessionCapabilities let supportsDocChanges = fromMaybe False $ do - let C.ClientCapabilities mWorkspace _ _ = caps + let mWorkspace = C._workspace caps C.WorkspaceClientCapabilities _ mEdit _ _ _ _ _ _ <- mWorkspace C.WorkspaceEditClientCapabilities mDocChanges <- mEdit mDocChanges @@ -494,6 +495,14 @@ getDefinitions doc pos = let params = TextDocumentPositionParams doc pos in getResponseResult <$> request TextDocumentDefinition params +-- | Returns the type definition(s) for the term at the specified position. +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 = + let params = TextDocumentPositionParams doc pos + in getResponseResult <$> request TextDocumentTypeDefinition params + -- | Renames the term at the specified position. rename :: TextDocumentIdentifier -> Position -> String -> Session () rename doc pos newName = do