Skip to content

Commit 276dfd3

Browse files
jhrcekmichaelpj
andauthored
Fix -Wall and -Wunused-packages in code-range plugin (#3980)
Co-authored-by: Michael Peyton Jones <[email protected]>
1 parent 665854f commit 276dfd3

File tree

5 files changed

+15
-22
lines changed

5 files changed

+15
-22
lines changed

plugins/hls-code-range-plugin/hls-code-range-plugin.cabal

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,19 @@ source-repository head
2222
type: git
2323
location: https://github.com/haskell/haskell-language-server.git
2424

25+
common warnings
26+
ghc-options: -Wall -Wunused-packages
27+
2528
library
29+
import: warnings
2630
exposed-modules:
2731
Ide.Plugin.CodeRange
2832
Ide.Plugin.CodeRange.Rules
2933
other-modules:
3034
Ide.Plugin.CodeRange.ASTPreProcess
31-
ghc-options: -Wall
3235
hs-source-dirs: src
3336
default-language: Haskell2010
3437
build-depends:
35-
, aeson
3638
, base >=4.12 && <5
3739
, containers
3840
, deepseq
@@ -44,11 +46,11 @@ library
4446
, lsp
4547
, mtl
4648
, semigroupoids
47-
, text
4849
, transformers
4950
, vector
5051

5152
test-suite tests
53+
import: warnings
5254
type: exitcode-stdio-1.0
5355
default-language: Haskell2010
5456
hs-source-dirs: test
@@ -60,16 +62,11 @@ test-suite tests
6062
build-depends:
6163
, base
6264
, bytestring
63-
, containers
6465
, filepath
65-
, ghcide == 2.6.0.0
6666
, hls-code-range-plugin
67-
, hls-plugin-api
6867
, hls-test-utils == 2.6.0.0
6968
, lens
7069
, lsp
7170
, lsp-test
72-
, tasty-hunit
73-
, text
7471
, transformers
7572
, vector

plugins/hls-code-range-plugin/src/Ide/Plugin/CodeRange.hs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{-# LANGUAGE DataKinds #-}
22
{-# LANGUAGE ExistentialQuantification #-}
3-
{-# LANGUAGE LambdaCase #-}
43
{-# LANGUAGE OverloadedStrings #-}
54
{-# LANGUAGE RecordWildCards #-}
65
{-# LANGUAGE ScopedTypeVariables #-}
@@ -63,11 +62,11 @@ descriptor recorder plId = (defaultPluginDescriptor plId "Provides selection and
6362
, pluginRules = codeRangeRule (cmapWithPrio LogRules recorder)
6463
}
6564

66-
data Log = LogRules Rules.Log
65+
newtype Log = LogRules Rules.Log
6766

6867
instance Pretty Log where
69-
pretty log = case log of
70-
LogRules codeRangeLog -> pretty codeRangeLog
68+
pretty (LogRules codeRangeLog) = pretty codeRangeLog
69+
7170

7271
foldingRangeHandler :: Recorder (WithPriority Log) -> PluginMethodHandler IdeState 'Method_TextDocumentFoldingRange
7372
foldingRangeHandler _ ide _ FoldingRangeParams{..} =

plugins/hls-code-range-plugin/test/Ide/Plugin/CodeRange/RulesTest.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
module Ide.Plugin.CodeRange.RulesTest (testTree) where
44

55
import Control.Monad.Trans.Writer.CPS
6-
import Data.Bifunctor (Bifunctor (first, second))
6+
import Data.Bifunctor (Bifunctor (second))
77
import qualified Data.Vector as V
88
import Ide.Plugin.CodeRange.Rules
99
import Test.Hls
10-
import Test.Tasty.HUnit
1110

1211
testTree :: TestTree
1312
testTree =
@@ -78,3 +77,4 @@ instance Eq LogEq where
7877
LogEq LogNoAST == LogEq LogNoAST = True
7978
LogEq (LogFoundInterleaving left right) == LogEq (LogFoundInterleaving left' right') =
8079
left == left' && right == right'
80+
LogEq _ == LogEq _ = False

plugins/hls-code-range-plugin/test/Ide/Plugin/CodeRangeTest.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import qualified Data.Vector as V
66
import Ide.Plugin.CodeRange
77
import Ide.Plugin.CodeRange.Rules
88
import Test.Hls
9-
import Test.Tasty.HUnit
109

1110
testTree :: TestTree
1211
testTree =

plugins/hls-code-range-plugin/test/Main.hs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,10 @@ import Control.Lens hiding (List, (<.>))
66
import Data.ByteString.Lazy (ByteString)
77
import qualified Data.ByteString.Lazy.Char8 as LBSChar8
88
import Data.String (fromString)
9-
import Ide.Logger (Priority (Debug),
10-
Recorder (Recorder),
11-
WithPriority (WithPriority),
12-
makeDefaultStderrRecorder,
13-
pretty)
149
import Ide.Plugin.CodeRange (Log, descriptor)
1510
import qualified Ide.Plugin.CodeRange.RulesTest
1611
import qualified Ide.Plugin.CodeRangeTest
17-
import Language.LSP.Protocol.Lens
12+
import Language.LSP.Protocol.Lens (result)
1813
import Language.LSP.Protocol.Message
1914
import Language.LSP.Protocol.Types
2015
import System.FilePath ((<.>), (</>))
@@ -89,7 +84,10 @@ foldingRangeGoldenTest testName = goldenGitDiff testName (testDataDir </> testN
8984
showFoldingRangesForTest foldingRanges = (LBSChar8.intercalate "\n" $ fmap showFoldingRangeForTest foldingRanges) `LBSChar8.snoc` '\n'
9085

9186
showFoldingRangeForTest :: FoldingRange -> ByteString
92-
showFoldingRangeForTest f@(FoldingRange sl (Just sc) el (Just ec) (Just frk) _) = "((" <> showLBS sl <>", "<> showLBS sc <> ")" <> " : " <> "(" <> showLBS el <>", "<> showLBS ec<> ")) : " <> showFRK frk
87+
showFoldingRangeForTest (FoldingRange sl (Just sc) el (Just ec) (Just frk) _) =
88+
"((" <> showLBS sl <> ", " <> showLBS sc <> ") : (" <> showLBS el <> ", " <> showLBS ec <> ")) : " <> showFRK frk
89+
showFoldingRangeForTest fr =
90+
"unexpected FoldingRange: " <> fromString (show fr)
9391

9492
showLBS = fromString . show
9593
showFRK = fromString . show

0 commit comments

Comments
 (0)