From: Luke Lau Date: Sun, 31 Mar 2019 05:09:30 +0000 (+0100) Subject: Merge pull request #30 from fendor/readme-how-to-test X-Git-Tag: 0.5.1.2~6 X-Git-Url: http://git.lukelau.me/?p=lsp-test.git;a=commitdiff_plain;h=1f51fec9ecd311a0684edf5c15238d2435a95090;hp=f8de45b8e1d90be9512f7cbefbefa79b821cc2a9 Merge pull request #30 from fendor/readme-how-to-test Update README to include instructions on how to run tests --- diff --git a/.travis.yml b/.travis.yml index 07dc18b..4dc2e29 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,12 +23,12 @@ before_install: - git init - git remote add origin https://github.com/haskell/haskell-ide-engine.git - git pull origin master - - git checkout 890ca3f2f3bd3bfe74e1f38a426b383a847763bb + - git checkout 89988b66a7b2d305740a9a085009a21fd4c80adf - git submodule init - git submodule sync - git submodule update --init - - stack --no-terminal --skip-ghc-check -j2 install --stack-yaml=stack-8.6.2.yaml - - stack exec hoogle generate --stack-yaml=stack-8.6.2.yaml + - stack --no-terminal --skip-ghc-check -j2 install + - stack exec hoogle generate - cd $TRAVIS_BUILD_DIR - npm update - npm i -g javascript-typescript-langserver diff --git a/src/Language/Haskell/LSP/Test.hs b/src/Language/Haskell/LSP/Test.hs index 1765c1f..3b40842 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 @@ -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 diff --git a/src/Language/Haskell/LSP/Test/Decoding.hs b/src/Language/Haskell/LSP/Test/Decoding.hs index 7756734..2cbc41c 100644 --- a/src/Language/Haskell/LSP/Test/Decoding.hs +++ b/src/Language/Haskell/LSP/Test/Decoding.hs @@ -72,6 +72,7 @@ getRequestMap = foldl helper HM.empty (ReqCompletionItemResolve val) -> insert val acc (ReqSignatureHelp val) -> insert val acc (ReqDefinition val) -> insert val acc + (ReqTypeDefinition val) -> insert val acc (ReqFindReferences val) -> insert val acc (ReqDocumentHighlights val) -> insert val acc (ReqDocumentSymbols val) -> insert val acc @@ -99,6 +100,7 @@ matchResponseMsgType req = case req of CompletionItemResolve -> RspCompletionItemResolve . decoded TextDocumentSignatureHelp -> RspSignatureHelp . decoded TextDocumentDefinition -> RspDefinition . decoded + TextDocumentTypeDefinition -> RspTypeDefinition . decoded TextDocumentReferences -> RspFindReferences . decoded TextDocumentDocumentHighlight -> RspDocumentHighlights . decoded TextDocumentDocumentSymbol -> RspDocumentSymbols . decoded diff --git a/src/Language/Haskell/LSP/Test/Messages.hs b/src/Language/Haskell/LSP/Test/Messages.hs index 4c1141d..02fa7fc 100644 --- a/src/Language/Haskell/LSP/Test/Messages.hs +++ b/src/Language/Haskell/LSP/Test/Messages.hs @@ -13,6 +13,7 @@ isServerResponse (RspCompletion _) = True isServerResponse (RspCompletionItemResolve _) = True isServerResponse (RspSignatureHelp _) = True isServerResponse (RspDefinition _) = True +isServerResponse (RspTypeDefinition _) = True isServerResponse (RspFindReferences _) = True isServerResponse (RspDocumentHighlights _) = True isServerResponse (RspDocumentSymbols _) = True diff --git a/stack.yaml b/stack.yaml index 0c1d999..119fa6a 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,7 +1,4 @@ -resolver: nightly-2018-12-01 +resolver: lts-13.9 packages: - . -extra-deps: - - haskell-lsp-0.8.0.1 - - haskell-lsp-types-0.8.0.1 diff --git a/test/Test.hs b/test/Test.hs index f73c186..0fc2f53 100644 --- a/test/Test.hs +++ b/test/Test.hs @@ -259,6 +259,13 @@ main = hspec $ do defs <- getDefinitions doc pos liftIO $ defs `shouldBe` [Location (doc ^. uri) (mkRange 28 0 28 7)] + -- describe "getTypeDefinitions" $ + -- it "works" $ runSession "hie" fullCaps "test/data/renamePass" $ do + -- doc <- openDoc "Desktop/simple.hs" "haskell" + -- let pos = Position 20 23 -- Quit value + -- defs <- getTypeDefinitions doc pos + -- liftIO $ defs `shouldBe` [Location (doc ^. uri) (mkRange 10 5 10 12)] -- Type definition + describe "waitForDiagnosticsSource" $ it "works" $ runSession "hie" fullCaps "test/data" $ do openDoc "Error.hs" "haskell"