From c6e68648c1e3b586e1ee8b0dcda1485ff5ae28ba Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Wed, 11 Jul 2018 01:51:31 +0100 Subject: [PATCH] Reexport modules via cabal Remove redundant dependencies Supress some hlints Prep cabal file --- .gitignore | 5 +++++ README.md | 8 ++++---- example/Main.hs | 4 ++-- haskell-lsp-test.cabal | 15 +++++---------- src/Language/Haskell/LSP/Test.hs | 20 -------------------- src/Language/Haskell/LSP/Test/Parsing.hs | 5 ++--- test/Test.hs | 10 +++++++--- 7 files changed, 25 insertions(+), 42 deletions(-) diff --git a/.gitignore b/.gitignore index 730460f..93b38a2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,8 @@ .stack-work +dist +dist-newstyle +cabal.project.local* +.ghc.environment.* **/.DS_Store *.swp + diff --git a/README.md b/README.md index 0af386e..dd71506 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,8 @@ runSession "session/root/dir" $ do skipMany notification - sendRequest TextDocumentDocumentSymbol (DocumentSymbolParams doc) - - rspSymbols <- response :: DocumentSymbolsResponse - let (List symbols) = fromJust (rspSymbols ^. result) + symbols <- getDocumentSymbols doc ``` + +## Developing +To test make sure you have [haskell-ide-engine](https://github.com/haskell/haskell-ide-engine) installed. diff --git a/example/Main.hs b/example/Main.hs index 0318ce8..c992b8e 100644 --- a/example/Main.hs +++ b/example/Main.hs @@ -1,8 +1,8 @@ +import Control.Applicative.Combinators +import Control.Monad.IO.Class import Language.Haskell.LSP.Test import Language.Haskell.LSP.Types -import Control.Monad.IO.Class - main = runSession "hie --lsp" "test/recordings/renamePass" $ do docItem <- openDoc "Desktop/simple.hs" "haskell" diff --git a/haskell-lsp-test.cabal b/haskell-lsp-test.cabal index 9c21b77..860c29b 100644 --- a/haskell-lsp-test.cabal +++ b/haskell-lsp-test.cabal @@ -19,12 +19,14 @@ library hs-source-dirs: src exposed-modules: Language.Haskell.LSP.Test , Language.Haskell.LSP.Test.Replay + reexported-modules: haskell-lsp:Language.Haskell.LSP.Types + , haskell-lsp:Language.Haskell.LSP.Types.Capabilities + , parser-combinators:Control.Applicative.Combinators default-language: Haskell2010 build-depends: base >= 4.7 && < 5 , haskell-lsp >= 0.4 , aeson , ansi-terminal - , async , bytestring , conduit , conduit-parse @@ -63,23 +65,16 @@ test-suite tests , hspec , lens , data-default - , directory - , haskell-lsp-test , haskell-lsp >= 0.4 - , conduit - , conduit-parse + , haskell-lsp-test , aeson , unordered-containers , text default-language: Haskell2010 -executable example +executable lsp-test-example hs-source-dirs: example main-is: Main.hs default-language: Haskell2010 build-depends: base >= 4.7 && < 5 , haskell-lsp-test - , haskell-lsp >= 0.4 - , lens - , text - , directory diff --git a/src/Language/Haskell/LSP/Test.hs b/src/Language/Haskell/LSP/Test.hs index 427b617..3ba8690 100644 --- a/src/Language/Haskell/LSP/Test.hs +++ b/src/Language/Haskell/LSP/Test.hs @@ -39,25 +39,6 @@ module Language.Haskell.LSP.Test , loggingNotification , publishDiagnosticsNotification -- * Combinators - , choice - , option - , optional - , between - , some - , many - , sepBy - , sepBy1 - , sepEndBy1 - , sepEndBy - , endBy1 - , endBy - , count - , manyTill - , skipMany - , skipSome - , skipManyTill - , skipSomeTill - , (<|>) , satisfy -- * Utilities , initializeResponse @@ -83,7 +64,6 @@ module Language.Haskell.LSP.Test , applyEdit ) where -import Control.Applicative import Control.Applicative.Combinators import Control.Concurrent import Control.Monad diff --git a/src/Language/Haskell/LSP/Test/Parsing.hs b/src/Language/Haskell/LSP/Test/Parsing.hs index 3ecc538..36349da 100644 --- a/src/Language/Haskell/LSP/Test/Parsing.hs +++ b/src/Language/Haskell/LSP/Test/Parsing.hs @@ -53,9 +53,8 @@ satisfy pred = do message :: forall a. (Typeable a, FromJSON a) => Session a message = let parser = decode . encodeMsg :: FromServerMessage -> Maybe a - in named (T.pack $ show $ head $ snd $ splitTyConApp $ last $ typeRepArgs $ typeOf parser) $ do - x <- satisfy (isJust . parser) - return $ castMsg x + in named (T.pack $ show $ head $ snd $ splitTyConApp $ last $ typeRepArgs $ typeOf parser) $ + castMsg <$> satisfy (isJust . parser) -- | Matches if the message is a notification. anyNotification :: Session FromServerMessage diff --git a/test/Test.hs b/test/Test.hs index 845f6e4..1a09b29 100644 --- a/test/Test.hs +++ b/test/Test.hs @@ -8,6 +8,7 @@ import Data.Aeson import Data.Default import qualified Data.HashMap.Strict as HM import qualified Data.Text as T +import Control.Applicative.Combinators import Control.Concurrent import Control.Monad.IO.Class import Control.Monad @@ -17,9 +18,12 @@ import Language.Haskell.LSP.Messages import Language.Haskell.LSP.Test import Language.Haskell.LSP.Test.Replay import Language.Haskell.LSP.Types.Capabilities -import Language.Haskell.LSP.Types hiding (message, capabilities) +import Language.Haskell.LSP.Types hiding (capabilities, message) import System.Timeout +{-# ANN module ("HLint: ignore Reduce duplication" :: String) #-} +{-# ANN module ("HLint: ignore Unnecessary hiding" :: String) #-} + main = hspec $ do describe "Session" $ do it "fails a test" $ @@ -157,7 +161,7 @@ main = hspec $ do noDiagnostics contents <- documentContents doc - liftIO $ contents `shouldBe` "main :: IO Int\nmain = return 42" + liftIO $ contents `shouldBe` "main :: IO Int\nmain = return 42\n" describe "getDocumentEdit" $ it "automatically consumes applyedit requests" $ @@ -170,7 +174,7 @@ main = hspec $ do reqParams = ExecuteCommandParams "applyrefact:applyOne" (Just (List [args])) sendRequest_ WorkspaceExecuteCommand reqParams contents <- getDocumentEdit doc - liftIO $ contents `shouldBe` "main :: IO Int\nmain = return 42" + liftIO $ contents `shouldBe` "main :: IO Int\nmain = return 42\n" noDiagnostics describe "getAllCodeActions" $ -- 2.30.2