diff --git a/cabal.project b/cabal.project index 4d64265352..e0ffe04263 100644 --- a/cabal.project +++ b/cabal.project @@ -10,8 +10,8 @@ packages: source-repository-package type: git - location: https://github.com/bubba/brittany.git - tag: c59655f10d5ad295c2481537fc8abf0a297d9d1c + location: https://github.com/lspitzner/brittany.git + tag: 0a710ab27147d4f7981fe4ca343b43136ee36919 tests: true @@ -25,6 +25,6 @@ package ghcide write-ghc-environment-files: never -index-state: 2020-12-03T03:58:05Z +index-state: 2020-12-09T06:57:58Z allow-newer: data-tree-print:base diff --git a/exe/Wrapper.hs b/exe/Wrapper.hs index 61dc26cd99..8a0c452be1 100644 --- a/exe/Wrapper.hs +++ b/exe/Wrapper.hs @@ -7,7 +7,8 @@ import Control.Monad.Extra import Data.Foldable import Data.List import Data.Void -import HIE.Bios +import Development.IDE.Session (findCradle, defaultLoadingOptions) +import HIE.Bios hiding (findCradle) import HIE.Bios.Environment import HIE.Bios.Types import Ide.Arguments @@ -135,7 +136,7 @@ getRuntimeGhcVersion' cradle = do -- of the project that may or may not be accurate. findLocalCradle :: FilePath -> IO (Cradle Void) findLocalCradle fp = do - cradleConf <- findCradle fp + cradleConf <- (findCradle defaultLoadingOptions) fp crdl <- case cradleConf of Just yaml -> do hPutStrLn stderr $ "Found \"" ++ yaml ++ "\" for \"" ++ fp ++ "\"" diff --git a/ghcide b/ghcide index 9b8aaf9b06..27b4250bb2 160000 --- a/ghcide +++ b/ghcide @@ -1 +1 @@ -Subproject commit 9b8aaf9b06846571cc0b5d46680e686e4f9153a3 +Subproject commit 27b4250bb245cbe44c2d63eeda5743d9807fe4a0 diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index 5391928d54..fca3471ec5 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -59,10 +59,9 @@ library , containers , data-default , ghc - , ghcide >=0.5 + , ghcide >=0.6 , gitrev , haskell-lsp ^>=0.22 - , hie-bios >=0.6.1 && <0.8 , hls-plugin-api >=0.5 , hslogger , optparse-applicative @@ -170,6 +169,7 @@ executable haskell-language-server-wrapper build-depends: , ghc , ghc-paths + , ghcide , gitrev , haskell-language-server , hie-bios diff --git a/nix/default.nix b/nix/default.nix index 625382b3cd..02ed1cbea1 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -17,6 +17,7 @@ let haskellPackages.extend (pkgs.haskell.lib.packageSourceOverrides { haskell-language-server = gitignoreSource ../.; ghcide = gitignoreSource ../ghcide; + shake-bench = gitignoreSource ../ghcide/shake-bench; hie-compat = gitignoreSource ../ghcide/hie-compat; hls-plugin-api = gitignoreSource ../hls-plugin-api; hls-tactics-plugin = gitignoreSource ../plugins/tactics; diff --git a/shell.nix b/shell.nix index c91cacdbed..0b0df7427e 100644 --- a/shell.nix +++ b/shell.nix @@ -26,6 +26,7 @@ let defaultCompiler = "ghc" + lib.replaceStrings ["."] [""] haskellPackages.ghc. packages = p: [ p.haskell-language-server p.ghcide + p.shake-bench p.hie-compat p.hls-plugin-api p.hls-tactics-plugin diff --git a/src/Ide/Main.hs b/src/Ide/Main.hs index 6feef3702e..4eda145c40 100644 --- a/src/Ide/Main.hs +++ b/src/Ide/Main.hs @@ -34,19 +34,18 @@ import Development.IDE.Core.Shake import Development.IDE.LSP.LanguageServer import Development.IDE.LSP.Protocol import Development.IDE.Plugin -import Development.IDE.Session +import Development.IDE.Session (loadSession, findCradle, defaultLoadingOptions) import Development.IDE.Types.Diagnostics import Development.IDE.Types.Location import Development.IDE.Types.Logger import Development.IDE.Types.Options -import HIE.Bios.Cradle import qualified Language.Haskell.LSP.Core as LSP import Ide.Arguments import Ide.Logger import Ide.Plugin import Ide.Version import Ide.Plugin.Config -import Ide.Types (IdePlugins, ipMap) +import Ide.Types (IdePlugins, ipMap) import Language.Haskell.LSP.Messages import Language.Haskell.LSP.Types import qualified System.Directory.Extra as IO @@ -158,7 +157,7 @@ runLspMode lspArgs@LspArguments{..} idePlugins = do putStrLn $ "Found " ++ show (length files) ++ " files" putStrLn "\nStep 2/4: Looking for hie.yaml files that control setup" - cradles <- mapM findCradle files + cradles <- mapM (findCradle defaultLoadingOptions) files let ucradles = nubOrd cradles let n = length ucradles putStrLn $ "Found " ++ show n ++ " cradle" ++ ['s' | n /= 1] diff --git a/stack-8.10.1.yaml b/stack-8.10.1.yaml index 08b8638274..c3aa894e3b 100644 --- a/stack-8.10.1.yaml +++ b/stack-8.10.1.yaml @@ -14,23 +14,25 @@ ghc-options: "$everything": -haddock extra-deps: -- github: bubba/brittany - commit: c59655f10d5ad295c2481537fc8abf0a297d9d1c +- github: lspitzner/brittany + commit: 0a710ab27147d4f7981fe4ca343b43136ee36919 - Cabal-3.0.2.0 - clock-0.7.2 -- data-tree-print-0.1.0.2 +- data-tree-print-0.1.0.2@rev:2 - floskell-0.10.4 - fourmolu-0.3.0.0 - ghc-lib-8.10.2.20200916 - ghc-lib-parser-8.10.2.20200916 +- heapsize-0.3.0 - hie-bios-0.7.1 -- hlint-3.2 +- hlint-3.2.3 - HsYAML-aeson-0.2.0.0@rev:2 - implicit-hie-cradle-0.3.0.2 - implicit-hie-0.1.2.5 - lsp-test-0.11.0.6 - monad-dijkstra-0.1.1.2 -- opentelemetry-0.4.2 +- opentelemetry-0.6.1 +- opentelemetry-extra-0.6.1 - ormolu-0.1.4.1 - refinery-0.3.0.0 - retrie-0.1.1.1 @@ -44,9 +46,6 @@ flags: retrie: BuildExecutable: false -# for data-tree-print's bounds on base (>=4.8 && <4.14); using base-4.14.0.0. -allow-newer: true - nix: packages: [ icu libcxx zlib ] diff --git a/stack-8.10.2.yaml b/stack-8.10.2.yaml index 4767dffd0f..f55be2c34e 100644 --- a/stack-8.10.2.yaml +++ b/stack-8.10.2.yaml @@ -1,4 +1,4 @@ -resolver: nightly-2020-11-22 +resolver: nightly-2020-12-09 packages: - . @@ -14,18 +14,18 @@ ghc-options: "$everything": -haddock extra-deps: -- github: bubba/brittany - commit: c59655f10d5ad295c2481537fc8abf0a297d9d1c +- github: lspitzner/brittany + commit: 0a710ab27147d4f7981fe4ca343b43136ee36919 - Cabal-3.0.2.0 - clock-0.7.2 -- data-tree-print-0.1.0.2 +- data-tree-print-0.1.0.2@rev:2 - floskell-0.10.4 - fourmolu-0.3.0.0 +- heapsize-0.3.0 - implicit-hie-cradle-0.3.0.2 - implicit-hie-0.1.2.5 - lsp-test-0.11.0.6 - monad-dijkstra-0.1.1.2 -- opentelemetry-0.4.2 - refinery-0.3.0.0 - retrie-0.1.1.1 - stylish-haskell-0.12.2.0 @@ -38,9 +38,6 @@ flags: retrie: BuildExecutable: false -# for data-tree-print's bounds on base (>=4.8 && <4.14); using base-4.14.0.0. -allow-newer: true - nix: packages: [ icu libcxx zlib ] diff --git a/stack-8.6.4.yaml b/stack-8.6.4.yaml index fc1ab647f6..a085023a34 100644 --- a/stack-8.6.4.yaml +++ b/stack-8.6.4.yaml @@ -19,8 +19,8 @@ extra-deps: - apply-refact-0.8.2.1 - ansi-terminal-0.10.3 - base-compat-0.10.5 -- github: bubba/brittany - commit: c59655f10d5ad295c2481537fc8abf0a297d9d1c +- github: lspitzner/brittany + commit: 0a710ab27147d4f7981fe4ca343b43136ee36919 - butcher-1.3.3.1 - Cabal-3.0.2.0 - cabal-plan-0.6.2.0 @@ -32,17 +32,21 @@ extra-deps: - fuzzy-0.1.0.0 # - ghcide-0.1.0 - ghc-check-0.5.0.1 +- ghc-events-0.13.0 - ghc-exactprint-0.6.3.2 - ghc-lib-8.10.2.20200916 - ghc-lib-parser-8.10.2.20200916 - ghc-lib-parser-ex-8.10.0.16 - ghc-source-gen-0.4.0.0 +- ghc-trace-events-0.1.2.1 - haddock-api-2.22.0@rev:1 - haddock-library-1.8.0 +- hashable-1.3.0.0 - haskell-lsp-0.22.0.0 - haskell-lsp-types-0.22.0.0 +- heapsize-0.3.0 - hie-bios-0.7.1 -- hlint-3.2 +- hlint-3.2.3 - HsYAML-0.2.1.0@rev:1 - HsYAML-aeson-0.2.0.0@rev:2 - implicit-hie-cradle-0.3.0.2 @@ -51,7 +55,8 @@ extra-deps: - lens-4.18 - lsp-test-0.11.0.6 - monad-dijkstra-0.1.1.2 -- opentelemetry-0.4.2 +- opentelemetry-0.6.1 +- opentelemetry-extra-0.6.1 - optics-core-0.2 - optparse-applicative-0.15.1.0 - ormolu-0.1.4.1 diff --git a/stack-8.6.5.yaml b/stack-8.6.5.yaml index 406b28464f..304a35f334 100644 --- a/stack-8.6.5.yaml +++ b/stack-8.6.5.yaml @@ -18,8 +18,8 @@ extra-deps: - apply-refact-0.8.2.1 - ansi-terminal-0.10.3 - base-compat-0.10.5 -- github: bubba/brittany - commit: c59655f10d5ad295c2481537fc8abf0a297d9d1c +- github: lspitzner/brittany + commit: 0a710ab27147d4f7981fe4ca343b43136ee36919 - butcher-1.3.3.1 - Cabal-3.0.2.0 - cabal-plan-0.6.2.0 @@ -31,17 +31,21 @@ extra-deps: - fuzzy-0.1.0.0 # - ghcide-0.1.0 - ghc-check-0.5.0.1 +- ghc-events-0.13.0 - ghc-exactprint-0.6.3.2 - ghc-lib-8.10.2.20200916 - ghc-lib-parser-8.10.2.20200916 - ghc-lib-parser-ex-8.10.0.16 - ghc-source-gen-0.4.0.0 +- ghc-trace-events-0.1.2.1 - haddock-api-2.22.0@rev:1 - haddock-library-1.8.0 +- hashable-1.3.0.0 - haskell-lsp-0.22.0.0 - haskell-lsp-types-0.22.0.0 +- heapsize-0.3.0 - hie-bios-0.7.1 -- hlint-3.2 +- hlint-3.2.3 - HsYAML-0.2.1.0@rev:1 - HsYAML-aeson-0.2.0.0@rev:2 - implicit-hie-cradle-0.3.0.2 @@ -50,7 +54,8 @@ extra-deps: - lens-4.18 - lsp-test-0.11.0.6 - monad-dijkstra-0.1.1.2 -- opentelemetry-0.4.2 +- opentelemetry-0.6.1 +- opentelemetry-extra-0.6.1 - optics-core-0.2 - optparse-applicative-0.15.1.0 - ormolu-0.1.4.1 diff --git a/stack-8.8.2.yaml b/stack-8.8.2.yaml index bbdbb4dbd8..8bc5919b8a 100644 --- a/stack-8.8.2.yaml +++ b/stack-8.8.2.yaml @@ -15,9 +15,8 @@ ghc-options: extra-deps: - aeson-1.5.2.0 -- apply-refact-0.8.2.1 -- github: bubba/brittany - commit: c59655f10d5ad295c2481537fc8abf0a297d9d1c +- github: lspitzner/brittany + commit: 0a710ab27147d4f7981fe4ca343b43136ee36919 - butcher-1.3.3.2 - bytestring-trie-0.2.5.0 - clock-0.7.2 @@ -25,18 +24,21 @@ extra-deps: - extra-1.7.3 - floskell-0.10.4 - fourmolu-0.3.0.0 -# - ghcide-0.1.0 +# - ghcide-0.6.0 - ghc-check-0.5.0.1 +- ghc-events-0.13.0 - ghc-exactprint-0.6.3.2 - ghc-lib-8.10.2.20200916 - ghc-lib-parser-8.10.2.20200916 - ghc-lib-parser-ex-8.10.0.16 +- ghc-trace-events-0.1.2.1 - haddock-library-1.8.0 - haskell-lsp-0.22.0.0 - haskell-lsp-types-0.22.0.0 - haskell-src-exts-1.21.1 +- heapsize-0.3.0 - hie-bios-0.7.1 -- hlint-3.2 +- hlint-3.2.3 - hoogle-5.0.17.11 - hsimport-0.11.0 - HsYAML-0.2.1.0@rev:1 @@ -46,7 +48,8 @@ extra-deps: - implicit-hie-0.1.2.5 - lsp-test-0.11.0.6 - monad-dijkstra-0.1.1.2 -- opentelemetry-0.4.2 +- opentelemetry-0.6.1 +- opentelemetry-extra-0.6.1 - ormolu-0.1.4.1 - refinery-0.3.0.0 - retrie-0.1.1.1 diff --git a/stack-8.8.3.yaml b/stack-8.8.3.yaml index e40078b1d8..a53ea1cb70 100644 --- a/stack-8.8.3.yaml +++ b/stack-8.8.3.yaml @@ -16,8 +16,8 @@ ghc-options: extra-deps: - aeson-1.5.2.0 - apply-refact-0.8.2.1 -- github: bubba/brittany - commit: c59655f10d5ad295c2481537fc8abf0a297d9d1c +- github: lspitzner/brittany + commit: 0a710ab27147d4f7981fe4ca343b43136ee36919 - bytestring-trie-0.2.5.0 - cabal-plan-0.6.2.0 - clock-0.7.2 @@ -25,13 +25,15 @@ extra-deps: - extra-1.7.3 - floskell-0.10.4 - fourmolu-0.3.0.0 -# - ghcide-0.1.0 +# - ghcide-0.6.0 - ghc-exactprint-0.6.3.2 - ghc-lib-8.10.2.20200916 - ghc-lib-parser-8.10.2.20200916 +- ghc-trace-events-0.1.2.1 - haskell-src-exts-1.21.1 +- heapsize-0.3.0 - hie-bios-0.7.1 -- hlint-3.2 +- hlint-3.2.3 - HsYAML-aeson-0.2.0.0@rev:2 - hoogle-5.0.17.11 - hsimport-0.11.0 @@ -40,6 +42,8 @@ extra-deps: - implicit-hie-0.1.2.5 - lsp-test-0.11.0.6 - monad-dijkstra-0.1.1.2 +- opentelemetry-0.6.1 +- opentelemetry-extra-0.6.1 - ormolu-0.1.4.1 - refinery-0.3.0.0 - retrie-0.1.1.1 diff --git a/stack-8.8.4.yaml b/stack-8.8.4.yaml index 1a427717d0..fc50d9b7d7 100644 --- a/stack-8.8.4.yaml +++ b/stack-8.8.4.yaml @@ -1,4 +1,4 @@ -resolver: lts-16.23 +resolver: lts-16.25 packages: - . @@ -16,20 +16,21 @@ ghc-options: extra-deps: - aeson-1.5.2.0 - apply-refact-0.8.2.1 -- github: bubba/brittany - commit: c59655f10d5ad295c2481537fc8abf0a297d9d1c +- github: lspitzner/brittany + commit: 0a710ab27147d4f7981fe4ca343b43136ee36919 - bytestring-trie-0.2.5.0 - cabal-plan-0.6.2.0 - clock-0.7.2 - constrained-dynamic-0.1.0.0 -- extra-1.7.3 - floskell-0.10.4 - fourmolu-0.3.0.0 -# - ghcide-0.1.0 +# - ghcide-0.6.0 - ghc-exactprint-0.6.3.2 +- ghc-trace-events-0.1.2.1 - haskell-src-exts-1.21.1 +- heapsize-0.3.0 - hie-bios-0.7.1 -- hlint-3.2 +- hlint-3.2.3 - HsYAML-aeson-0.2.0.0@rev:2 - hoogle-5.0.17.11 - hsimport-0.11.0 @@ -38,6 +39,8 @@ extra-deps: - implicit-hie-0.1.2.5 - lsp-test-0.11.0.6 - monad-dijkstra-0.1.1.2 +- opentelemetry-0.6.1 +- opentelemetry-extra-0.6.1 - refinery-0.3.0.0 - retrie-0.1.1.1 - semigroups-0.18.5 diff --git a/stack.yaml b/stack.yaml index 406b28464f..238c04e01d 100644 --- a/stack.yaml +++ b/stack.yaml @@ -18,8 +18,8 @@ extra-deps: - apply-refact-0.8.2.1 - ansi-terminal-0.10.3 - base-compat-0.10.5 -- github: bubba/brittany - commit: c59655f10d5ad295c2481537fc8abf0a297d9d1c +- github: lspitzner/brittany + commit: 0a710ab27147d4f7981fe4ca343b43136ee36919 - butcher-1.3.3.1 - Cabal-3.0.2.0 - cabal-plan-0.6.2.0 @@ -29,17 +29,21 @@ extra-deps: - floskell-0.10.4 - fourmolu-0.3.0.0 - fuzzy-0.1.0.0 -# - ghcide-0.1.0 +# - ghcide-0.6.0 - ghc-check-0.5.0.1 - ghc-exactprint-0.6.3.2 +- ghc-events-0.13.0 - ghc-lib-8.10.2.20200916 - ghc-lib-parser-8.10.2.20200916 - ghc-lib-parser-ex-8.10.0.16 - ghc-source-gen-0.4.0.0 +- ghc-trace-events-0.1.2.1 - haddock-api-2.22.0@rev:1 - haddock-library-1.8.0 +- hashable-1.3.0.0 - haskell-lsp-0.22.0.0 - haskell-lsp-types-0.22.0.0 +- heapsize-0.3.0 - hie-bios-0.7.1 - hlint-3.2 - HsYAML-0.2.1.0@rev:1 @@ -50,7 +54,8 @@ extra-deps: - lens-4.18 - lsp-test-0.11.0.6 - monad-dijkstra-0.1.1.2 -- opentelemetry-0.4.2 +- opentelemetry-0.6.1 +- opentelemetry-extra-0.6.1 - optics-core-0.2 - optparse-applicative-0.15.1.0 - ormolu-0.1.4.1 diff --git a/test/functional/Completion.hs b/test/functional/Completion.hs index d49626c000..fef31e7183 100644 --- a/test/functional/Completion.hs +++ b/test/functional/Completion.hs @@ -29,8 +29,8 @@ tests = testGroup "completions" [ item ^. label @?= "putStrLn" item ^. kind @?= Just CiFunction item ^. detail @?= Just ":: String -> IO ()" - item ^. insertTextFormat @?= Just PlainText - item ^. insertText @?= Nothing + item ^. insertTextFormat @?= Just Snippet + item ^. insertText @?= Just "putStrLn ${1:String}" , ignoreTestBecause "no support for itemCompletion/resolve requests" $ testCase "itemCompletion/resolve works" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do @@ -105,8 +105,8 @@ tests = testGroup "completions" [ liftIO $ do item ^. label @?= "LANGUAGE" item ^. kind @?= Just CiKeyword - item ^. insertTextFormat @?= Just PlainText - item ^. insertText @?= Nothing + item ^. insertTextFormat @?= Just Snippet + item ^. insertText @?= Just "LANGUAGE ${1:extension} #-}" , testCase "completes pragmas no close" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" @@ -120,8 +120,8 @@ tests = testGroup "completions" [ liftIO $ do item ^. label @?= "LANGUAGE" item ^. kind @?= Just CiKeyword - item ^. insertTextFormat @?= Just PlainText - item ^. insertText @?= Nothing + item ^. insertTextFormat @?= Just Snippet + item ^. insertText @?= Just "LANGUAGE ${1:extension}" , testCase "completes options pragma" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" @@ -135,8 +135,8 @@ tests = testGroup "completions" [ liftIO $ do item ^. label @?= "OPTIONS_GHC" item ^. kind @?= Just CiKeyword - item ^. insertTextFormat @?= Just PlainText - item ^. insertText @?= Nothing + item ^. insertTextFormat @?= Just Snippet + item ^. insertText @?= Just "OPTIONS_GHC -${1:option} #-}" , testCase "completes ghc options pragma values" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" @@ -199,7 +199,6 @@ tests = testGroup "completions" [ snippetTests :: TestTree snippetTests = testGroup "snippets" [ - ignoreTestBecause "no support for snippets" $ testCase "work for argumentless constructors" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" _ <- waitForDiagnosticsFrom doc @@ -211,10 +210,9 @@ snippetTests = testGroup "snippets" [ let item = head $ filter ((== "Nothing") . (^. label)) compls liftIO $ do item ^. insertTextFormat @?= Just Snippet - item ^. insertText @?= Just "Nothing" + item ^. insertText @?= Just "Nothing " - , ignoreTestBecause "no support for snippets" $ - testCase "work for polymorphic types" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do + , testCase "work for polymorphic types" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" _ <- waitForDiagnosticsFrom doc @@ -229,8 +227,7 @@ snippetTests = testGroup "snippets" [ item ^. insertTextFormat @?= Just Snippet item ^. insertText @?= Just "foldl ${1:b -> a -> b} ${2:b} ${3:t a}" - , ignoreTestBecause "no support for snippets" $ - testCase "work for complex types" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do + , testCase "work for complex types" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" _ <- waitForDiagnosticsFrom doc @@ -245,8 +242,7 @@ snippetTests = testGroup "snippets" [ item ^. insertTextFormat @?= Just Snippet item ^. insertText @?= Just "mapM ${1:a -> m b} ${2:t a}" - , ignoreTestBecause "no support for snippets" $ - testCase "work for infix functions" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do + , testCase "work for infix functions" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" _ <- waitForDiagnosticsFrom doc @@ -259,10 +255,9 @@ snippetTests = testGroup "snippets" [ item ^. label @?= "filter" item ^. kind @?= Just CiFunction item ^. insertTextFormat @?= Just Snippet - item ^. insertText @?= Just "filter`" + item ^. insertText @?= Just "filter ${1:a -> Bool} ${2:[a]}" - , ignoreTestBecause "no support for snippets" $ - testCase "work for infix functions in backticks" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do + , testCase "work for infix functions in backticks" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" _ <- waitForDiagnosticsFrom doc @@ -275,10 +270,9 @@ snippetTests = testGroup "snippets" [ item ^. label @?= "filter" item ^. kind @?= Just CiFunction item ^. insertTextFormat @?= Just Snippet - item ^. insertText @?= Just "filter" + item ^. insertText @?= Just "filter ${1:a -> Bool} ${2:[a]}" - , ignoreTestBecause "no support for snippets" $ - testCase "work for qualified infix functions" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do + , testCase "work for qualified infix functions" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" _ <- waitForDiagnosticsFrom doc @@ -291,10 +285,9 @@ snippetTests = testGroup "snippets" [ item ^. label @?= "intersperse" item ^. kind @?= Just CiFunction item ^. insertTextFormat @?= Just Snippet - item ^. insertText @?= Just "intersperse`" + item ^. insertText @?= Just "intersperse ${1:a} ${2:[a]}" - , ignoreTestBecause "no support for snippets" $ - testCase "work for qualified infix functions in backticks" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do + , testCase "work for qualified infix functions in backticks" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" _ <- waitForDiagnosticsFrom doc @@ -307,9 +300,10 @@ snippetTests = testGroup "snippets" [ item ^. label @?= "intersperse" item ^. kind @?= Just CiFunction item ^. insertTextFormat @?= Just Snippet - item ^. insertText @?= Just "intersperse" + item ^. insertText @?= Just "intersperse ${1:a} ${2:[a]}" - , testCase "respects lsp configuration" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do + , ignoreTestBecause "ghcide does not support the completionSnippetsOn option" $ + testCase "respects lsp configuration" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" _ <- waitForDiagnosticsFrom doc @@ -372,28 +366,11 @@ contextTests = testGroup "contexts" [ , testCase "completes qualified type suggestions" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Context.hs" "haskell" _ <- waitForDiagnosticsFrom doc - let te = TextEdit (Range (Position 2 17) (Position 2 17)) " -> Conc." - _ <- applyEdit doc te - -- The module doesn't parse right now. So we are using stale data. HLS - -- can give us completions for "Conc." but it can't tell that we are in - -- a context where we expect a type. compls <- getCompletions doc (Position 2 26) liftIO $ do - -- forkOn is an inappropriate completion in a type context. - compls `shouldContainCompl` "forkOn" + compls `shouldNotContainCompl` "forkOn" compls `shouldContainCompl` "MVar" compls `shouldContainCompl` "Chan" - let te' = TextEdit (Range (Position 2 26) (Position 2 26)) "MVar" - _ <- applyEdit doc te' - -- The module can now be parsed. Wait until it has been. - _ <- waitForDiagnosticsFrom doc - -- HLS can see that we are expecting a type. - compls' <- getCompletions doc (Position 2 26) - liftIO $ do - -- forkOn is gone. - compls' `shouldNotContainCompl` "forkOn" - compls' `shouldContainCompl` "MVar" - compls' `shouldContainCompl` "Chan" ] shouldContainCompl :: [CompletionItem] -> T.Text -> Assertion diff --git a/test/functional/FunctionalCodeAction.hs b/test/functional/FunctionalCodeAction.hs index 81bfa2a243..9e7b1149f4 100644 --- a/test/functional/FunctionalCodeAction.hs +++ b/test/functional/FunctionalCodeAction.hs @@ -276,7 +276,7 @@ redundantImportTests = testGroup "redundant import code actions" [ -- provides workspace edit property which skips round trip to -- the server contents <- documentContents doc - liftIO $ contents @?= "module CodeActionRedundant where\nmain :: IO ()\nmain = putStrLn \"hello\"" + liftIO $ contents @?= "{-# OPTIONS_GHC -Wunused-imports #-}\nmodule CodeActionRedundant where\nmain :: IO ()\nmain = putStrLn \"hello\"\n" , testCase "doesn't touch other imports" $ runSession hlsCommand noLiteralCaps "test/testdata/redundantImportTest/" $ do doc <- openDoc "src/MultipleImports.hs" "haskell" @@ -285,7 +285,8 @@ redundantImportTests = testGroup "redundant import code actions" [ executeCommand cmd contents <- documentContents doc liftIO $ (T.lines contents) @?= - [ "module MultipleImports where" + [ "{-# OPTIONS_GHC -Wunused-imports #-}" + , "module MultipleImports where" , "import Data.Maybe" , "foo :: Int" , "foo = fromJust (Just 3)" diff --git a/test/testdata/Highlight.hs b/test/testdata/Highlight.hs index 8d92d18779..b58460b896 100644 --- a/test/testdata/Highlight.hs +++ b/test/testdata/Highlight.hs @@ -2,4 +2,4 @@ module Highlight where foo :: Int foo = 3 bar = foo - where baz = let x = foo in x + where baz = let x = foo in id x diff --git a/test/testdata/completion/Completion.hs b/test/testdata/completion/Completion.hs index d6480903b6..1e394a8f21 100644 --- a/test/testdata/completion/Completion.hs +++ b/test/testdata/completion/Completion.hs @@ -6,4 +6,4 @@ main :: IO () main = putStrLn "hello" foo :: Either a b -> Either a b -foo = id \ No newline at end of file +foo = id id diff --git a/test/testdata/completion/Context.hs b/test/testdata/completion/Context.hs index 45c5befb10..2f6effccb6 100644 --- a/test/testdata/completion/Context.hs +++ b/test/testdata/completion/Context.hs @@ -1,4 +1,4 @@ module Context where import Control.Concurrent as Conc -foo :: Int -> Int -foo x = abs 42 \ No newline at end of file +foo :: Int -> Int -> Conc.MVar +foo x = abs $ id 42 diff --git a/test/testdata/redundantImportTest/src/CodeActionRedundant.hs b/test/testdata/redundantImportTest/src/CodeActionRedundant.hs index 870fc5b16a..f56d232f27 100644 --- a/test/testdata/redundantImportTest/src/CodeActionRedundant.hs +++ b/test/testdata/redundantImportTest/src/CodeActionRedundant.hs @@ -1,4 +1,5 @@ +{-# OPTIONS_GHC -Wunused-imports #-} module CodeActionRedundant where import Data.List main :: IO () -main = putStrLn "hello" \ No newline at end of file +main = putStrLn "hello" diff --git a/test/testdata/redundantImportTest/src/MultipleImports.hs b/test/testdata/redundantImportTest/src/MultipleImports.hs index 4bc5508b61..7a8278b1d3 100644 --- a/test/testdata/redundantImportTest/src/MultipleImports.hs +++ b/test/testdata/redundantImportTest/src/MultipleImports.hs @@ -1,3 +1,4 @@ +{-# OPTIONS_GHC -Wunused-imports #-} module MultipleImports where import Data.Foldable import Data.Maybe