Merge pull request #30 from fendor/readme-how-to-test
authorLuke Lau <luke_lau@icloud.com>
Sun, 31 Mar 2019 05:09:30 +0000 (06:09 +0100)
committerGitHub <noreply@github.com>
Sun, 31 Mar 2019 05:09:30 +0000 (06:09 +0100)
Update README to include instructions on how to run tests

.travis.yml
src/Language/Haskell/LSP/Test.hs
src/Language/Haskell/LSP/Test/Decoding.hs
src/Language/Haskell/LSP/Test/Messages.hs
stack.yaml
test/Test.hs

index 07dc18b060dbf82d137ab15c67a4eadc103c8faf..4dc2e296037b25366a75e716f617139f95aaca92 100644 (file)
@@ -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
index 1765c1f6a624ce7dee5aa571ee55109b3419e3fa..3b40842dd7ff169c69e3b1bbb3e2210a4d0eaaf0 100644 (file)
@@ -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
index 77567349053e86cce1b52e873032b8a7f3028022..2cbc41c07354f9c10f81ab902379085e52d5ed72 100644 (file)
@@ -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
index 4c1141d113d91103b0cd74752888a3a8d6a0f97b..02fa7fc41dd2f6e7dec83cfd3a9cfc59d3a0694a 100644 (file)
@@ -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
index 0c1d999cf218b8d3e0d8e3b4eb4b91eff1c3fbb9..119fa6a1bf115cc70297ec65b502bcca4c27d7a1 100644 (file)
@@ -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
index f73c18606bee24d24d86c70347d3bfc81c61c5dd..0fc2f53f73d2511b480a83b7ef770e83ba9acba9 100644 (file)
@@ -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"