Skip to content

Commit 6620f2c

Browse files
jhrcekmergify[bot]
andauthored
Fix -Wall and -Wunused-packages in eval plugin (#3981)
* Fix -Wall and -Wunused-packages in eval plugin * Ah, so that's why -Wno-unticked-promoted-constructors * stylish-haskell * Fix pre-commit check --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 78f510e commit 6620f2c

File tree

3 files changed

+29
-37
lines changed

3 files changed

+29
-37
lines changed

plugins/hls-class-plugin/src/Ide/Plugin/Class/Types.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
{-# LANGUAGE CPP #-}
12
{-# LANGUAGE DeriveAnyClass #-}
23
{-# LANGUAGE DeriveGeneric #-}
34
{-# LANGUAGE FlexibleContexts #-}
45
{-# LANGUAGE LambdaCase #-}
56
{-# LANGUAGE RecordWildCards #-}
67
{-# LANGUAGE TypeFamilies #-}
78
{-# LANGUAGE ViewPatterns #-}
8-
{-# LANGUAGE CPP #-}
99

1010
module Ide.Plugin.Class.Types where
1111

plugins/hls-eval-plugin/hls-eval-plugin.cabal

+6-12
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ source-repository head
3636
type: git
3737
location: https://github.com/haskell/haskell-language-server
3838

39+
common warnings
40+
ghc-options:
41+
-Wall -Wunused-packages -Wno-name-shadowing -Wno-unticked-promoted-constructors -fno-ignore-asserts
42+
3943
library
44+
import: warnings
4045
exposed-modules:
4146
Ide.Plugin.Eval
4247
Ide.Plugin.Eval.Types
@@ -57,18 +62,14 @@ library
5762
, base >=4.12 && <5
5863
, bytestring
5964
, containers
60-
, data-default
6165
, deepseq
6266
, Diff ^>=0.4.0
63-
, directory
6467
, dlist
6568
, extra
6669
, filepath
6770
, ghc
6871
, ghc-boot-th
69-
, ghc-paths
7072
, ghcide == 2.6.0.0
71-
, hashable
7273
, hls-graph
7374
, hls-plugin-api == 2.6.0.0
7475
, lens
@@ -77,18 +78,11 @@ library
7778
, megaparsec >=9.0
7879
, mtl
7980
, parser-combinators >=1.2
80-
, pretty-simple
81-
, QuickCheck
82-
, safe-exceptions
8381
, text
84-
, time
8582
, transformers
8683
, unliftio
8784
, unordered-containers
8885

89-
ghc-options:
90-
-Wall -Wno-name-shadowing -Wno-unticked-promoted-constructors -fno-ignore-asserts
91-
9286
if flag(pedantic)
9387
ghc-options: -Werror
9488

@@ -98,6 +92,7 @@ library
9892
TypeOperators
9993

10094
test-suite tests
95+
import: warnings
10196
type: exitcode-stdio-1.0
10297
default-language: Haskell2010
10398
hs-source-dirs: test
@@ -107,7 +102,6 @@ test-suite tests
107102
, aeson
108103
, base
109104
, containers
110-
, directory
111105
, extra
112106
, filepath
113107
, hls-eval-plugin

plugins/hls-eval-plugin/test/Main.hs

+22-24
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,25 @@ module Main
88
( main
99
) where
1010

11-
import Control.Lens (_Just, folded, preview,
12-
toListOf, view, (^..))
13-
import Data.Aeson (Value (Object), fromJSON,
14-
object, toJSON, (.=))
15-
import Data.Aeson.Types (Pair, Result (Success))
16-
import Data.List (isInfixOf)
17-
import Data.List.Extra (nubOrdOn)
18-
import qualified Data.Map as Map
11+
import Control.Lens (_Just, folded, preview, view, (^.),
12+
(^..))
13+
import Data.Aeson (Value (Object), fromJSON, object,
14+
(.=))
15+
import Data.Aeson.Types (Pair, Result (Success))
16+
import Data.List (isInfixOf)
17+
import Data.List.Extra (nubOrdOn)
18+
import qualified Data.Map as Map
1919
import Data.Row
20-
import qualified Data.Text as T
21-
import Ide.Plugin.Config (Config)
22-
import qualified Ide.Plugin.Config as Plugin
23-
import qualified Ide.Plugin.Eval as Eval
24-
import Ide.Plugin.Eval.Types (EvalParams (..), Section (..),
25-
testOutput)
26-
import Ide.Types (IdePlugins (IdePlugins))
27-
import Language.LSP.Protocol.Lens (arguments, command, range,
28-
title)
29-
import Language.LSP.Protocol.Message hiding (error)
30-
import System.FilePath ((<.>), (</>))
20+
import qualified Data.Text as T
21+
import Ide.Plugin.Config (Config)
22+
import qualified Ide.Plugin.Config as Plugin
23+
import qualified Ide.Plugin.Eval as Eval
24+
import Ide.Plugin.Eval.Types (EvalParams (..), Section (..),
25+
testOutput)
26+
import Language.LSP.Protocol.Lens (command, range, title)
27+
import System.FilePath ((<.>), (</>))
3128
import Test.Hls
32-
import qualified Test.Hls.FileSystem as FS
29+
import qualified Test.Hls.FileSystem as FS
3330

3431
main :: IO ()
3532
main = defaultTestRunner tests
@@ -215,16 +212,17 @@ tests =
215212
, testCase "Interfaces are reused after Eval" $ do
216213
runSessionWithServerInTmpDir def evalPlugin (mkFs $ FS.directProjectMulti ["TLocalImport.hs", "Util.hs"]) $ do
217214
doc <- openDoc "TLocalImport.hs" "haskell"
218-
waitForTypecheck doc
215+
_ <- waitForTypecheck doc
219216
lenses <- getCodeLenses doc
220-
let ~cmds@[cmd] = lenses^..folded.command._Just
221-
liftIO $ cmds^..folded.title @?= ["Evaluate..."]
217+
cmd <- liftIO $ case lenses^..folded.command._Just of
218+
[cmd] -> (cmd^.title @?= "Evaluate...") >> pure cmd
219+
cmds -> assertFailure $ "Expected a single command, got " <> show (length cmds)
222220

223221
executeCmd cmd
224222

225223
-- trigger a rebuild and check that dependency interfaces are not rebuilt
226224
changeDoc doc []
227-
waitForTypecheck doc
225+
_ <- waitForTypecheck doc
228226
Right keys <- getLastBuildKeys
229227
let ifaceKeys = filter ("GetModIface" `T.isPrefixOf`) keys
230228
liftIO $ ifaceKeys @?= []

0 commit comments

Comments
 (0)