Skip to content

Commit 3fa2f7c

Browse files
authored
Fix -Wall and -Wunused-package in gadt plugin (#4008)
* Fix -Wall and -Wunused-package in gadt plugin * stylish-haskell
1 parent dc9326c commit 3fa2f7c

File tree

3 files changed

+19
-20
lines changed

3 files changed

+19
-20
lines changed

plugins/hls-gadt-plugin/hls-gadt-plugin.cabal

+9-9
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,15 @@ source-repository head
1919
type: git
2020
location: https://github.com/haskell/haskell-language-server.git
2121

22+
common warnings
23+
ghc-options:
24+
-Wall
25+
-Wunused-packages
26+
-Wno-name-shadowing
27+
-Wno-unticked-promoted-constructors
28+
2229
library
30+
import: warnings
2331
exposed-modules: Ide.Plugin.GADT
2432
other-modules: Ide.Plugin.GHC
2533

@@ -31,7 +39,6 @@ library
3139
, extra
3240
, ghc
3341
, ghcide == 2.6.0.0
34-
, ghc-boot-th
3542
, ghc-exactprint
3643
, hls-plugin-api == 2.6.0.0
3744
, hls-refactor-plugin
@@ -40,16 +47,12 @@ library
4047
, mtl
4148
, text
4249
, transformers
43-
, unordered-containers
4450

45-
ghc-options:
46-
-Wall
47-
-Wno-name-shadowing
48-
-Wno-unticked-promoted-constructors
4951
default-language: Haskell2010
5052
default-extensions: DataKinds
5153

5254
test-suite tests
55+
import: warnings
5356
type: exitcode-stdio-1.0
5457
default-language: Haskell2010
5558
hs-source-dirs: test
@@ -60,7 +63,4 @@ test-suite tests
6063
, filepath
6164
, hls-gadt-plugin
6265
, hls-test-utils == 2.6.0.0
63-
, lens
64-
, lsp
65-
, lsp-test
6666
, text

plugins/hls-gadt-plugin/src/Ide/Plugin/GADT.hs

+4-4
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ toGADTSyntaxCommandId = "GADT.toGADT"
5757
-- | A command replaces H98 data decl with GADT decl in place
5858
toGADTCommand :: PluginId -> CommandFunction IdeState ToGADTParams
5959
toGADTCommand pId@(PluginId pId') state ToGADTParams{..} = withExceptT handleGhcidePluginError $ do
60-
nfp <- withExceptT (GhcidePluginErrors) $ getNormalizedFilePathE uri
60+
nfp <- withExceptT GhcidePluginErrors $ getNormalizedFilePathE uri
6161
(decls, exts) <- getInRangeH98DeclsAndExts state range nfp
6262
(L ann decl) <- case decls of
6363
[d] -> pure d
@@ -88,7 +88,7 @@ toGADTCommand pId@(PluginId pId') state ToGADTParams{..} = withExceptT handleGhc
8888

8989
codeActionHandler :: PluginMethodHandler IdeState Method_TextDocumentCodeAction
9090
codeActionHandler state plId (CodeActionParams _ _ doc range _) = withExceptT handleGhcidePluginError $ do
91-
nfp <- withExceptT (GhcidePluginErrors) $ getNormalizedFilePathE (doc ^. L.uri)
91+
nfp <- withExceptT GhcidePluginErrors $ getNormalizedFilePathE (doc ^. L.uri)
9292
(inRangeH98Decls, _) <- getInRangeH98DeclsAndExts state range nfp
9393
let actions = map (mkAction . printOutputable . tcdLName . unLoc) inRangeH98Decls
9494
pure $ InL actions
@@ -138,8 +138,8 @@ handleGhcidePluginError = \case
138138
UnexpectedNumberOfDeclarations nums -> do
139139
PluginInternalError $ "Expected one declaration but found: " <> T.pack (show nums)
140140
FailedToFindDataDeclRange ->
141-
PluginInternalError $ "Unable to get data decl range"
141+
PluginInternalError "Unable to get data decl range"
142142
PrettyGadtError errMsg ->
143-
PluginInternalError $ errMsg
143+
PluginInternalError errMsg
144144
GhcidePluginErrors errors ->
145145
errors

plugins/hls-gadt-plugin/src/Ide/Plugin/GHC.hs

+6-7
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,17 @@
55
{-# LANGUAGE PatternSynonyms #-}
66
{-# LANGUAGE RankNTypes #-}
77
{-# LANGUAGE RecordWildCards #-}
8-
{-# LANGUAGE TupleSections #-}
98
{-# LANGUAGE TypeApplications #-}
109
{-# OPTIONS_GHC -Wno-missing-signatures #-}
1110
{-# OPTIONS_GHC -Wno-overlapping-patterns #-}
1211
module Ide.Plugin.GHC where
1312

1413
import Data.Functor ((<&>))
1514
import Data.List.Extra (stripInfix)
16-
import qualified Data.List.NonEmpty as NE
1715
import qualified Data.Text as T
1816
import Development.IDE
1917
import Development.IDE.GHC.Compat
2018
import Development.IDE.GHC.Compat.ExactPrint
21-
import Ide.PluginUtils (subRange)
22-
import Language.Haskell.GHC.ExactPrint.Parsers (parseDecl)
23-
2419
import GHC.Parser.Annotation (AddEpAnn (..),
2520
Anchor (Anchor),
2621
AnchorOperation (MovedAnchor),
@@ -30,10 +25,14 @@ import GHC.Parser.Annotation (AddEpAnn (..),
3025
EpaLocation (EpaDelta),
3126
SrcSpanAnn' (SrcSpanAnn),
3227
spanAsAnchor)
28+
import Ide.PluginUtils (subRange)
29+
import Language.Haskell.GHC.ExactPrint (showAst)
30+
import Language.Haskell.GHC.ExactPrint.Parsers (parseDecl)
31+
3332
#if MIN_VERSION_ghc(9,5,0)
33+
import qualified Data.List.NonEmpty as NE
3434
import GHC.Parser.Annotation (TokenLocation (..))
3535
#endif
36-
import Language.Haskell.GHC.ExactPrint (showAst)
3736

3837
type GP = GhcPass Parsed
3938

@@ -229,4 +228,4 @@ noUsed = EpAnnNotUsed
229228
pattern UserTyVar' :: LIdP pass -> HsTyVarBndr flag pass
230229
pattern UserTyVar' s <- UserTyVar _ _ s
231230

232-
implicitTyVars = (wrapXRec @GP mkHsOuterImplicit)
231+
implicitTyVars = wrapXRec @GP mkHsOuterImplicit

0 commit comments

Comments
 (0)