diff --git a/plugins/hls-code-range-plugin/hls-code-range-plugin.cabal b/plugins/hls-code-range-plugin/hls-code-range-plugin.cabal index 5ae79376cf..0ac2dcdd81 100644 --- a/plugins/hls-code-range-plugin/hls-code-range-plugin.cabal +++ b/plugins/hls-code-range-plugin/hls-code-range-plugin.cabal @@ -22,17 +22,19 @@ source-repository head type: git location: https://github.com/haskell/haskell-language-server.git +common warnings + ghc-options: -Wall -Wunused-packages + library + import: warnings exposed-modules: Ide.Plugin.CodeRange Ide.Plugin.CodeRange.Rules other-modules: Ide.Plugin.CodeRange.ASTPreProcess - ghc-options: -Wall hs-source-dirs: src default-language: Haskell2010 build-depends: - , aeson , base >=4.12 && <5 , containers , deepseq @@ -44,11 +46,11 @@ library , lsp , mtl , semigroupoids - , text , transformers , vector test-suite tests + import: warnings type: exitcode-stdio-1.0 default-language: Haskell2010 hs-source-dirs: test @@ -60,16 +62,11 @@ test-suite tests build-depends: , base , bytestring - , containers , filepath - , ghcide == 2.6.0.0 , hls-code-range-plugin - , hls-plugin-api , hls-test-utils == 2.6.0.0 , lens , lsp , lsp-test - , tasty-hunit - , text , transformers , vector diff --git a/plugins/hls-code-range-plugin/src/Ide/Plugin/CodeRange.hs b/plugins/hls-code-range-plugin/src/Ide/Plugin/CodeRange.hs index 5c4675f2fd..510b65e1d1 100644 --- a/plugins/hls-code-range-plugin/src/Ide/Plugin/CodeRange.hs +++ b/plugins/hls-code-range-plugin/src/Ide/Plugin/CodeRange.hs @@ -1,6 +1,5 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE ExistentialQuantification #-} -{-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ScopedTypeVariables #-} @@ -63,11 +62,11 @@ descriptor recorder plId = (defaultPluginDescriptor plId "Provides selection and , pluginRules = codeRangeRule (cmapWithPrio LogRules recorder) } -data Log = LogRules Rules.Log +newtype Log = LogRules Rules.Log instance Pretty Log where - pretty log = case log of - LogRules codeRangeLog -> pretty codeRangeLog + pretty (LogRules codeRangeLog) = pretty codeRangeLog + foldingRangeHandler :: Recorder (WithPriority Log) -> PluginMethodHandler IdeState 'Method_TextDocumentFoldingRange foldingRangeHandler _ ide _ FoldingRangeParams{..} = diff --git a/plugins/hls-code-range-plugin/test/Ide/Plugin/CodeRange/RulesTest.hs b/plugins/hls-code-range-plugin/test/Ide/Plugin/CodeRange/RulesTest.hs index 473d5b7f77..4dee5e039c 100644 --- a/plugins/hls-code-range-plugin/test/Ide/Plugin/CodeRange/RulesTest.hs +++ b/plugins/hls-code-range-plugin/test/Ide/Plugin/CodeRange/RulesTest.hs @@ -3,11 +3,10 @@ module Ide.Plugin.CodeRange.RulesTest (testTree) where import Control.Monad.Trans.Writer.CPS -import Data.Bifunctor (Bifunctor (first, second)) +import Data.Bifunctor (Bifunctor (second)) import qualified Data.Vector as V import Ide.Plugin.CodeRange.Rules import Test.Hls -import Test.Tasty.HUnit testTree :: TestTree testTree = @@ -78,3 +77,4 @@ instance Eq LogEq where LogEq LogNoAST == LogEq LogNoAST = True LogEq (LogFoundInterleaving left right) == LogEq (LogFoundInterleaving left' right') = left == left' && right == right' + LogEq _ == LogEq _ = False diff --git a/plugins/hls-code-range-plugin/test/Ide/Plugin/CodeRangeTest.hs b/plugins/hls-code-range-plugin/test/Ide/Plugin/CodeRangeTest.hs index 627dc28493..4db8e41d7b 100644 --- a/plugins/hls-code-range-plugin/test/Ide/Plugin/CodeRangeTest.hs +++ b/plugins/hls-code-range-plugin/test/Ide/Plugin/CodeRangeTest.hs @@ -6,7 +6,6 @@ import qualified Data.Vector as V import Ide.Plugin.CodeRange import Ide.Plugin.CodeRange.Rules import Test.Hls -import Test.Tasty.HUnit testTree :: TestTree testTree = diff --git a/plugins/hls-code-range-plugin/test/Main.hs b/plugins/hls-code-range-plugin/test/Main.hs index aebc68ca7e..b51297b893 100644 --- a/plugins/hls-code-range-plugin/test/Main.hs +++ b/plugins/hls-code-range-plugin/test/Main.hs @@ -6,15 +6,10 @@ import Control.Lens hiding (List, (<.>)) import Data.ByteString.Lazy (ByteString) import qualified Data.ByteString.Lazy.Char8 as LBSChar8 import Data.String (fromString) -import Ide.Logger (Priority (Debug), - Recorder (Recorder), - WithPriority (WithPriority), - makeDefaultStderrRecorder, - pretty) import Ide.Plugin.CodeRange (Log, descriptor) import qualified Ide.Plugin.CodeRange.RulesTest import qualified Ide.Plugin.CodeRangeTest -import Language.LSP.Protocol.Lens +import Language.LSP.Protocol.Lens (result) import Language.LSP.Protocol.Message import Language.LSP.Protocol.Types import System.FilePath ((<.>), ()) @@ -89,7 +84,10 @@ foldingRangeGoldenTest testName = goldenGitDiff testName (testDataDir testN showFoldingRangesForTest foldingRanges = (LBSChar8.intercalate "\n" $ fmap showFoldingRangeForTest foldingRanges) `LBSChar8.snoc` '\n' showFoldingRangeForTest :: FoldingRange -> ByteString - showFoldingRangeForTest f@(FoldingRange sl (Just sc) el (Just ec) (Just frk) _) = "((" <> showLBS sl <>", "<> showLBS sc <> ")" <> " : " <> "(" <> showLBS el <>", "<> showLBS ec<> ")) : " <> showFRK frk + showFoldingRangeForTest (FoldingRange sl (Just sc) el (Just ec) (Just frk) _) = + "((" <> showLBS sl <> ", " <> showLBS sc <> ") : (" <> showLBS el <> ", " <> showLBS ec <> ")) : " <> showFRK frk + showFoldingRangeForTest fr = + "unexpected FoldingRange: " <> fromString (show fr) showLBS = fromString . show showFRK = fromString . show