Skip to content

Fix -Wall and -Wunused-package in gadt plugin #4008

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions plugins/hls-gadt-plugin/hls-gadt-plugin.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@ source-repository head
type: git
location: https://github.com/haskell/haskell-language-server.git

common warnings
ghc-options:
-Wall
-Wunused-packages
-Wno-name-shadowing
-Wno-unticked-promoted-constructors

library
import: warnings
exposed-modules: Ide.Plugin.GADT
other-modules: Ide.Plugin.GHC

Expand All @@ -31,7 +39,6 @@ library
, extra
, ghc
, ghcide == 2.6.0.0
, ghc-boot-th
, ghc-exactprint
, hls-plugin-api == 2.6.0.0
, hls-refactor-plugin
Expand All @@ -40,16 +47,12 @@ library
, mtl
, text
, transformers
, unordered-containers

ghc-options:
-Wall
-Wno-name-shadowing
-Wno-unticked-promoted-constructors
default-language: Haskell2010
default-extensions: DataKinds

test-suite tests
import: warnings
type: exitcode-stdio-1.0
default-language: Haskell2010
hs-source-dirs: test
Expand All @@ -60,7 +63,4 @@ test-suite tests
, filepath
, hls-gadt-plugin
, hls-test-utils == 2.6.0.0
, lens
, lsp
, lsp-test
, text
8 changes: 4 additions & 4 deletions plugins/hls-gadt-plugin/src/Ide/Plugin/GADT.hs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ toGADTSyntaxCommandId = "GADT.toGADT"
-- | A command replaces H98 data decl with GADT decl in place
toGADTCommand :: PluginId -> CommandFunction IdeState ToGADTParams
toGADTCommand pId@(PluginId pId') state ToGADTParams{..} = withExceptT handleGhcidePluginError $ do
nfp <- withExceptT (GhcidePluginErrors) $ getNormalizedFilePathE uri
nfp <- withExceptT GhcidePluginErrors $ getNormalizedFilePathE uri
(decls, exts) <- getInRangeH98DeclsAndExts state range nfp
(L ann decl) <- case decls of
[d] -> pure d
Expand Down Expand Up @@ -88,7 +88,7 @@ toGADTCommand pId@(PluginId pId') state ToGADTParams{..} = withExceptT handleGhc

codeActionHandler :: PluginMethodHandler IdeState Method_TextDocumentCodeAction
codeActionHandler state plId (CodeActionParams _ _ doc range _) = withExceptT handleGhcidePluginError $ do
nfp <- withExceptT (GhcidePluginErrors) $ getNormalizedFilePathE (doc ^. L.uri)
nfp <- withExceptT GhcidePluginErrors $ getNormalizedFilePathE (doc ^. L.uri)
(inRangeH98Decls, _) <- getInRangeH98DeclsAndExts state range nfp
let actions = map (mkAction . printOutputable . tcdLName . unLoc) inRangeH98Decls
pure $ InL actions
Expand Down Expand Up @@ -138,8 +138,8 @@ handleGhcidePluginError = \case
UnexpectedNumberOfDeclarations nums -> do
PluginInternalError $ "Expected one declaration but found: " <> T.pack (show nums)
FailedToFindDataDeclRange ->
PluginInternalError $ "Unable to get data decl range"
PluginInternalError "Unable to get data decl range"
PrettyGadtError errMsg ->
PluginInternalError $ errMsg
PluginInternalError errMsg
GhcidePluginErrors errors ->
errors
13 changes: 6 additions & 7 deletions plugins/hls-gadt-plugin/src/Ide/Plugin/GHC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,17 @@
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -Wno-missing-signatures #-}
{-# OPTIONS_GHC -Wno-overlapping-patterns #-}
module Ide.Plugin.GHC where

import Data.Functor ((<&>))
import Data.List.Extra (stripInfix)
import qualified Data.List.NonEmpty as NE
import qualified Data.Text as T
import Development.IDE
import Development.IDE.GHC.Compat
import Development.IDE.GHC.Compat.ExactPrint
import Ide.PluginUtils (subRange)
import Language.Haskell.GHC.ExactPrint.Parsers (parseDecl)

import GHC.Parser.Annotation (AddEpAnn (..),
Anchor (Anchor),
AnchorOperation (MovedAnchor),
Expand All @@ -30,10 +25,14 @@ import GHC.Parser.Annotation (AddEpAnn (..),
EpaLocation (EpaDelta),
SrcSpanAnn' (SrcSpanAnn),
spanAsAnchor)
import Ide.PluginUtils (subRange)
import Language.Haskell.GHC.ExactPrint (showAst)
import Language.Haskell.GHC.ExactPrint.Parsers (parseDecl)

#if MIN_VERSION_ghc(9,5,0)
import qualified Data.List.NonEmpty as NE
import GHC.Parser.Annotation (TokenLocation (..))
#endif
import Language.Haskell.GHC.ExactPrint (showAst)

type GP = GhcPass Parsed

Expand Down Expand Up @@ -229,4 +228,4 @@ noUsed = EpAnnNotUsed
pattern UserTyVar' :: LIdP pass -> HsTyVarBndr flag pass
pattern UserTyVar' s <- UserTyVar _ _ s

implicitTyVars = (wrapXRec @GP mkHsOuterImplicit)
implicitTyVars = wrapXRec @GP mkHsOuterImplicit