diff --git a/.circleci/config.yml b/.circleci/config.yml index faae427dbe..b0f465db57 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -105,6 +105,11 @@ jobs: - STACK_FILE: "stack-9.0.2.yaml" <<: *defaults + ghc-9.2.1: + environment: + - STACK_FILE: "stack-9.2.1.yaml" + <<: *defaults + ghc-default: environment: - STACK_FILE: "stack.yaml" @@ -121,4 +126,5 @@ workflows: - ghc-8.10.7 - ghc-9.0.1 - ghc-9.0.2 + - ghc-9.2.1 - ghc-default diff --git a/.github/actions/setup-build/action.yml b/.github/actions/setup-build/action.yml index c0e01ebe5e..ff44232a1b 100644 --- a/.github/actions/setup-build/action.yml +++ b/.github/actions/setup-build/action.yml @@ -54,11 +54,19 @@ runs: fi shell: bash + # some alpines come with integer-simple instead of integer-gmp + - if: inputs.os == 'Linux' + name: Force integer-simple + run: | + if ghc --info | grep -q integer-simple ; then + echo -e 'package blaze-textual\n flags: +integer-simple' >> cabal.project.local + fi + shell: bash + - if: inputs.os == 'Windows' && inputs.ghc == '8.8.4' name: (Windows,GHC 8.8) Modify `cabal.project` to workaround segfaults run: | - echo "package floskell" >> cabal.project - echo " ghc-options: -O0" >> cabal.project + echo -e 'package floskell\n ghc-options: -O0' >> cabal.project.local shell: bash # Shorten binary names as a workaround for filepath length limits in Windows, diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bbbff326c0..32c086981c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,40 +41,15 @@ jobs: apk add --no-cache zlib zlib-dev zlib-static gmp gmp-dev ncurses-static - uses: actions/checkout@v2 - - uses: haskell/actions/setup@v1 - with: - ghc-version : ${{ matrix.ghc }} - cabal-version: ${{ matrix.cabal }} - enable-stack: false - - # some alpines come with integer-simple instead of integer-gmp - - name: Force integer-simple - if: matrix.os == 'ubuntu-18.04' - run: | - if ghc --info | grep -q integer-simple ; then - echo -e 'package blaze-textual\n flags: +integer-simple' >> cabal.project.local - fi - - - name: Use modified cabal.project - env: - GHCVER: ${{ matrix.ghc }} + - name: Disable tests and bechmarks run: | - GHCVER2=${GHCVER//./} - ALT_PROJECT_FILE_MINOR=cabal-ghc${GHCVER2}.project - ALT_PROJECT_FILE_MAJOR=cabal-ghc${GHCVER2:0:2}.project - if [[ -f "$ALT_PROJECT_FILE_MINOR" ]]; then - rm -f -v cabal.project && cp -v "$ALT_PROJECT_FILE_MINOR" cabal.project - elif [[ -f "$ALT_PROJECT_FILE_MAJOR" ]]; then - rm -f -v cabal.project && cp -v "$ALT_PROJECT_FILE_MAJOR" cabal.project - fi + echo -e 'tests: false' >> cabal.project.local + echo -e 'benchmarks: false' >> cabal.project.local - - name: Shorten binary names - run: | - sed -i.bak -e 's/haskell-language-server/hls/g' \ - -e 's/haskell_language_server/hls/g' \ - haskell-language-server.cabal cabal.project - sed -i.bak -e 's/Paths_haskell_language_server/Paths_hls/g' \ - src/**/*.hs exe/*.hs + - uses: ./.github/actions/setup-build + with: + ghc: ${{ matrix.ghc }} + os: ${{ runner.os }} - name: (Windows) Platform specifics if: matrix.os == 'windows-latest' @@ -99,17 +74,10 @@ jobs: run: | echo "GHC_VERSION=$GHC_VER" >> $GITHUB_ENV - - name: (Windows, GHC 8.8.4) Workaround segfaults - if: matrix.ghc == '8.8.4' && matrix.os == 'windows-latest' - run: | - echo "package floskell" >> cabal.project - echo " ghc-options: -O0" >> cabal.project - - name: Build the server # Try building it twice in case of flakey builds on Windows run: | - cabal build --disable-tests exe:hls -O2 $LINUX_CABAL_ARGS || \ - cabal build --disable-tests exe:hls -O2 $LINUX_CABAL_ARGS -j1 + cabal build exe:hls -O2 $LINUX_CABAL_ARGS || cabal build exe:hls -O2 $LINUX_CABAL_ARGS -j1 - name: Compress server binary id: compress_server_binary @@ -148,7 +116,7 @@ jobs: - name: (GHC 8.10) Build the wrapper if: matrix.ghc == '8.10.7' - run: cabal build --disable-tests exe:hls-wrapper -O2 $LINUX_CABAL_ARGS + run: cabal build exe:hls-wrapper -O2 $LINUX_CABAL_ARGS - name: (GHC 8.10) Compress wrapper binary if: matrix.ghc == '8.10.7' diff --git a/.github/workflows/flags.yml b/.github/workflows/flags.yml index 6f2f3d0b6d..1f7e659a04 100644 --- a/.github/workflows/flags.yml +++ b/.github/workflows/flags.yml @@ -43,7 +43,11 @@ jobs: strategy: fail-fast: true matrix: - ghc: [ "8.10.7" + ghc: [ "9.2.1" + , "9.0.2" + , "8.10.7" + , "8.8.4" + , "8.6.5" ] os: [ "ubuntu-latest" ] @@ -57,20 +61,20 @@ jobs: os: ${{ runner.os }} - name: Build `hls-graph` with flags - run: cabal v2-build hls-graph --flags="pedantic embed-files stm-stats" + run: cabal v2-build hls-graph --flags="embed-files stm-stats" - - name: Build `hie-compat` with flags + - if: matrix.ghc != '8.6.5' && matrix.ghc != '8.8.4' + name: Build `hie-compat` with flags run: cabal v2-build hie-compat --flags="ghc-lib" - - name: Build `hls-plugin-api` with flags - run: cabal v2-build hls-plugin-api --flags="pedantic" - - - name: Build `hls-test-utils` with flags - run: cabal v2-build hls-test-utils --flags="pedantic" - - - name: Build + - name: Build `ghcide` with flags run: cabal v2-build ghcide --flags="ghc-patched-unboxed-bytecode test-exe executable bench-exe" + # we have to clean up warnings for 9.0 and 9.2 before enable -WAll + - if: matrix.ghc != '9.0.2' && matrix.ghc != '9.2.1' + name: Build with pedantic (-WError) + run: cabal v2-build --flags="pedantic" + flags_post_job: if: always() runs-on: ubuntu-latest diff --git a/cabal-ghc921.project b/cabal-ghc921.project index 2ad661358a..fc08879367 100644 --- a/cabal-ghc921.project +++ b/cabal-ghc921.project @@ -27,16 +27,6 @@ packages: ./plugins/hls-call-hierarchy-plugin ./plugins/hls-alternate-number-format-plugin -repository head.hackage.ghc.haskell.org - url: https://ghc.gitlab.haskell.org/head.hackage/ - secure: True - key-threshold: 3 - root-keys: - f76d08be13e9a61a377a85e2fb63f4c5435d40f8feb3e12eb05905edb8cdea89 - 26021a13b401500c8eb2761ca95c61f2d625bfef951b939a8124ed12ecf07329 - 7541f32a4ccca4f97aea3b22f5e593ba2c0267546016b992dfadcd2fe944e55d - - with-compiler: ghc-9.2.1 tests: true @@ -63,17 +53,8 @@ constraints: -splice -stylishhaskell -tactic, - ghc-lib-parser ^>= 9.2, - attoparsec ^>= 0.14.3, - ghc-exactprint >= 1.3, - retrie >= 1.2, - direct-sqlite == 2.3.26, - lens >= 5.0.1, - primitive-unlifted ==0.1.3.1 allow-newer: - -- base, - -- for shake-bench Chart:lens, Chart-diagrams:lens, diff --git a/hls-graph/src/Development/IDE/Graph/Internal/Types.hs b/hls-graph/src/Development/IDE/Graph/Internal/Types.hs index 9706061971..0a1278f5d3 100644 --- a/hls-graph/src/Development/IDE/Graph/Internal/Types.hs +++ b/hls-graph/src/Development/IDE/Graph/Internal/Types.hs @@ -1,5 +1,3 @@ - - {-# LANGUAGE CPP #-} {-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DeriveFunctor #-} @@ -14,16 +12,13 @@ module Development.IDE.Graph.Internal.Types where import Control.Applicative import Control.Monad.Catch -#if __GLASGOW_HASKELL__ < 870 +#if __GLASGOW_HASKELL__ < 808 -- Needed in GHC 8.6.5 import Control.Concurrent.STM.Stats (TVar, atomically) +import Control.Monad.Fail #else import GHC.Conc (TVar, atomically) #endif -#if __GLASGOW_HASKELL__ < 880 -import Control.Monad.Fail -import Prelude hiding (MonadFail) -#endif import Control.Monad.IO.Class import Control.Monad.Trans.Reader import Data.Aeson (FromJSON, ToJSON) diff --git a/plugins/default/src/Ide/Plugin/Example.hs b/plugins/default/src/Ide/Plugin/Example.hs index 6fbbaad67a..9511b00b06 100644 --- a/plugins/default/src/Ide/Plugin/Example.hs +++ b/plugins/default/src/Ide/Plugin/Example.hs @@ -109,15 +109,18 @@ mkDiag file diagSource sev loc msg = (file, D.ShowDiag,) -- | Generate code actions. codeAction :: PluginMethodHandler IdeState TextDocumentCodeAction codeAction state _pid (CodeActionParams _ _ (TextDocumentIdentifier uri) _range CodeActionContext{_diagnostics=List _xs}) = liftIO $ do - let Just nfp = uriToNormalizedFilePath $ toNormalizedUri uri - Just (ParsedModule{},_) <- runIdeAction "example" (shakeExtras state) $ useWithStaleFast GetParsedModule nfp - let - title = "Add TODO Item 1" - tedit = [TextEdit (Range (Position 2 0) (Position 2 0)) - "-- TODO1 added by Example Plugin directly\n"] - edit = WorkspaceEdit (Just $ Map.singleton uri $ List tedit) Nothing Nothing - pure $ Right $ List - [ InR $ CodeAction title (Just CodeActionQuickFix) (Just $ List []) Nothing Nothing (Just edit) Nothing Nothing] + let mbnfp = uriToNormalizedFilePath $ toNormalizedUri uri + case mbnfp of + Just nfp -> do + Just (ParsedModule{},_) <- runIdeAction "example" (shakeExtras state) $ useWithStaleFast GetParsedModule nfp + let + title = "Add TODO Item 1" + tedit = [TextEdit (Range (Position 2 0) (Position 2 0)) + "-- TODO1 added by Example Plugin directly\n"] + edit = WorkspaceEdit (Just $ Map.singleton uri $ List tedit) Nothing Nothing + pure $ Right $ List + [ InR $ CodeAction title (Just CodeActionQuickFix) (Just $ List []) Nothing Nothing (Just edit) Nothing Nothing] + Nothing -> error $ "Unable to get a normalized file path from the uri: " ++ show uri -- --------------------------------------------------------------------- diff --git a/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/Rules.hs b/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/Rules.hs index dfca81fabc..94539a395f 100644 --- a/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/Rules.hs +++ b/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/Rules.hs @@ -2,7 +2,8 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE RecordWildCards #-} - +-- To avoid warning "Pattern match has inaccessible right hand side" +{-# OPTIONS_GHC -Wno-overlapping-patterns #-} module Ide.Plugin.Eval.Rules (GetEvalComments(..), rules,queueForEvaluation) where import Control.Monad.IO.Class (MonadIO (liftIO)) diff --git a/plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs b/plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs index c4da71d5cc..4d079e8421 100644 --- a/plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs +++ b/plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs @@ -59,7 +59,9 @@ import Development.IDE.GHC.Compat (BufSpan, DynFlags, extensionFlags, ms_hspp_opts, - topDir) + topDir, + WarningFlag(Opt_WarnUnrecognisedPragmas), + wopt) import qualified Development.IDE.GHC.Compat.Util as EnumSet import "ghc-lib" GHC hiding (DynFlags (..), @@ -85,6 +87,7 @@ import Language.Haskell.GHC.ExactPrint.Delta (deltaOption import Language.Haskell.GHC.ExactPrint.Parsers (postParseTransform) import Language.Haskell.GHC.ExactPrint.Types (Rigidity (..)) import Language.Haskell.GhclibParserEx.Fixity as GhclibParserEx (applyFixities) +import GHC.Generics (Associativity (LeftAssociative, NotAssociative, RightAssociative)) #endif import Ide.Logger @@ -105,12 +108,6 @@ import Language.LSP.Types hiding import qualified Language.LSP.Types as LSP import qualified Language.LSP.Types.Lens as LSP -import GHC.Generics (Associativity (LeftAssociative, NotAssociative, RightAssociative), - Generic) -import Text.Regex.TDFA.Text () - -import Development.IDE.GHC.Compat (WarningFlag (Opt_WarnUnrecognisedPragmas), - wopt) import Development.IDE.Spans.Pragmas (LineSplitTextEdits (LineSplitTextEdits), NextPragmaInfo (NextPragmaInfo), getNextPragmaInfo, @@ -118,8 +115,10 @@ import Development.IDE.Spans.Pragmas (LineSplitTe lineSplitInsertTextEdit, lineSplitTextEdits, nextPragmaLine) +import GHC.Generics (Generic) import System.Environment (setEnv, unsetEnv) +import Text.Regex.TDFA.Text () -- --------------------------------------------------------------------- #ifdef HLINT_ON_GHC_LIB diff --git a/plugins/hls-tactics-plugin/src/Wingman/LanguageServer/TacticProviders.hs b/plugins/hls-tactics-plugin/src/Wingman/LanguageServer/TacticProviders.hs index a9ed4e791e..fb6f5693b1 100644 --- a/plugins/hls-tactics-plugin/src/Wingman/LanguageServer/TacticProviders.hs +++ b/plugins/hls-tactics-plugin/src/Wingman/LanguageServer/TacticProviders.hs @@ -160,10 +160,11 @@ commandProvider RunMetaprogram = requireGHC88OrHigher :: TacticProvider -> TacticProvider -requireGHC88OrHigher tp tpd = #if __GLASGOW_HASKELL__ >= 808 +requireGHC88OrHigher tp tpd = tp tpd #else +requireGHC88OrHigher _ _= mempty #endif diff --git a/plugins/hls-tactics-plugin/src/Wingman/Metaprogramming/Parser/Documentation.hs b/plugins/hls-tactics-plugin/src/Wingman/Metaprogramming/Parser/Documentation.hs index 7b047513f8..9c2ff0f632 100644 --- a/plugins/hls-tactics-plugin/src/Wingman/Metaprogramming/Parser/Documentation.hs +++ b/plugins/hls-tactics-plugin/src/Wingman/Metaprogramming/Parser/Documentation.hs @@ -1,4 +1,5 @@ {-# LANGUAGE OverloadedStrings #-} +{-# OPTIONS_GHC -Wno-deprecations #-} module Wingman.Metaprogramming.Parser.Documentation where diff --git a/plugins/hls-tactics-plugin/src/Wingman/Metaprogramming/ProofState.hs b/plugins/hls-tactics-plugin/src/Wingman/Metaprogramming/ProofState.hs index 5563b75c63..02e203a1d3 100644 --- a/plugins/hls-tactics-plugin/src/Wingman/Metaprogramming/ProofState.hs +++ b/plugins/hls-tactics-plugin/src/Wingman/Metaprogramming/ProofState.hs @@ -1,5 +1,7 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE OverloadedStrings #-} +{-# OPTIONS_GHC -Wno-deprecations #-} module Wingman.Metaprogramming.ProofState where diff --git a/plugins/hls-tactics-plugin/src/Wingman/StaticPlugin.hs b/plugins/hls-tactics-plugin/src/Wingman/StaticPlugin.hs index ce7fb8863b..563a1fcc63 100644 --- a/plugins/hls-tactics-plugin/src/Wingman/StaticPlugin.hs +++ b/plugins/hls-tactics-plugin/src/Wingman/StaticPlugin.hs @@ -8,17 +8,21 @@ module Wingman.StaticPlugin , pattern MetaprogramSyntax ) where -import Data.Data import Development.IDE.GHC.Compat import Development.IDE.GHC.Compat.Util import GHC.LanguageExtensions.Type (Extension(EmptyCase, QuasiQuotes)) -import Generics.SYB + import Ide.Types + +#if __GLASGOW_HASKELL__ >= 808 +import Data.Data +import Generics.SYB #if __GLASGOW_HASKELL__ >= 900 import GHC.Driver.Plugins (purePlugin) #else import Plugins (purePlugin) #endif +#endif staticPlugin :: DynFlagsModifications staticPlugin = mempty @@ -44,7 +48,6 @@ pattern MetaprogramSourceText :: SourceText pattern MetaprogramSourceText = SourceText "wingman-meta-program" - pattern WingmanMetaprogram :: FastString -> HsExpr p pattern WingmanMetaprogram mp <- #if __GLASGOW_HASKELL__ >= 900 @@ -56,7 +59,6 @@ pattern WingmanMetaprogram mp <- #endif - enableQuasiQuotes :: DynFlags -> DynFlags enableQuasiQuotes = flip xopt_set QuasiQuotes @@ -80,11 +82,6 @@ metaprogrammingPlugin = } worker :: Monad m => [CommandLineOption] -> ModSummary -> HsParsedModule -> m HsParsedModule worker _ _ pm = pure $ pm { hpm_module = addMetaprogrammingSyntax $ hpm_module pm } -#endif - -metaprogramHoleName :: OccName -metaprogramHoleName = mkVarOcc "_$metaprogram" - mkMetaprogram :: SrcSpan -> FastString -> HsExpr GhcPs mkMetaprogram ss mp = @@ -98,14 +95,16 @@ mkMetaprogram ss mp = $ L ss $ mkRdrUnqual metaprogramHoleName - addMetaprogrammingSyntax :: Data a => a -> a addMetaprogrammingSyntax = everywhere $ mkT $ \case L ss (MetaprogramSyntax mp) -> L ss $ mkMetaprogram ss mp (x :: LHsExpr GhcPs) -> x +#endif +metaprogramHoleName :: OccName +metaprogramHoleName = mkVarOcc "_$metaprogram" pattern MetaprogramSyntax :: FastString -> HsExpr GhcPs pattern MetaprogramSyntax mp <- @@ -119,4 +118,3 @@ pattern MetaprogramSyntax mp <- (mkRdrUnqual $ mkVarOcc "wingman") noSrcSpan mp - diff --git a/plugins/hls-tactics-plugin/src/Wingman/Types.hs b/plugins/hls-tactics-plugin/src/Wingman/Types.hs index df64258f46..621cc9752e 100644 --- a/plugins/hls-tactics-plugin/src/Wingman/Types.hs +++ b/plugins/hls-tactics-plugin/src/Wingman/Types.hs @@ -38,7 +38,6 @@ import GHC.Exts (fromString) import GHC.Generics import GHC.SourceGen (var) import Refinery.ProofState -import Refinery.Tactic import Refinery.Tactic.Internal (TacticT(TacticT), RuleT (RuleT)) import System.IO.Unsafe (unsafePerformIO) import Wingman.Debug diff --git a/stack-9.0.2.yaml b/stack-9.0.2.yaml index 8a6fc004b3..841b11c2fe 100644 --- a/stack-9.0.2.yaml +++ b/stack-9.0.2.yaml @@ -19,8 +19,8 @@ packages: - ./plugins/hls-rename-plugin - ./plugins/hls-retrie-plugin - ./plugins/hls-splice-plugin -# - ./plugins/hls-tactics-plugin -# - ./plugins/hls-brittany-plugin +- ./plugins/hls-tactics-plugin +- ./plugins/hls-brittany-plugin # - ./plugins/hls-stylish-haskell-plugin - ./plugins/hls-floskell-plugin - ./plugins/hls-fourmolu-plugin @@ -48,6 +48,7 @@ extra-deps: - implicit-hie-cradle-0.3.0.5 - monad-dijkstra-0.1.1.3 - multistate-0.8.0.3 +- refinery-0.4.0.0 - retrie-1.1.0.0 - unix-compat-0.5.4 @@ -99,9 +100,7 @@ flags: pedantic: true ignore-plugins-ghc-bounds: true - tactic: false # Dependencies fail stylishHaskell: false - brittany: false retrie: BuildExecutable: false diff --git a/stack-9.2.1.yaml b/stack-9.2.1.yaml index 597fd8b587..3929e3d041 100644 --- a/stack-9.2.1.yaml +++ b/stack-9.2.1.yaml @@ -10,47 +10,58 @@ packages: - ./hls-test-utils - ./shake-bench - ./plugins/hls-call-hierarchy-plugin -- ./plugins/hls-class-plugin +# - ./plugins/hls-class-plugin # - ./plugins/hls-haddock-comments-plugin # - ./plugins/hls-eval-plugin - ./plugins/hls-explicit-imports-plugin - ./plugins/hls-qualify-imported-names-plugin -# - ./plugins/hls-refine-imports-plugin +- ./plugins/hls-refine-imports-plugin # - ./plugins/hls-hlint-plugin -# - ./plugins/hls-rename-plugin +- ./plugins/hls-rename-plugin # - ./plugins/hls-retrie-plugin # - ./plugins/hls-splice-plugin # - ./plugins/hls-tactics-plugin # - ./plugins/hls-brittany-plugin # - ./plugins/hls-stylish-haskell-plugin -# - ./plugins/hls-floskell-plugin -# - ./plugins/hls-fourmolu-plugin +- ./plugins/hls-floskell-plugin +- ./plugins/hls-fourmolu-plugin - ./plugins/hls-pragmas-plugin - ./plugins/hls-module-name-plugin -# - ./plugins/hls-ormolu-plugin +- ./plugins/hls-ormolu-plugin # - ./plugins/hls-alternate-number-format-plugin extra-deps: - +- aeson-2.0.3.0 +- base-compat-0.12.1 +- base-compat-batteries-0.12.1 +- brittany-0.14.0.0 +- butcher-1.3.3.2 - bytestring-encoding-0.1.1.0 +- data-tree-print-0.1.0.2 - dependent-map-0.4.0.0 -- extra-1.7.9 # for ghcide, https://github.com/haskell/haskell-language-server/pull/2131 -- hspec-2.7.10 # for hls-test-utils -- hspec-core-2.7.10 # for hls-test-utils -- some-1.0.2 # for dependent-sum, https://github.com/obsidiansystems/dependent-sum/issues/66 +- dependent-sum-0.7.1.0 +- extra-1.7.10 - floskell-0.10.6 +- fourmolu-0.5.0.0 +- ghc-exactprint-1.4.1 +- ghc-lib-9.2.1.20220109 +- ghc-lib-parser-9.2.1.20220109 +- ghc-lib-parser-ex-9.2.0.1 - heapsize-0.3.0.1 - hiedb-0.4.1.0 +- hspec-2.7.10 # for hls-test-utils +- hspec-core-2.7.10 # for hls-test-utils - implicit-hie-0.1.2.6 - implicit-hie-cradle-0.5.0.0 +- lens-5.1 - monad-dijkstra-0.1.1.3 -- retrie-1.1.0.0 +- multistate-0.8.0.3 +- ormolu-0.4.0.0 +- refinery-0.4.0.0 +- retrie-1.2.0.1 +- some-1.0.2 # for dependent-sum, https://github.com/obsidiansystems/dependent-sum/issues/66 - unix-compat-0.5.4 -# hls-graph dependencies -- stm-containers-1.2 -- stm-hamt-1.2.0.7 - # shake-bench dependencies - Chart-1.9.3 - Chart-diagrams-1.9.3 @@ -59,17 +70,27 @@ extra-deps: - statestack-0.3 - operational-0.2.4.1 +# hls-graph dependencies +- stm-containers-1.2 +- stm-hamt-1.2.0.7 + # primitive-unlifted-1.0.0 is not buildable with ghc-9.0.2 # see https://gitlab.haskell.org/ghc/ghc/-/issues/20908 - primitive-unlifted-0.1.3.1 - primitive-extras-0.10.1.4 +# for ghcide test suite +- ghc-typelits-knownnat-0.7.6 +- ghc-typelits-natnormalise-0.7.6 + # boot libraries -- Cabal-3.6.2.0 -- directory-1.3.7.0 +- Cabal-3.6.0.0 +- directory-1.3.6.2 - ghc-boot-9.2.1 - process-1.6.13.2 -- time-1.12.1 +- time-1.11.1.1 +- unix-2.7.2.2 +- Win32-2.12.0.1 # currently needed for ghcide>extra, etc. allow-newer: true @@ -92,20 +113,14 @@ flags: ignore-plugins-ghc-bounds: true alternateNumberFormat: false brittany: false - callhierarchy: false class: false eval: false - floskell: false - fourmolu: false haddockComments: false hlint: false - importLens: false - ormolu: false retrie: false splice: false stylishhaskell: false tactic: false - importLens: false retrie: BuildExecutable: false diff --git a/test/functional/Completion.hs b/test/functional/Completion.hs index 5b5052f1ac..cd816d90fb 100644 --- a/test/functional/Completion.hs +++ b/test/functional/Completion.hs @@ -37,14 +37,15 @@ tests = testGroup "completions" [ compls <- getCompletions doc (Position 5 9) let item = head $ filter ((== "putStrLn") . (^. label)) compls resolvedRes <- request SCompletionItemResolve item - let Right resolved = resolvedRes ^. result - liftIO $ print resolved - liftIO $ do - resolved ^. label @?= "putStrLn" - resolved ^. kind @?= Just CiFunction - resolved ^. detail @?= Just "String -> IO ()\nPrelude" - resolved ^. insertTextFormat @?= Just Snippet - resolved ^. insertText @?= Just "putStrLn ${1:String}" + let eResolved = resolvedRes ^. result + case eResolved of + Right resolved -> liftIO $ do + resolved ^. label @?= "putStrLn" + resolved ^. kind @?= Just CiFunction + resolved ^. detail @?= Just "String -> IO ()\nPrelude" + resolved ^. insertTextFormat @?= Just Snippet + resolved ^. insertText @?= Just "putStrLn ${1:String}" + _ -> error $ "Unexpected resolved value: " ++ show eResolved , testCase "completes imports" $ runSession (hlsCommand <> " --test") fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" diff --git a/test/functional/FunctionalCodeAction.hs b/test/functional/FunctionalCodeAction.hs index fd12fe39d1..321ba401b5 100644 --- a/test/functional/FunctionalCodeAction.hs +++ b/test/functional/FunctionalCodeAction.hs @@ -56,11 +56,13 @@ renameTests = testGroup "rename suggestions" [ cars <- getAllCodeActions doc cmd <- liftIO $ inspectCommand cars ["Replace with", "putStrLn"] - let Just (List [args]) = cmd ^. L.arguments - editParams = args ^. ix "fallbackWorkspaceEdit" . _Object - liftIO $ do - (editParams & has (ix "changes")) @? "Contains changes" - not (editParams & has (ix "documentChanges")) @? "Doesn't contain documentChanges" + let mbArgs = cmd ^. L.arguments + case mbArgs of + Just (List [args]) -> liftIO $ do + let editParams = args ^. ix "fallbackWorkspaceEdit" . _Object + (editParams & has (ix "changes")) @? "Contains changes" + not (editParams & has (ix "documentChanges")) @? "Doesn't contain documentChanges" + _ -> error $ "Unexpected arguments: " ++ show mbArgs executeCommand cmd _ <- anyRequest @@ -115,14 +117,16 @@ packageTests = testGroup "add package suggestions" [ in liftIO $ any (`T.isPrefixOf` (diag ^. L.message)) prefixes @? "Contains prefix" acts <- getAllCodeActions doc - let (InR action:_) = acts + case acts of + (InR action:_) -> do + liftIO $ do + action ^. L.title @?= "Add text as a dependency" + action ^. L.kind @?= Just CodeActionQuickFix + "package:add" `T.isSuffixOf` (action ^. L.command . _Just . L.command) @? "Command contains package:add" - liftIO $ do - action ^. L.title @?= "Add text as a dependency" - action ^. L.kind @?= Just CodeActionQuickFix - "package:add" `T.isSuffixOf` (action ^. L.command . _Just . L.command) @? "Command contains package:add" + executeCodeAction action - executeCodeAction action + _ -> error $ "Unexpected code actions: " ++ show acts contents <- skipManyTill anyMessage $ getDocumentEdit . TextDocumentIdentifier =<< getDocUri "add-package-test.cabal" liftIO $ @@ -175,14 +179,18 @@ redundantImportTests = testGroup "redundant import code actions" [ liftIO $ actionTitles `shouldContain` ["Remove import", "Remove all redundant imports"] - let Just removeAction = find (\x -> x ^. L.title == "Remove import") allActions + let mbRemoveAction = find (\x -> x ^. L.title == "Remove import") allActions - liftIO $ do - forM_ allActions $ \a -> a ^. L.kind @?= Just CodeActionQuickFix - forM_ allActions $ \a -> a ^. L.command @?= Nothing - forM_ allActions $ \a -> isJust (a ^. L.edit) @? "Has edit" + case mbRemoveAction of + Just removeAction -> do + liftIO $ do + forM_ allActions $ \a -> a ^. L.kind @?= Just CodeActionQuickFix + forM_ allActions $ \a -> a ^. L.command @?= Nothing + forM_ allActions $ \a -> isJust (a ^. L.edit) @? "Has edit" + + executeCodeAction removeAction - executeCodeAction removeAction + Nothing -> error $ "Unexpected code actions: " ++ show allActions -- No command/applyworkspaceedit should be here, since action -- provides workspace edit property which skips round trip to diff --git a/test/functional/HieBios.hs b/test/functional/HieBios.hs index 1ab9f2837e..df742abcdb 100644 --- a/test/functional/HieBios.hs +++ b/test/functional/HieBios.hs @@ -17,9 +17,12 @@ tests = testGroup "hie-bios" [ runSession hlsCommand fullCaps "test/testdata/hieBiosMainIs" $ do doc <- openDoc "Main.hs" "haskell" Just mainHoverText <- getHover doc (Position 3 1) - let (HoverContents (MarkupContent _ x)) = mainHoverText ^. L.contents - liftIO $ "main :: IO ()" `T.isInfixOf` x - @? "found hover text for main" + let hoverContents = mainHoverText ^. L.contents + case hoverContents of + (HoverContents (MarkupContent _ x)) -> do + liftIO $ "main :: IO ()" `T.isInfixOf` x + @? "found hover text for main" + _ -> error $ "Unexpected hover contents: " ++ show hoverContents , testCase "reports errors in hie.yaml" $ do writeFile (hieBiosErrorPath "hie.yaml") "" diff --git a/test/functional/Progress.hs b/test/functional/Progress.hs index d131fc6175..e4f84f82ce 100644 --- a/test/functional/Progress.hs +++ b/test/functional/Progress.hs @@ -44,16 +44,19 @@ tests = [] -- this is a test so exceptions result in fails - let LSP.List [evalLens] = getResponseResult codeLensResponse - let command = evalLens ^?! L.command . _Just - - _ <- sendRequest SWorkspaceExecuteCommand $ - ExecuteCommandParams - Nothing - (command ^. L.command) - (decode $ encode $ fromJust $ command ^. L.arguments) - - expectProgressMessages ["Evaluating"] activeProgressTokens + let response = getResponseResult codeLensResponse + case response of + LSP.List [evalLens] -> do + let command = evalLens ^?! L.command . _Just + + _ <- sendRequest SWorkspaceExecuteCommand $ + ExecuteCommandParams + Nothing + (command ^. L.command) + (decode $ encode $ fromJust $ command ^. L.arguments) + + expectProgressMessages ["Evaluating"] activeProgressTokens + _ -> error $ "Unexpected response result: " ++ show response , requiresOrmoluPlugin $ testCase "ormolu plugin sends progress notifications" $ do runSession hlsCommand progressCaps "test/testdata/format" $ do sendConfigurationChanged (formatLspConfig "ormolu")