From aacef4c366dfa8153226e544a80ede8fcc9a730d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Hr=C4=8Dek?= Date: Mon, 5 Feb 2024 18:46:38 +0100 Subject: [PATCH 01/10] Add -Wunused-packages to common warnings --- haskell-language-server.cabal | 94 ++++++----------------------------- 1 file changed, 15 insertions(+), 79 deletions(-) diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index 492d14e3ef..73b495b7ef 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -53,7 +53,11 @@ common common-deps -- Default warnings in HLS common warnings - ghc-options: -Wall -Wredundant-constraints -Wno-name-shadowing -Wno-unticked-promoted-constructors + ghc-options: -Wall + -Wredundant-constraints + -Wunused-packages + -Wno-name-shadowing + -Wno-unticked-promoted-constructors flag pedantic description: Enable -Werror @@ -430,7 +434,7 @@ flag importLens manual: True library hls-explicit-imports-plugin - import: defaults, warnings, pedantic + import: defaults, warnings exposed-modules: Ide.Plugin.ExplicitImports hs-source-dirs: plugins/hls-explicit-imports-plugin/src build-depends: @@ -447,13 +451,12 @@ library hls-explicit-imports-plugin , mtl , text , transformers - , unordered-containers default-extensions: DataKinds test-suite hls-explicit-imports-plugin-tests - import: defaults, test-defaults, warnings + import: defaults, pedantic, test-defaults, warnings type: exitcode-stdio-1.0 hs-source-dirs: plugins/hls-explicit-imports-plugin/test main-is: Main.hs @@ -490,8 +493,6 @@ library hls-rename-plugin , base >=4.12 && <5 , containers , extra - , ghc - , ghc-exactprint , ghcide == 2.6.0.0 , hashable , hiedb @@ -538,7 +539,7 @@ common retrie cpp-options: -Dhls_retrie library hls-retrie-plugin - import: defaults, warnings + import: defaults, warnings exposed-modules: Ide.Plugin.Retrie hs-source-dirs: plugins/hls-retrie-plugin/src build-depends: @@ -546,7 +547,6 @@ library hls-retrie-plugin , base >=4.12 && <5 , bytestring , containers - , deepseq , directory , extra , ghc @@ -574,7 +574,6 @@ test-suite hls-retrie-plugin-tests hs-source-dirs: plugins/hls-retrie-plugin/test main-is: Main.hs build-depends: - , aeson , base , containers , filepath @@ -814,7 +813,7 @@ common splice cpp-options: -Dhls_splice library hls-splice-plugin - import: defaults, warnings + import: defaults, pedantic, warnings exposed-modules: Ide.Plugin.Splice Ide.Plugin.Splice.Types @@ -823,8 +822,6 @@ library hls-splice-plugin build-depends: , aeson , base >=4.12 && <5 - , containers - , dlist , extra , foldl , ghc @@ -835,18 +832,16 @@ library hls-splice-plugin , lens , lsp , mtl - , retrie , syb , text , transformers , unliftio-core - , unordered-containers default-extensions: DataKinds test-suite hls-splice-plugin-tests - import: defaults, test-defaults, warnings + import: defaults, pedantic, test-defaults, warnings type: exitcode-stdio-1.0 hs-source-dirs: plugins/hls-splice-plugin/test main-is: Main.hs @@ -933,22 +928,17 @@ common qualifyImportedNames cpp-options: -Dhls_qualifyImportedNames library hls-qualify-imported-names-plugin - import: defaults, warnings + import: defaults, pedantic, warnings exposed-modules: Ide.Plugin.QualifyImportedNames hs-source-dirs: plugins/hls-qualify-imported-names-plugin/src build-depends: - , aeson , base >=4.12 && <5 , containers - , deepseq - , ghc , ghcide == 2.6.0.0 - , hls-graph , hls-plugin-api == 2.6.0.0 , lens , lsp , text - , unordered-containers , dlist , transformers @@ -1558,7 +1548,7 @@ common semanticTokens cpp-options: -Dhls_semanticTokens library hls-semantic-tokens-plugin - import: defaults, warnings + import: defaults, pedantic, warnings buildable: True exposed-modules: Ide.Plugin.SemanticTokens @@ -1573,20 +1563,16 @@ library hls-semantic-tokens-plugin hs-source-dirs: plugins/hls-semantic-tokens-plugin/src build-depends: - , aeson , base >=4.12 && <5 , containers , extra - , hiedb , text-rope , mtl >= 2.2 , ghcide == 2.6.0.0 , hls-plugin-api == 2.6.0.0 , lens , lsp >=2.3 - , sqlite-simple , text - , unordered-containers , transformers , bytestring , syb @@ -1599,7 +1585,7 @@ library hls-semantic-tokens-plugin default-extensions: DataKinds test-suite hls-semantic-tokens-plugin-tests - import: defaults, test-defaults, warnings + import: defaults, pedantic, test-defaults, warnings type: exitcode-stdio-1.0 hs-source-dirs: plugins/hls-semantic-tokens-plugin/test main-is: Main.hs @@ -1608,7 +1594,6 @@ test-suite hls-semantic-tokens-plugin-tests , aeson , base , containers - , extra , filepath , haskell-language-server:hls-semantic-tokens-plugin , hls-test-utils == 2.6.0.0 @@ -1621,10 +1606,8 @@ test-suite hls-semantic-tokens-plugin-tests , lsp-test , text , data-default - , bytestring , ghcide == 2.6.0.0 , hls-plugin-api == 2.6.0.0 - , template-haskell , data-default ----------------------------- @@ -1675,26 +1658,15 @@ library autogen-modules: Paths_haskell_language_server hs-source-dirs: src build-depends: - , async - , base16-bytestring - , bytestring - , containers - , cryptohash-sha1 , data-default , ghc , ghcide == 2.6.0.0 , githash >=0.1.6.1 - , lsp >= 2.3.0.0 , hie-bios - , hiedb , hls-plugin-api == 2.6.0.0 , optparse-applicative , optparse-simple , process - , hls-graph - , safe-exceptions - , sqlite-simple - , unordered-containers , aeson-pretty default-extensions: DataKinds @@ -1728,36 +1700,9 @@ executable haskell-language-server ghc-options: -dynamic build-depends: - , aeson - , async - , base16-bytestring - , binary - , bytestring - , containers - , cryptohash-sha1 - , deepseq - , ghc - , ghc-boot-th - , ghcide - , hashable , haskell-language-server , lsp - , hie-bios - , hiedb - , lens - , regex-tdfa - , optparse-applicative , hls-plugin-api - , lens - , mtl - , regex-tdfa - , safe-exceptions - , hls-graph - , sqlite-simple - , stm - , temporary - , transformers - , unordered-containers default-extensions: DataKinds @@ -1781,18 +1726,12 @@ executable haskell-language-server-wrapper build-depends: , data-default , ghc - , ghc-paths , ghcide - , gitrev , haskell-language-server , hie-bios , hls-plugin-api , lsp , lsp-types - , mtl - , optparse-applicative - , optparse-simple - , process , transformers , unliftio-core if !os(windows) @@ -1816,11 +1755,9 @@ test-suite func-test build-depends: , bytestring - , data-default , deepseq , hashable , lens - , lens-aeson , ghcide , ghcide-test-utils , hls-test-utils == 2.6.0.0 @@ -1830,7 +1767,6 @@ test-suite func-test , lsp-test , containers , unordered-containers - , row-types hs-source-dirs: test/functional test/utils @@ -1859,7 +1795,8 @@ test-suite func-test cpp-options: -Dhls_ormolu test-suite wrapper-test - import: defaults, common-deps + import: defaults + , common-deps , warnings , pedantic type: exitcode-stdio-1.0 @@ -1901,7 +1838,6 @@ benchmark benchmark hls-plugin-api, lens, lens-aeson, - optparse-applicative, shake, shake-bench == 0.2.*, yaml From 1c594218606d0727fde55be846ea696bec74b48f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Hr=C4=8Dek?= Date: Mon, 5 Feb 2024 19:24:18 +0100 Subject: [PATCH 02/10] Get rid of common deps --- haskell-language-server.cabal | 86 +++++++++++++++++++---------------- 1 file changed, 48 insertions(+), 38 deletions(-) diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index 73b495b7ef..8a9a355fb7 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -42,15 +42,6 @@ common defaults common test-defaults ghc-options: -threaded -rtsopts -with-rtsopts=-N -common common-deps - build-depends: - , base >=4.16 && <5 - , directory - , extra - , filepath - , text - , prettyprinter >= 1.7 - -- Default warnings in HLS common warnings ghc-options: -Wall @@ -434,7 +425,7 @@ flag importLens manual: True library hls-explicit-imports-plugin - import: defaults, warnings + import: defaults, pedantic, warnings exposed-modules: Ide.Plugin.ExplicitImports hs-source-dirs: plugins/hls-explicit-imports-plugin/src build-depends: @@ -928,7 +919,7 @@ common qualifyImportedNames cpp-options: -Dhls_qualifyImportedNames library hls-qualify-imported-names-plugin - import: defaults, pedantic, warnings + import: defaults, warnings exposed-modules: Ide.Plugin.QualifyImportedNames hs-source-dirs: plugins/hls-qualify-imported-names-plugin/src build-depends: @@ -1616,7 +1607,6 @@ test-suite hls-semantic-tokens-plugin-tests library import: defaults - , common-deps , warnings , pedantic -- plugins @@ -1658,7 +1648,12 @@ library autogen-modules: Paths_haskell_language_server hs-source-dirs: src build-depends: + , aeson-pretty + , base >=4.16 && <5 , data-default + , directory + , extra + , filepath , ghc , ghcide == 2.6.0.0 , githash >=0.1.6.1 @@ -1666,14 +1661,14 @@ library , hls-plugin-api == 2.6.0.0 , optparse-applicative , optparse-simple + , prettyprinter >= 1.7 , process - , aeson-pretty + , text default-extensions: DataKinds executable haskell-language-server import: defaults - , common-deps , warnings , pedantic main-is: Main.hs @@ -1700,15 +1695,17 @@ executable haskell-language-server ghc-options: -dynamic build-depends: + , base >=4.16 && <5 , haskell-language-server - , lsp , hls-plugin-api + , lsp + , prettyprinter >= 1.7 + , text default-extensions: DataKinds executable haskell-language-server-wrapper import: defaults - , common-deps , warnings , pedantic main-is: Wrapper.hs @@ -1724,14 +1721,18 @@ executable haskell-language-server-wrapper "-with-rtsopts=-I0 -A128M" build-depends: + , base >=4.16 && <5 , data-default - , ghc + , directory + , extra + , filepath , ghcide , haskell-language-server , hie-bios , hls-plugin-api , lsp , lsp-types + , text , transformers , unliftio-core if !os(windows) @@ -1744,7 +1745,6 @@ executable haskell-language-server-wrapper test-suite func-test import: defaults , test-defaults - , common-deps , warnings , pedantic , refactor @@ -1754,18 +1754,22 @@ test-suite func-test ghcide:ghcide-test-preprocessor build-depends: + , aeson + , base >=4.16 && <5 , bytestring + , containers , deepseq - , hashable - , lens + , extra + , filepath , ghcide , ghcide-test-utils - , hls-test-utils == 2.6.0.0 - , lsp-types - , aeson + , hashable , hls-plugin-api + , hls-test-utils == 2.6.0.0 + , lens , lsp-test - , containers + , lsp-types + , text , unordered-containers hs-source-dirs: test/functional test/utils @@ -1796,7 +1800,6 @@ test-suite func-test test-suite wrapper-test import: defaults - , common-deps , warnings , pedantic type: exitcode-stdio-1.0 @@ -1805,14 +1808,16 @@ test-suite wrapper-test haskell-language-server:haskell-language-server build-depends: - process + , base >=4.16 && <5 + , extra , hls-test-utils + , process hs-source-dirs: test/wrapper main-is: Main.hs benchmark benchmark - import: defaults, warnings, common-deps + import: defaults, warnings -- Depends on shake-bench which is unbuildable after this point if impl(ghc >= 9.5) buildable: False @@ -1830,14 +1835,19 @@ benchmark benchmark ViewPatterns build-depends: - aeson, - containers, - data-default, - ghcide-bench, - haskell-language-server, - hls-plugin-api, - lens, - lens-aeson, - shake, - shake-bench == 0.2.*, - yaml + , aeson + , base >=4.16 && <5 + , containers + , data-default + , directory + , extra + , filepath + , ghcide-bench + , haskell-language-server + , hls-plugin-api + , lens + , lens-aeson + , shake + , shake-bench == 0.2.* + , text + , yaml From 0721987ebbc872b6b6abbcb0cf2d0edbaef0be5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Hr=C4=8Dek?= Date: Tue, 6 Feb 2024 05:04:22 +0100 Subject: [PATCH 03/10] Wrapper needs process on windows --- haskell-language-server.cabal | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index 8a9a355fb7..98bdc760d5 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -1737,10 +1737,11 @@ executable haskell-language-server-wrapper , unliftio-core if !os(windows) build-depends: - unix + , unix , containers - - + else + build-depends: + , process test-suite func-test import: defaults From 786089f9dc4cdfe37c6b8ad06267035fcfbfb0a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Hr=C4=8Dek?= Date: Tue, 6 Feb 2024 07:16:30 +0100 Subject: [PATCH 04/10] Refine --- haskell-language-server.cabal | 17 +++++++++-- .../hls-semantic-tokens-plugin/test/Main.hs | 29 +++++++++---------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index 98bdc760d5..fab16a71b9 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -46,6 +46,11 @@ common test-defaults common warnings ghc-options: -Wall -Wredundant-constraints + -- Note [unused-packages] Some packages need CPP conditioned on MIN_VERSION_ghc(x,y,z). + -- MIN_VERSION_ is CPP macro that cabal defines only when is declared as a dependency. + -- But -Wunused-packages still reports it as unused dependency if it's not imported. + -- For packages with such "unused" dependencies we demote -Wunused-packages error + -- (enabled by --flag=pedantic) to warning via -Wwarn=unused-packages. -Wunused-packages -Wno-name-shadowing -Wno-unticked-promoted-constructors @@ -428,6 +433,9 @@ library hls-explicit-imports-plugin import: defaults, pedantic, warnings exposed-modules: Ide.Plugin.ExplicitImports hs-source-dirs: plugins/hls-explicit-imports-plugin/src + ghc-options: + --See Note [unused-packages] + -Wwarn=unused-packages build-depends: , aeson , base >=4.12 && <5 @@ -808,6 +816,9 @@ library hls-splice-plugin exposed-modules: Ide.Plugin.Splice Ide.Plugin.Splice.Types + ghc-options: + --See Note [unused-packages] + -Wwarn=unused-packages hs-source-dirs: plugins/hls-splice-plugin/src build-depends: @@ -1364,10 +1375,13 @@ library hls-ormolu-plugin test-suite hls-ormolu-plugin-tests - import: defaults, test-defaults, warnings + import: defaults, pedantic, test-defaults, warnings type: exitcode-stdio-1.0 hs-source-dirs: plugins/hls-ormolu-plugin/test main-is: Main.hs + ghc-options: + -- See Note [unused-packages] + -Wwarn=unused-packages build-tool-depends: ormolu:ormolu build-depends: @@ -1592,7 +1606,6 @@ test-suite hls-semantic-tokens-plugin-tests , hls-plugin-api , lens , lsp - , ghc , text-rope , lsp-test , text diff --git a/plugins/hls-semantic-tokens-plugin/test/Main.hs b/plugins/hls-semantic-tokens-plugin/test/Main.hs index 292096d700..8905b0ae7d 100644 --- a/plugins/hls-semantic-tokens-plugin/test/Main.hs +++ b/plugins/hls-semantic-tokens-plugin/test/Main.hs @@ -1,11 +1,10 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE OverloadedStrings #-} import Control.Lens ((^?)) import Control.Monad.IO.Class (liftIO) -import Data.Aeson (KeyValue (..), Value (..), - object) +import Data.Aeson (KeyValue (..), Object) +import qualified Data.Aeson.KeyMap as KV import Data.Default import Data.Functor (void) import Data.Map.Strict as Map hiding (map) @@ -14,6 +13,9 @@ import Data.Text hiding (length, map, unlines) import qualified Data.Text as Text import qualified Data.Text.Utf16.Rope as Rope +import Development.IDE (Pretty) +import Development.IDE.GHC.Compat (GhcVersion (..), + ghcVersion) import Development.IDE.Plugin.Test (WaitForIdeRuleResult (..)) import Development.IDE.Test (waitForBuildQueue) import Ide.Plugin.SemanticTokens @@ -22,13 +24,12 @@ import Ide.Plugin.SemanticTokens.Types import Ide.Types import Language.LSP.Protocol.Types (SemanticTokenTypes (..), _L) -import Language.LSP.Test (Session (..), +import Language.LSP.Test (Session, SessionConfig (ignoreConfigurationRequests), openDoc) import qualified Language.LSP.Test as Test import Language.LSP.VFS (VirtualFile (..)) import System.FilePath -import qualified Test.Hls as Test import Test.Hls (PluginTestDescriptor, TestName, TestTree, TextDocumentIdentifier, @@ -65,6 +66,7 @@ semanticTokensPlugin = Test.Hls.mkPluginTestDescriptor enabledSemanticDescriptor } } +goldenWithHaskellAndCapsOutPut :: Pretty b => Config -> PluginTestDescriptor b -> TestName -> FS.VirtualFileTree -> FilePath -> String -> (TextDocumentIdentifier -> Session String) -> TestTree goldenWithHaskellAndCapsOutPut config plugin title tree path desc act = goldenGitDiff title (FS.vftOriginalRoot tree path <.> desc) $ runSessionWithServerInTmpDir config plugin tree $ @@ -118,13 +120,11 @@ semanticTokensValuePatternTests = goldenWithSemanticTokensWithDefaultConfig "pattern bind" "TPatternbind" ] -mkSemanticConfig :: Value -> Config +mkSemanticConfig :: Object -> Config mkSemanticConfig setting = def{plugins = Map.insert "SemanticTokens" conf (plugins def)} where - conf = def{plcConfig = (\(Object obj) -> obj) setting } + conf = def{plcConfig = setting } -modifySemantic :: Value -> Session () -modifySemantic setting = Test.setHlsConfig $ mkSemanticConfig setting directFile :: FilePath -> Text -> [FS.FileTree] @@ -138,7 +138,7 @@ semanticTokensConfigTest = testGroup "semantic token config test" [ testCase "function to variable" $ do let content = Text.unlines ["module Hello where", "go _ = 1"] let fs = mkFs $ directFile "Hello.hs" content - let funcVar = object ["functionToken" .= var] + let funcVar = KV.fromList ["functionToken" .= var] var :: String var = "variable" do @@ -158,8 +158,7 @@ semanticTokensConfigTest = testGroup "semantic token config test" [ semanticTokensTests :: TestTree semanticTokensTests = - testGroup - "other semantic Token test" + testGroup "other semantic Token test" $ [ testCase "module import test" $ do let file1 = "TModula𐐀bA.hs" let file2 = "TModuleB.hs" @@ -194,11 +193,9 @@ semanticTokensTests = goldenWithSemanticTokensWithDefaultConfig "type family" "TTypefamily", goldenWithSemanticTokensWithDefaultConfig "TUnicodeSyntax" "TUnicodeSyntax", goldenWithSemanticTokensWithDefaultConfig "TQualifiedName" "TQualifiedName" - -- it is not supported in ghc92 -#if MIN_VERSION_ghc(9,4,0) - , goldenWithSemanticTokensWithDefaultConfig "TDoc" "TDoc" -#endif ] + -- not supported in ghc92 + ++ [goldenWithSemanticTokensWithDefaultConfig "TDoc" "TDoc" | ghcVersion > GHC92] semanticTokensDataTypeTests :: TestTree semanticTokensDataTypeTests = From 50c389110db8e75bcaefe68fa476bd73b828e722 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Hr=C4=8Dek?= Date: Tue, 6 Feb 2024 07:45:40 +0100 Subject: [PATCH 05/10] Does it work like this? --- haskell-language-server.cabal | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index fab16a71b9..70e89788d8 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -433,9 +433,10 @@ library hls-explicit-imports-plugin import: defaults, pedantic, warnings exposed-modules: Ide.Plugin.ExplicitImports hs-source-dirs: plugins/hls-explicit-imports-plugin/src - ghc-options: - --See Note [unused-packages] - -Wwarn=unused-packages + if flag(pedantic) + ghc-options: + --See Note [unused-packages] + -Wwarn=unused-packages build-depends: , aeson , base >=4.12 && <5 @@ -816,9 +817,10 @@ library hls-splice-plugin exposed-modules: Ide.Plugin.Splice Ide.Plugin.Splice.Types - ghc-options: - --See Note [unused-packages] - -Wwarn=unused-packages + if flag(pedantic) + ghc-options: + --See Note [unused-packages] + -Wwarn=unused-packages hs-source-dirs: plugins/hls-splice-plugin/src build-depends: @@ -1379,9 +1381,10 @@ test-suite hls-ormolu-plugin-tests type: exitcode-stdio-1.0 hs-source-dirs: plugins/hls-ormolu-plugin/test main-is: Main.hs - ghc-options: - -- See Note [unused-packages] - -Wwarn=unused-packages + if flag(pedantic) + ghc-options: + --See Note [unused-packages] + -Wwarn=unused-packages build-tool-depends: ormolu:ormolu build-depends: From 6d20721588e3211230409e68883b6820cce4347b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Hr=C4=8Dek?= Date: Wed, 7 Feb 2024 14:20:52 +0100 Subject: [PATCH 06/10] More cleanups in ghcide --- ghcide/ghcide.cabal | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/ghcide/ghcide.cabal b/ghcide/ghcide.cabal index 5b4c84da5e..41e1edbf92 100644 --- a/ghcide/ghcide.cabal +++ b/ghcide/ghcide.cabal @@ -14,7 +14,7 @@ homepage: https://github.com/haskell/haskell-language-server/tree/master/ghcide#readme bug-reports: https://github.com/haskell/haskell-language-server/issues -tested-with: GHC == 9.8.1 || ==9.6.4 || ==9.4.8 || ==9.2.8 +tested-with: GHC ==9.8.1 || ==9.6.4 || ==9.4.8 || ==9.2.8 extra-source-files: CHANGELOG.md README.md @@ -215,11 +215,8 @@ library Development.IDE.Types.Action if flag(pedantic) - -- We eventually want to build with Werror fully, but we haven't - -- finished purging the warnings, so some are set to not be errors - -- for now ghc-options: - -Werror -Wwarn=unused-packages + -Werror if flag(ekg) build-depends: @@ -283,13 +280,6 @@ executable ghcide if !flag(executable) buildable: False - if flag(ekg) - build-depends: - , ekg-core - , ekg-wai - - cpp-options: -DMONITORING_EKG - test-suite ghcide-tests import: warnings type: exitcode-stdio-1.0 @@ -310,14 +300,6 @@ test-suite ghcide-tests , extra , filepath , fuzzy - -------------------------------------------------------------- - -- The MIN_VERSION_ghc macro relies on MIN_VERSION pragmas - -- which require depending on ghc. So the tests need to depend - -- on ghc if they need to use MIN_VERSION_ghc. Maybe a - -- better solution can be found, but this is a quick solution - -- which works for now. - -------------------------------------------------------------- - , ghc , ghcide , hls-plugin-api , lens From 74830aa038fe99f5fcee292827ff63818cfef075 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Hr=C4=8Dek?= Date: Wed, 7 Feb 2024 15:33:10 +0100 Subject: [PATCH 07/10] Fix build with stack --- haskell-language-server.cabal | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index 70e89788d8..14d86b608a 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -389,9 +389,6 @@ library hls-eval-plugin , unliftio , unordered-containers - if flag(pedantic) - ghc-options: -Wwarn=redundant-constraints - default-extensions: DataKinds @@ -1683,6 +1680,11 @@ library default-extensions: DataKinds + if flag(pedantic) + ghc-options: + --See Note [unused-packages] + -Wwarn=unused-packages + executable haskell-language-server import: defaults , warnings From 47a9dcdd1e45398e65ff2983fa6f34f2b96e66eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Hr=C4=8Dek?= Date: Wed, 7 Feb 2024 17:25:29 +0100 Subject: [PATCH 08/10] Also fix stack --test --- haskell-language-server.cabal | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index 14d86b608a..77429fe1b1 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -1804,6 +1804,11 @@ test-suite func-test Test.Hls.Command Test.Hls.Flags + if flag(pedantic) + ghc-options: + --See Note [unused-packages] + -Wwarn=unused-packages + default-extensions: OverloadedStrings -- Duplicating inclusion plugin conditions until tests are moved to their own packages From d01aefd8206ec30437846e7ea8089829f8ee51f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Hr=C4=8Dek?= Date: Wed, 7 Feb 2024 18:33:14 +0100 Subject: [PATCH 09/10] Less noisy workaround --- haskell-language-server.cabal | 36 ++++++++--------------------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index 77429fe1b1..20ba6414af 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -46,11 +46,6 @@ common test-defaults common warnings ghc-options: -Wall -Wredundant-constraints - -- Note [unused-packages] Some packages need CPP conditioned on MIN_VERSION_ghc(x,y,z). - -- MIN_VERSION_ is CPP macro that cabal defines only when is declared as a dependency. - -- But -Wunused-packages still reports it as unused dependency if it's not imported. - -- For packages with such "unused" dependencies we demote -Wunused-packages error - -- (enabled by --flag=pedantic) to warning via -Wwarn=unused-packages. -Wunused-packages -Wno-name-shadowing -Wno-unticked-promoted-constructors @@ -63,7 +58,14 @@ flag pedantic -- Allow compiling in pedantic mode common pedantic if flag(pedantic) - ghc-options: -Werror + ghc-options: + -Werror + -- Note [unused-packages] Some packages need CPP conditioned on MIN_VERSION_ghc(x,y,z). + -- MIN_VERSION_ is CPP macro that cabal defines only when is declared as a dependency. + -- But -Wunused-packages still reports it as unused dependency if it's not imported. + -- For packages with such "unused" dependencies we demote -Wunused-packages error + -- (enabled by --flag=pedantic) to warning via -Wwarn=unused-packages. + -Wwarn=unused-packages -- Plugin flags are designed for 'cabal install haskell-language-server': -- - Bulk flags should be default:False @@ -430,10 +432,6 @@ library hls-explicit-imports-plugin import: defaults, pedantic, warnings exposed-modules: Ide.Plugin.ExplicitImports hs-source-dirs: plugins/hls-explicit-imports-plugin/src - if flag(pedantic) - ghc-options: - --See Note [unused-packages] - -Wwarn=unused-packages build-depends: , aeson , base >=4.12 && <5 @@ -814,10 +812,6 @@ library hls-splice-plugin exposed-modules: Ide.Plugin.Splice Ide.Plugin.Splice.Types - if flag(pedantic) - ghc-options: - --See Note [unused-packages] - -Wwarn=unused-packages hs-source-dirs: plugins/hls-splice-plugin/src build-depends: @@ -1378,10 +1372,6 @@ test-suite hls-ormolu-plugin-tests type: exitcode-stdio-1.0 hs-source-dirs: plugins/hls-ormolu-plugin/test main-is: Main.hs - if flag(pedantic) - ghc-options: - --See Note [unused-packages] - -Wwarn=unused-packages build-tool-depends: ormolu:ormolu build-depends: @@ -1680,11 +1670,6 @@ library default-extensions: DataKinds - if flag(pedantic) - ghc-options: - --See Note [unused-packages] - -Wwarn=unused-packages - executable haskell-language-server import: defaults , warnings @@ -1804,11 +1789,6 @@ test-suite func-test Test.Hls.Command Test.Hls.Flags - if flag(pedantic) - ghc-options: - --See Note [unused-packages] - -Wwarn=unused-packages - default-extensions: OverloadedStrings -- Duplicating inclusion plugin conditions until tests are moved to their own packages From 93598110267d9d125cf40873d30b15ebf96dee25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Hr=C4=8Dek?= Date: Thu, 8 Feb 2024 13:05:56 +0100 Subject: [PATCH 10/10] Fix new warnings --- .../src/Ide/Plugin/SemanticTokens/Internal.hs | 1 - .../src/Ide/Plugin/SemanticTokens/Types.hs | 2 -- 2 files changed, 3 deletions(-) diff --git a/plugins/hls-semantic-tokens-plugin/src/Ide/Plugin/SemanticTokens/Internal.hs b/plugins/hls-semantic-tokens-plugin/src/Ide/Plugin/SemanticTokens/Internal.hs index 6289482714..3b87c0f336 100644 --- a/plugins/hls-semantic-tokens-plugin/src/Ide/Plugin/SemanticTokens/Internal.hs +++ b/plugins/hls-semantic-tokens-plugin/src/Ide/Plugin/SemanticTokens/Internal.hs @@ -18,7 +18,6 @@ import Control.Monad.Except (ExceptT, liftEither, import Control.Monad.Trans (lift) import Control.Monad.Trans.Except (runExceptT) import qualified Data.Map.Strict as M -import qualified Data.Set as S import Development.IDE (Action, GetDocMap (GetDocMap), GetHieAst (GetHieAst), diff --git a/plugins/hls-semantic-tokens-plugin/src/Ide/Plugin/SemanticTokens/Types.hs b/plugins/hls-semantic-tokens-plugin/src/Ide/Plugin/SemanticTokens/Types.hs index a479646990..601956bee9 100644 --- a/plugins/hls-semantic-tokens-plugin/src/Ide/Plugin/SemanticTokens/Types.hs +++ b/plugins/hls-semantic-tokens-plugin/src/Ide/Plugin/SemanticTokens/Types.hs @@ -18,8 +18,6 @@ import Development.IDE.Graph.Classes (Hashable) import GHC.Generics (Generic) import Language.LSP.Protocol.Types -- import template haskell -import Data.Map.Strict (Map) -import Data.Set (Set) import Language.Haskell.TH.Syntax (Lift)