From e34ac21ba1446b9b195ad1f3a30849742f89115c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Hr=C4=8Dek?= Date: Tue, 23 Jan 2024 12:47:22 +0100 Subject: [PATCH 1/2] Fix -Wall and -Wunused-packages in module name and overloaded record dot plugins --- .../hls-module-name-plugin.cabal | 6 +++++- .../src/Ide/Plugin/ModuleName.hs | 3 +-- plugins/hls-module-name-plugin/test/Main.hs | 1 - .../hls-overloaded-record-dot-plugin.cabal | 10 +--------- .../src/Ide/Plugin/OverloadedRecordDot.hs | 13 +++++++------ 5 files changed, 14 insertions(+), 19 deletions(-) diff --git a/plugins/hls-module-name-plugin/hls-module-name-plugin.cabal b/plugins/hls-module-name-plugin/hls-module-name-plugin.cabal index f251571e35..671e2af351 100644 --- a/plugins/hls-module-name-plugin/hls-module-name-plugin.cabal +++ b/plugins/hls-module-name-plugin/hls-module-name-plugin.cabal @@ -23,7 +23,11 @@ source-repository head type: git location: https://github.com/haskell/haskell-language-server.git +common warnings + ghc-options: -Wall -Wunused-packages + library + import: warnings exposed-modules: Ide.Plugin.ModuleName hs-source-dirs: src build-depends: @@ -37,11 +41,11 @@ library , lsp , text , transformers - , unordered-containers default-language: Haskell2010 test-suite tests + import: warnings type: exitcode-stdio-1.0 default-language: Haskell2010 hs-source-dirs: test 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 2be69dcfcc..83f73ab4ff 100644 --- a/plugins/hls-module-name-plugin/src/Ide/Plugin/ModuleName.hs +++ b/plugins/hls-module-name-plugin/src/Ide/Plugin/ModuleName.hs @@ -2,7 +2,6 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE RecordWildCards #-} -{-# LANGUAGE TypeOperators #-} {-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -Wall -Wwarn -fno-warn-type-defaults #-} @@ -133,7 +132,7 @@ action recorder state uri = do | emptyModule -> let code = "module " <> bestName <> " where\n" in pure [Replace uri (Range (Position 0 0) (Position 0 0)) code code] - _ -> pure $ [] + _ -> pure [] -- | Possible module names, as derived by the position of the module in the -- source directories. There may be more than one possible name, if the source diff --git a/plugins/hls-module-name-plugin/test/Main.hs b/plugins/hls-module-name-plugin/test/Main.hs index ae5a87f0d5..de3e71d8be 100644 --- a/plugins/hls-module-name-plugin/test/Main.hs +++ b/plugins/hls-module-name-plugin/test/Main.hs @@ -55,7 +55,6 @@ tests = let edit = TextEdit (mkRange 1 0 1 0) "f =" _ <- applyEdit doc edit newLens <- getCodeLenses doc - txt <- documentContents doc liftIO $ newLens @?= oldLens closeDoc doc ] diff --git a/plugins/hls-overloaded-record-dot-plugin/hls-overloaded-record-dot-plugin.cabal b/plugins/hls-overloaded-record-dot-plugin/hls-overloaded-record-dot-plugin.cabal index a6c460c83d..4138cb87ec 100644 --- a/plugins/hls-overloaded-record-dot-plugin/hls-overloaded-record-dot-plugin.cabal +++ b/plugins/hls-overloaded-record-dot-plugin/hls-overloaded-record-dot-plugin.cabal @@ -19,7 +19,7 @@ source-repository head location: https://github.com/haskell/haskell-language-server common warnings - ghc-options: -Wall + ghc-options: -Wall -Wunused-packages library import: warnings @@ -35,8 +35,6 @@ library , text , syb , transformers - , ghc-boot-th - , unordered-containers , containers , deepseq hs-source-dirs: src @@ -51,13 +49,7 @@ test-suite tests build-depends: , base , filepath - , ghcide , text , hls-overloaded-record-dot-plugin - , hls-plugin-api - , lens - , lsp-test - , lsp-types - , row-types , hls-test-utils diff --git a/plugins/hls-overloaded-record-dot-plugin/src/Ide/Plugin/OverloadedRecordDot.hs b/plugins/hls-overloaded-record-dot-plugin/src/Ide/Plugin/OverloadedRecordDot.hs index 4d8a4aa3ef..d497841012 100644 --- a/plugins/hls-overloaded-record-dot-plugin/src/Ide/Plugin/OverloadedRecordDot.hs +++ b/plugins/hls-overloaded-record-dot-plugin/src/Ide/Plugin/OverloadedRecordDot.hs @@ -36,11 +36,6 @@ import Development.IDE.Core.RuleTypes (TcModuleResult (..), import Development.IDE.Core.Shake (define, useWithStale) import qualified Development.IDE.Core.Shake as Shake -#if __GLASGOW_HASKELL__ >= 903 -import Development.IDE.GHC.Compat (HsExpr (HsRecSel)) -#else -import Development.IDE.GHC.Compat (HsExpr (HsRecFld)) -#endif import Control.DeepSeq (rwhnf) import Development.IDE.Core.PluginUtils @@ -49,7 +44,13 @@ import Development.IDE.Core.PositionMapping (PositionMapping, import Development.IDE.GHC.Compat (Extension (OverloadedRecordDot), GhcPass, HsExpansion (HsExpanded), - HsExpr (HsApp, HsVar, OpApp, XExpr), + HsExpr (HsApp, HsVar, OpApp, XExpr, +#if __GLASGOW_HASKELL__ >= 903 + HsRecSel +#else + HsRecFld +#endif + ), LHsExpr, Outputable, Pass (..), appPrec, dollarName, getLoc, From 703ce33dcc6dc9ae3a4b60dd303bdf67a4d193a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Hr=C4=8Dek?= Date: Tue, 23 Jan 2024 13:41:06 +0100 Subject: [PATCH 2/2] undo import change to make stylish-haskell succeed --- .../src/Ide/Plugin/OverloadedRecordDot.hs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/plugins/hls-overloaded-record-dot-plugin/src/Ide/Plugin/OverloadedRecordDot.hs b/plugins/hls-overloaded-record-dot-plugin/src/Ide/Plugin/OverloadedRecordDot.hs index d497841012..4d8a4aa3ef 100644 --- a/plugins/hls-overloaded-record-dot-plugin/src/Ide/Plugin/OverloadedRecordDot.hs +++ b/plugins/hls-overloaded-record-dot-plugin/src/Ide/Plugin/OverloadedRecordDot.hs @@ -36,6 +36,11 @@ import Development.IDE.Core.RuleTypes (TcModuleResult (..), import Development.IDE.Core.Shake (define, useWithStale) import qualified Development.IDE.Core.Shake as Shake +#if __GLASGOW_HASKELL__ >= 903 +import Development.IDE.GHC.Compat (HsExpr (HsRecSel)) +#else +import Development.IDE.GHC.Compat (HsExpr (HsRecFld)) +#endif import Control.DeepSeq (rwhnf) import Development.IDE.Core.PluginUtils @@ -44,13 +49,7 @@ import Development.IDE.Core.PositionMapping (PositionMapping, import Development.IDE.GHC.Compat (Extension (OverloadedRecordDot), GhcPass, HsExpansion (HsExpanded), - HsExpr (HsApp, HsVar, OpApp, XExpr, -#if __GLASGOW_HASKELL__ >= 903 - HsRecSel -#else - HsRecFld -#endif - ), + HsExpr (HsApp, HsVar, OpApp, XExpr), LHsExpr, Outputable, Pass (..), appPrec, dollarName, getLoc,