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 diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index b1ded23e1e..b4a0d12753 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -42,18 +42,13 @@ 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 -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 @@ -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 @@ -389,9 +391,6 @@ library hls-eval-plugin , unliftio , unordered-containers - if flag(pedantic) - ghc-options: -Wwarn=redundant-constraints - default-extensions: DataKinds @@ -430,7 +429,7 @@ flag importLens manual: True library hls-explicit-imports-plugin - import: defaults, warnings, pedantic + import: defaults, pedantic, warnings exposed-modules: Ide.Plugin.ExplicitImports hs-source-dirs: plugins/hls-explicit-imports-plugin/src build-depends: @@ -447,13 +446,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 +488,6 @@ library hls-rename-plugin , base >=4.12 && <5 , containers , extra - , ghc - , ghc-exactprint , ghcide == 2.6.0.0 , hashable , hiedb @@ -538,7 +534,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 +542,6 @@ library hls-retrie-plugin , base >=4.12 && <5 , bytestring , containers - , deepseq , directory , extra , ghc @@ -574,7 +569,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 +808,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 +817,6 @@ library hls-splice-plugin build-depends: , aeson , base >=4.12 && <5 - , containers - , dlist , extra , foldl , ghc @@ -835,18 +827,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 +923,17 @@ common qualifyImportedNames cpp-options: -Dhls_qualifyImportedNames library hls-qualify-imported-names-plugin - import: defaults, warnings + import: defaults, 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 @@ -1383,7 +1368,7 @@ 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 @@ -1558,7 +1543,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 +1558,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 @@ -1600,7 +1581,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 @@ -1609,7 +1590,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 @@ -1617,15 +1597,12 @@ test-suite hls-semantic-tokens-plugin-tests , hls-plugin-api , lens , lsp - , ghc , text-rope , lsp-test , text , data-default - , bytestring , ghcide == 2.6.0.0 , hls-plugin-api == 2.6.0.0 - , template-haskell , data-default ----------------------------- @@ -1634,7 +1611,6 @@ test-suite hls-semantic-tokens-plugin-tests library import: defaults - , common-deps , warnings , pedantic -- plugins @@ -1676,33 +1652,27 @@ library autogen-modules: Paths_haskell_language_server hs-source-dirs: src build-depends: - , async - , base16-bytestring - , bytestring - , containers - , cryptohash-sha1 + , aeson-pretty + , base >=4.16 && <5 , data-default + , directory + , extra + , filepath , 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 + , prettyprinter >= 1.7 , process - , hls-graph - , safe-exceptions - , sqlite-simple - , unordered-containers - , aeson-pretty + , text default-extensions: DataKinds executable haskell-language-server import: defaults - , common-deps , warnings , pedantic main-is: Main.hs @@ -1729,42 +1699,17 @@ 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 + , base >=4.16 && <5 , 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 + , lsp + , prettyprinter >= 1.7 + , text default-extensions: DataKinds executable haskell-language-server-wrapper import: defaults - , common-deps , warnings , pedantic main-is: Wrapper.hs @@ -1780,33 +1725,31 @@ executable haskell-language-server-wrapper "-with-rtsopts=-I0 -A128M" build-depends: + , base >=4.16 && <5 , data-default - , ghc - , ghc-paths + , directory + , extra + , filepath , ghcide - , gitrev , haskell-language-server , hie-bios , hls-plugin-api , lsp , lsp-types - , mtl - , optparse-applicative - , optparse-simple - , process + , text , transformers , unliftio-core if !os(windows) build-depends: - unix + , unix , containers - - + else + build-depends: + , process test-suite func-test import: defaults , test-defaults - , common-deps , warnings , pedantic , refactor @@ -1816,22 +1759,23 @@ test-suite func-test ghcide:ghcide-test-preprocessor build-depends: + , aeson + , base >=4.16 && <5 , bytestring - , data-default + , containers , deepseq - , hashable - , lens - , lens-aeson + , 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 - , row-types hs-source-dirs: test/functional test/utils @@ -1860,7 +1804,7 @@ test-suite func-test cpp-options: -Dhls_ormolu test-suite wrapper-test - import: defaults, common-deps + import: defaults , warnings , pedantic type: exitcode-stdio-1.0 @@ -1869,14 +1813,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 @@ -1894,15 +1840,19 @@ benchmark benchmark ViewPatterns build-depends: - aeson, - containers, - data-default, - ghcide-bench, - haskell-language-server, - hls-plugin-api, - lens, - lens-aeson, - optparse-applicative, - 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 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) 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 =