From 44b99d15431c9aa00c612773478b82db3d58420a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Hr=C4=8Dek?= Date: Fri, 28 Jun 2024 08:10:14 +0200 Subject: [PATCH 1/3] Cleanup unnecessarily disabled warnings --- ghcide/src/Development/IDE/Core/Compile.hs | 4 +-- ghcide/test/data/ignore-fatal/IgnoreFatal.hs | 2 +- .../src/Ide/Plugin/Eval/Code.hs | 1 - .../src/Ide/Plugin/Eval/CodeLens.hs | 35 ++++++------------- .../src/Ide/Plugin/Eval/GHC.hs | 2 +- .../src/Ide/Plugin/Eval/Util.hs | 35 +++++++------------ .../hls-hlint-plugin/src/Ide/Plugin/Hlint.hs | 5 --- .../src/Ide/Plugin/ModuleName.hs | 2 -- src/Ide/Arguments.hs | 1 - src/Ide/Main.hs | 3 +- 10 files changed, 28 insertions(+), 62 deletions(-) diff --git a/ghcide/src/Development/IDE/Core/Compile.hs b/ghcide/src/Development/IDE/Core/Compile.hs index a9611902f1..600ea9777e 100644 --- a/ghcide/src/Development/IDE/Core/Compile.hs +++ b/ghcide/src/Development/IDE/Core/Compile.hs @@ -38,7 +38,6 @@ module Development.IDE.Core.Compile , shareUsages ) where -import Control.Concurrent.Extra import Control.Concurrent.STM.Stats hiding (orElse) import Control.DeepSeq (NFData (..), force, rnf) @@ -72,8 +71,7 @@ import Data.Tuple.Extra (dupe) import Debug.Trace import Development.IDE.Core.FileStore (resetInterfaceStore) import Development.IDE.Core.Preprocessor -import Development.IDE.Core.ProgressReporting (ProgressReporting (..), - progressReportingOutsideState) +import Development.IDE.Core.ProgressReporting (ProgressReporting (..)) import Development.IDE.Core.RuleTypes import Development.IDE.Core.Shake import Development.IDE.Core.Tracing (withTrace) diff --git a/ghcide/test/data/ignore-fatal/IgnoreFatal.hs b/ghcide/test/data/ignore-fatal/IgnoreFatal.hs index 77b11c5bb3..b73787f166 100644 --- a/ghcide/test/data/ignore-fatal/IgnoreFatal.hs +++ b/ghcide/test/data/ignore-fatal/IgnoreFatal.hs @@ -1,7 +1,7 @@ -- "missing signature" is declared a fatal warning in the cabal file, -- but is ignored in this module. -{-# OPTIONS_GHC -fno-warn-missing-signatures #-} +{-# OPTIONS_GHC -Wno-missing-signatures #-} module IgnoreFatal where diff --git a/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/Code.hs b/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/Code.hs index cc22d31da8..46044e162c 100644 --- a/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/Code.hs +++ b/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/Code.hs @@ -1,7 +1,6 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ViewPatterns #-} -{-# OPTIONS_GHC -Wwarn -fno-warn-orphans #-} -- | Expression execution module Ide.Plugin.Eval.Code (Statement, testRanges, resultRange, propSetup, testCheck, asStatements,myExecStmt) where diff --git a/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/CodeLens.hs b/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/CodeLens.hs index b3c2be60a6..34aa3b39e3 100644 --- a/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/CodeLens.hs +++ b/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/CodeLens.hs @@ -5,7 +5,7 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ViewPatterns #-} -{-# OPTIONS_GHC -fno-warn-type-defaults -Wno-unused-imports #-} +{-# OPTIONS_GHC -Wno-type-defaults #-} {- | A plugin inspired by the REPLoid feature of , 's Examples and Properties and . @@ -18,12 +18,11 @@ module Ide.Plugin.Eval.CodeLens ( ) where import Control.Applicative (Alternative ((<|>))) -import Control.Arrow (second, (>>>)) -import Control.Exception (bracket_, try) +import Control.Arrow (second) +import Control.Exception (bracket_) import qualified Control.Exception as E -import Control.Lens (_1, _3, ix, (%~), - (<&>), (^.)) -import Control.Monad (guard, join, +import Control.Lens (ix, (%~), (^.)) +import Control.Monad (guard, void, when) import Control.Monad.IO.Class (MonadIO (liftIO)) import Control.Monad.Trans.Except (ExceptT (..), @@ -44,25 +43,18 @@ import Data.Typeable (Typeable) import Development.IDE.Core.Rules (IdeState, runAction) import Development.IDE.Core.RuleTypes (LinkableResult (linkableHomeMod), - NeedsCompilation (NeedsCompilation), TypeCheck (..), tmrTypechecked) -import Development.IDE.Core.Shake (shakeExtras, - useNoFile_, - useWithStale_, +import Development.IDE.Core.Shake (useNoFile_, use_, uses_) import Development.IDE.GHC.Compat hiding (typeKind, unitState) -import Development.IDE.GHC.Compat.Util (GhcException, - OverridingBool (..), - bagToList) +import Development.IDE.GHC.Compat.Util (OverridingBool (..)) import Development.IDE.GHC.Util (evalGhcEnv, - modifyDynFlags, - printOutputable) + modifyDynFlags) import Development.IDE.Import.DependencyInformation (transitiveDeps, transitiveModuleDeps) -import Development.IDE.Types.Location (toNormalizedFilePath', - uriToFilePath') +import Development.IDE.Types.Location (toNormalizedFilePath') import GHC (ClsInst, ExecOptions (execLineNumber, execSourceFile), FamInst, @@ -87,15 +79,12 @@ import Development.IDE.Core.RuleTypes (GetLinkable (GetL ModSummaryResult (msrModSummary)) import Development.IDE.Core.Shake (VFSModified (VFSUnmodified)) import qualified Development.IDE.GHC.Compat.Core as Compat (InteractiveImport (IIModule)) -import qualified Development.IDE.GHC.Compat.Core as SrcLoc (HasSrcSpan (getLoc), - unLoc) +import qualified Development.IDE.GHC.Compat.Core as SrcLoc (unLoc) import Development.IDE.Types.HscEnvEq (HscEnvEq (hscEnv)) import qualified GHC.LanguageExtensions.Type as LangExt (Extension (..)) -import Control.Concurrent.STM.Stats (atomically) import Development.IDE.Core.FileStore (setSomethingModified) import Development.IDE.Core.PluginUtils -import Development.IDE.Graph (ShakeOptions (shakeExtra)) import Development.IDE.Types.Shake (toKey) import GHC.Types.SrcLoc (UnhelpfulSpanReason (UnhelpfulInteractive)) import Ide.Logger (Priority (..), @@ -103,7 +92,6 @@ import Ide.Logger (Priority (..), WithPriority, logWith) import Ide.Plugin.Error (PluginError (PluginInternalError), - handleMaybe, handleMaybeM) import Ide.Plugin.Eval.Code (Statement, asStatements, @@ -117,8 +105,7 @@ import Ide.Plugin.Eval.Config (EvalConfig (..), import Ide.Plugin.Eval.GHC (addImport, addPackages, hasPackage, - setSessionAndInteractiveDynFlags, - showDynFlags) + setSessionAndInteractiveDynFlags) import Ide.Plugin.Eval.Parse.Comments (commentsToSections) import Ide.Plugin.Eval.Parse.Option (parseSetFlags) import Ide.Plugin.Eval.Rules (queueForEvaluation, diff --git a/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/GHC.hs b/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/GHC.hs index 7dac1d3ce0..f0b01fca92 100644 --- a/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/GHC.hs +++ b/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/GHC.hs @@ -1,6 +1,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE LambdaCase #-} -{-# OPTIONS_GHC -fno-warn-unused-imports -Wno-orphans #-} +{-# OPTIONS_GHC -Wno-orphans #-} -- |GHC API utilities module Ide.Plugin.Eval.GHC ( diff --git a/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/Util.hs b/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/Util.hs index 175b389398..9844cb1fdc 100644 --- a/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/Util.hs +++ b/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/Util.hs @@ -1,9 +1,8 @@ -{-# LANGUAGE CPP #-} -{-# LANGUAGE NoMonomorphismRestriction #-} -{-# OPTIONS_GHC -Wno-orphans -Wno-unused-imports #-} -{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE CPP #-} +{-# LANGUAGE RecordWildCards #-} +{-# OPTIONS_GHC -Wno-orphans #-} --- |Debug utilities +-- | Debug utilities module Ide.Plugin.Eval.Util ( timed, isLiterate, @@ -15,39 +14,31 @@ module Ide.Plugin.Eval.Util ( import Control.Exception (SomeException, evaluate, fromException) -import Control.Monad.Error.Class (MonadError (throwError)) import Control.Monad.IO.Class (MonadIO (liftIO)) import Control.Monad.Trans.Class (MonadTrans (lift)) import Control.Monad.Trans.Except (ExceptT (..), runExceptT) import Data.Aeson (Value) -import Data.Bifunctor (second) import Data.String (IsString (fromString)) -import qualified Data.Text as T -import Development.IDE (IdeState, - printOutputable) -import qualified Development.IDE.Core.PluginUtils as PluginUtils -import qualified Development.IDE.GHC.Compat.Core as Core -import qualified Development.IDE.GHC.Compat.Core as SrcLoc import Development.IDE.GHC.Compat.Outputable import Development.IDE.GHC.Compat.Util (MonadCatch, bagToList, catch) -import GHC.Exts (toList) -import GHC.Stack (HasCallStack, callStack, - srcLocFile, - srcLocStartCol, - srcLocStartLine) import Ide.Plugin.Error import Ide.Types (HandlerM, pluginSendRequest) import Language.LSP.Protocol.Message import Language.LSP.Protocol.Types -import Language.LSP.Server import System.FilePath (takeExtension) import qualified System.Time.Extra as Extra -import System.Time.Extra (duration, showDuration) +import System.Time.Extra (duration) import UnliftIO.Exception (catchAny) +#if !MIN_VERSION_ghc(9,8,0) +import Development.IDE (printOutputable) +import qualified Development.IDE.GHC.Compat.Core as Core +import qualified Data.Text as T +#endif + timed :: MonadIO m => (t -> Extra.Seconds -> m a) -> t -> m b -> m b timed out name op = do (secs, r) <- duration op @@ -107,6 +98,6 @@ prettyWarnings = unlines . map prettyWarn prettyWarn :: Core.Warn -> String prettyWarn Core.Warn{..} = - T.unpack (printOutputable $ SrcLoc.getLoc warnMsg) <> ": warning:\n" - <> " " <> SrcLoc.unLoc warnMsg + T.unpack (printOutputable $ Core.getLoc warnMsg) <> ": warning:\n" + <> " " <> Core.unLoc warnMsg #endif diff --git a/plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs b/plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs index 97b9cabcae..ec20569b9d 100644 --- a/plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs +++ b/plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs @@ -13,11 +13,6 @@ {-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -Wno-orphans #-} --- On 9.4 we get a new redundant constraint warning, but deleting the --- constraint breaks the build on earlier versions. Rather than apply --- lots of CPP, we just disable the warning until later. -{-# OPTIONS_GHC -Wno-redundant-constraints #-} - #ifdef GHC_LIB #define MIN_GHC_API_VERSION(x,y,z) MIN_VERSION_ghc_lib_parser(x,y,z) #else diff --git a/plugins/hls-module-name-plugin/src/Ide/Plugin/ModuleName.hs b/plugins/hls-module-name-plugin/src/Ide/Plugin/ModuleName.hs index 8bd4a0712b..1b43c45ebe 100644 --- a/plugins/hls-module-name-plugin/src/Ide/Plugin/ModuleName.hs +++ b/plugins/hls-module-name-plugin/src/Ide/Plugin/ModuleName.hs @@ -4,8 +4,6 @@ {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ViewPatterns #-} -{-# OPTIONS_GHC -Wwarn -fno-warn-type-defaults #-} - {- | Keep the module name in sync with its file path. Provide CodeLenses to: diff --git a/src/Ide/Arguments.hs b/src/Ide/Arguments.hs index e07e059c8e..733da2e557 100644 --- a/src/Ide/Arguments.hs +++ b/src/Ide/Arguments.hs @@ -3,7 +3,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE TemplateHaskell #-} -{-# OPTIONS_GHC -Wno-dodgy-imports #-} -- GHC no longer exports def in GHC 8.6 and above module Ide.Arguments ( Arguments(..) diff --git a/src/Ide/Main.hs b/src/Ide/Main.hs index d32bb66e8e..33b1d51a11 100644 --- a/src/Ide/Main.hs +++ b/src/Ide/Main.hs @@ -1,7 +1,6 @@ -- Copyright (c) 2019 The DAML Authors. All rights reserved. -- SPDX-License-Identifier: Apache-2.0 {-# LANGUAGE CPP #-} -{-# OPTIONS_GHC -Wno-dodgy-imports #-} -- GHC no longer exports def in GHC 8.6 and above {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE TypeFamilies #-} @@ -18,7 +17,7 @@ import Data.Text (Text) import qualified Data.Text as T import Data.Text.Lazy.Encoding (decodeUtf8) import qualified Data.Text.Lazy.IO as LT -import Development.IDE.Core.Rules hiding (Log, logToPriority) +import Development.IDE.Core.Rules hiding (Log) import Development.IDE.Core.Tracing (withTelemetryRecorder) import Development.IDE.Main (isLSP) import qualified Development.IDE.Main as IDEMain From c98117833ce17ecaf609b150cb5b93a134d36e86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Hr=C4=8Dek?= Date: Fri, 28 Jun 2024 08:21:52 +0200 Subject: [PATCH 2/3] Fix stack nighly build --- plugins/hls-eval-plugin/src/Ide/Plugin/Eval/Code.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/Code.hs b/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/Code.hs index 46044e162c..e8b7428b10 100644 --- a/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/Code.hs +++ b/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/Code.hs @@ -1,6 +1,7 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ViewPatterns #-} +{-# OPTIONS_GHC -Wwarn #-} -- | Expression execution module Ide.Plugin.Eval.Code (Statement, testRanges, resultRange, propSetup, testCheck, asStatements,myExecStmt) where From 3712fb5ad8eda39896be61df754197a6c073d331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Hr=C4=8Dek?= Date: Fri, 28 Jun 2024 08:24:02 +0200 Subject: [PATCH 3/3] stylish --- plugins/hls-eval-plugin/src/Ide/Plugin/Eval/CodeLens.hs | 8 ++++---- plugins/hls-eval-plugin/src/Ide/Plugin/Eval/Util.hs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/CodeLens.hs b/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/CodeLens.hs index 34aa3b39e3..bf8849a79c 100644 --- a/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/CodeLens.hs +++ b/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/CodeLens.hs @@ -22,8 +22,8 @@ import Control.Arrow (second) import Control.Exception (bracket_) import qualified Control.Exception as E import Control.Lens (ix, (%~), (^.)) -import Control.Monad (guard, - void, when) +import Control.Monad (guard, void, + when) import Control.Monad.IO.Class (MonadIO (liftIO)) import Control.Monad.Trans.Except (ExceptT (..), runExceptT) @@ -45,8 +45,8 @@ import Development.IDE.Core.Rules (IdeState, import Development.IDE.Core.RuleTypes (LinkableResult (linkableHomeMod), TypeCheck (..), tmrTypechecked) -import Development.IDE.Core.Shake (useNoFile_, - use_, uses_) +import Development.IDE.Core.Shake (useNoFile_, use_, + uses_) import Development.IDE.GHC.Compat hiding (typeKind, unitState) import Development.IDE.GHC.Compat.Util (OverridingBool (..)) diff --git a/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/Util.hs b/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/Util.hs index 9844cb1fdc..77b133ef92 100644 --- a/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/Util.hs +++ b/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/Util.hs @@ -34,9 +34,9 @@ import System.Time.Extra (duration) import UnliftIO.Exception (catchAny) #if !MIN_VERSION_ghc(9,8,0) +import qualified Data.Text as T import Development.IDE (printOutputable) import qualified Development.IDE.GHC.Compat.Core as Core -import qualified Data.Text as T #endif timed :: MonadIO m => (t -> Extra.Seconds -> m a) -> t -> m b -> m b