From beaf9157c3d3657860644a77ac1b1ea098dee56b Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Sat, 9 May 2020 17:55:47 +0100 Subject: [PATCH] Use latest mpickering hls, with hover tweaks added --- cabal.project | 7 +----- exe/Main.hs | 47 +++++++++++++++++++---------------- ghcide | 2 +- haskell-language-server.cabal | 2 +- stack-8.6.4.yaml | 6 ++--- stack-8.6.5.yaml | 14 +++++------ stack-8.8.2.yaml | 6 ++--- stack-8.8.3.yaml | 6 ++--- stack.yaml | 9 ++++--- 9 files changed, 47 insertions(+), 52 deletions(-) diff --git a/cabal.project b/cabal.project index 8796ce7560..1133bbf4ec 100644 --- a/cabal.project +++ b/cabal.project @@ -7,11 +7,6 @@ source-repository-package location: https://github.com/DanielG/cabal-helper.git tag: 5b85a4b9e1c6463c94ffa595893ad02c9a3d2ec3 -source-repository-package - type: git - location: https://github.com/mpickering/hie-bios.git - tag: 501cc337691cc9da45ff12db46d8b3af9a2a0eda - source-repository-package type: git location: https://github.com/wz1000/shake @@ -27,4 +22,4 @@ package ghcide write-ghc-environment-files: never -index-state: 2020-05-05T17:33:00Z +index-state: 2020-05-09T16:01:39Z diff --git a/exe/Main.hs b/exe/Main.hs index e73d00f98e..37c6eafc4a 100644 --- a/exe/Main.hs +++ b/exe/Main.hs @@ -54,7 +54,7 @@ import DynFlags (gopt_set, gopt_unset, updOptLevel) import DynFlags (PackageFlag(..), PackageArg(..)) import GHC hiding (def) -import GHC.Check (runTimeVersion, compileTimeVersionFromLibdir) +import GHC.Check ( VersionCheck(..), makeGhcVersionChecker ) -- import GhcMonad import HIE.Bios.Cradle import HIE.Bios.Environment (addCmdOpts, makeDynFlagsAbsolute) @@ -267,12 +267,12 @@ cradleToSessionOpts cradle file = do CradleNone -> fail "'none' cradle is not yet supported" pure opts -emptyHscEnv :: IO HscEnv -emptyHscEnv = do +emptyHscEnv :: IORef NameCache -> IO HscEnv +emptyHscEnv nc = do libdir <- getLibdir env <- runGhc (Just libdir) getSession initDynLinker env - pure env + pure $ setNameCache nc env -- Convert a target to a list of potential absolute paths. -- A TargetModule can be anywhere listed by the supplied include @@ -295,7 +295,9 @@ setNameCache nc hsc = hsc { hsc_NC = nc } -- components mapping to the same hie,yaml file are mapped to the same -- HscEnv which is updated as new components are discovered. loadSession :: FilePath -> Action (FilePath -> Action HscEnvEq) -loadSession dir = liftIO $ do +loadSession dir = do + nc <- ideNc <$> getShakeExtras + liftIO $ do -- Mapping from hie.yaml file to HscEnv, one per hie.yaml file hscEnvs <- newVar Map.empty -- Mapping from a filepath to HscEnv @@ -316,7 +318,7 @@ loadSession dir = liftIO $ do -- which contains both. packageSetup <- return $ \(hieYaml, cfp, opts) -> do -- Parse DynFlags for the newly discovered component - hscEnv <- emptyHscEnv + hscEnv <- emptyHscEnv nc (df, targets) <- evalGhcEnv hscEnv $ do setOptions opts (hsc_dflags hscEnv) dep_info <- getDependencyInfo (componentDependencies opts) @@ -347,9 +349,7 @@ loadSession dir = liftIO $ do -- It's important to keep the same NameCache though for reasons -- that I do not fully understand print ("Making new HscEnv" ++ (show inplace)) - hscEnv <- case oldDeps of - Nothing -> emptyHscEnv - Just (old_hsc, _) -> setNameCache (hsc_NC old_hsc) <$> emptyHscEnv + hscEnv <- emptyHscEnv nc newHscEnv <- -- Add the options for the current component to the HscEnv evalGhcEnv hscEnv $ do @@ -357,11 +357,11 @@ loadSession dir = liftIO $ do getSession -- Modify the map so the hieYaml now maps to the newly created -- HscEnv - -- Returns: - -- * The new HscEnv so it can be used to modify the + -- Returns + -- * the new HscEnv so it can be used to modify the -- FilePath -> HscEnv map - -- * The information for the new component which caused this cache miss - -- * The modified information (without -inplace flags) for + -- * The information for the new component which caused this cache miss + -- * The modified information (without -inplace flags) for -- existing packages pure (Map.insert hieYaml (newHscEnv, new_deps) m, (newHscEnv, head new_deps', tail new_deps')) @@ -382,7 +382,7 @@ loadSession dir = liftIO $ do let hscEnv' = hscEnv { hsc_dflags = df , hsc_IC = (hsc_IC hscEnv) { ic_dflags = df } } - versionMismatch <- evalGhcEnv hscEnv' checkGhcVersion + versionMismatch <- checkGhcVersion henv <- case versionMismatch of Just mismatch -> return mismatch Nothing -> newHscEnvEq hscEnv' uids @@ -590,12 +590,17 @@ getCacheDir opts = IO.getXdgDirectory IO.XdgCache (cacheDir opts_hash) cacheDir :: String cacheDir = "ghcide" -compileTimeGhcVersion :: Version -compileTimeGhcVersion = $$(compileTimeVersionFromLibdir getLibdir) +ghcVersionChecker :: IO VersionCheck +ghcVersionChecker = $$(makeGhcVersionChecker (pure <$> getLibdir)) -checkGhcVersion :: Ghc (Maybe HscEnvEq) +checkGhcVersion :: IO (Maybe HscEnvEq) checkGhcVersion = do - v <- runTimeVersion - return $ if v == Just compileTimeGhcVersion - then Nothing - else Just GhcVersionMismatch {compileTime = compileTimeGhcVersion, runTime = v} + res <- ghcVersionChecker + case res of + Failure err -> do + putStrLn $ "Error while checking GHC version: " ++ show err + return Nothing + Mismatch {..} -> + return $ Just GhcVersionMismatch {..} + _ -> + return Nothing diff --git a/ghcide b/ghcide index 174b17c006..6c72c5f6e5 160000 --- a/ghcide +++ b/ghcide @@ -1 +1 @@ -Subproject commit 174b17c0064d0fde72d1b0313572ad0c389ec263 +Subproject commit 6c72c5f6e54b6032444ff1930f4f56e8b4641d6d diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index 0039392ae8..b3453f3d06 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -152,7 +152,7 @@ executable haskell-language-server -- which works for now. , ghc -------------------------------------------------------------- - , ghc-check ^>= 0.1 + , ghc-check >= 0.3.0.1 , ghc-paths , ghcide , gitrev diff --git a/stack-8.6.4.yaml b/stack-8.6.4.yaml index 9b34fc0c25..dae50795f8 100644 --- a/stack-8.6.4.yaml +++ b/stack-8.6.4.yaml @@ -17,7 +17,7 @@ extra-deps: - extra-1.6.21 - floskell-0.10.2 - fuzzy-0.1.0.0 -- ghc-check-0.1.0.3 +- ghc-check-0.3.0.1 - ghc-exactprint-0.6.2 # for HaRe - ghc-lib-parser-8.10.1.20200412 - ghc-lib-parser-ex-8.10.0.4 @@ -26,9 +26,7 @@ extra-deps: - haskell-lsp-0.22.0.0 - haskell-lsp-types-0.22.0.0 - haskell-src-exts-1.21.1 -# - hie-bios-0.4.0 -- github: mpickering/hie-bios - commit: 501cc337691cc9da45ff12db46d8b3af9a2a0eda +- hie-bios-0.5.0 - hlint-2.2.8 - hoogle-5.0.17.11 - hsimport-0.11.0 diff --git a/stack-8.6.5.yaml b/stack-8.6.5.yaml index 9cbcd4b061..5e12e2bf35 100644 --- a/stack-8.6.5.yaml +++ b/stack-8.6.5.yaml @@ -7,24 +7,24 @@ packages: extra-deps: - ansi-terminal-0.10.2 - base-compat-0.11.0 +- brittany-0.12.1.1 +- butcher-1.3.3.1 # - cabal-helper-1.0.0.0 - github: DanielG/cabal-helper commit: 5b85a4b9e1c6463c94ffa595893ad02c9a3d2ec3 - cabal-plan-0.6.2.0 - clock-0.7.2 +- extra-1.7.1 - floskell-0.10.2 -# - ghcide-0.1.0 -- extra-1.6.21 - fuzzy-0.1.0.0 -- ghc-check-0.1.0.3 +# - ghcide-0.1.0 +- ghc-check-0.3.0.1 - ghc-lib-parser-8.10.1.20200412 - ghc-lib-parser-ex-8.10.0.4 - haddock-library-1.8.0 - haskell-lsp-0.22.0.0 - haskell-lsp-types-0.22.0.0 -# - hie-bios-0.4.0 -- github: mpickering/hie-bios - commit: f0abff9c855ea7e6624617df669825f3f62f723b +- hie-bios-0.5.0 - indexed-profunctors-0.1 - lsp-test-0.10.3.0 - monad-dijkstra-0.1.1.2 @@ -36,9 +36,9 @@ extra-deps: - regex-base-0.94.0.0 - regex-pcre-builtin-0.95.1.1.8.43 - regex-tdfa-1.3.1.0 +- semialign-1.1 - github: wz1000/shake commit: fb3859dca2e54d1bbb2c873e68ed225fa179fbef -- semialign-1.1 - tasty-rerun-1.1.17 - temporary-1.2.1.1 - topograph-1 diff --git a/stack-8.8.2.yaml b/stack-8.8.2.yaml index e8370f31a3..5013e314e2 100644 --- a/stack-8.8.2.yaml +++ b/stack-8.8.2.yaml @@ -14,16 +14,14 @@ extra-deps: - constrained-dynamic-0.1.0.0 - floskell-0.10.2 # - ghcide-0.1.0 -- ghc-check-0.1.0.3 +- ghc-check-0.3.0.1 - ghc-lib-parser-8.10.1.20200412 - ghc-lib-parser-ex-8.10.0.4 - haddock-library-1.8.0 - haskell-lsp-0.22.0.0 - haskell-lsp-types-0.22.0.0 - haskell-src-exts-1.21.1 -# - hie-bios-0.4.0 -- github: mpickering/hie-bios - commit: 501cc337691cc9da45ff12db46d8b3af9a2a0eda +- hie-bios-0.5.0 - hlint-2.2.8 - hoogle-5.0.17.11 - hsimport-0.11.0 diff --git a/stack-8.8.3.yaml b/stack-8.8.3.yaml index a61da1952f..ba65f75a92 100644 --- a/stack-8.8.3.yaml +++ b/stack-8.8.3.yaml @@ -14,16 +14,14 @@ extra-deps: - constrained-dynamic-0.1.0.0 - floskell-0.10.2 # - ghcide-0.1.0 -- ghc-check-0.1.0.3 +- ghc-check-0.3.0.1 - ghc-lib-parser-8.10.1.20200412 - ghc-lib-parser-ex-8.10.0.4 - haddock-library-1.8.0 - haskell-lsp-0.22.0.0 - haskell-lsp-types-0.22.0.0 - haskell-src-exts-1.21.1 -# - hie-bios-0.4.0 -- github: mpickering/hie-bios - commit: 501cc337691cc9da45ff12db46d8b3af9a2a0eda +- hie-bios-0.5.0 - hlint-2.2.8 - hoogle-5.0.17.11 - hsimport-0.11.0 diff --git a/stack.yaml b/stack.yaml index e69801bdb5..5e12e2bf35 100644 --- a/stack.yaml +++ b/stack.yaml @@ -7,23 +7,24 @@ packages: extra-deps: - ansi-terminal-0.10.2 - base-compat-0.11.0 +- brittany-0.12.1.1 +- butcher-1.3.3.1 # - cabal-helper-1.0.0.0 - github: DanielG/cabal-helper commit: 5b85a4b9e1c6463c94ffa595893ad02c9a3d2ec3 - cabal-plan-0.6.2.0 - clock-0.7.2 +- extra-1.7.1 - floskell-0.10.2 - fuzzy-0.1.0.0 # - ghcide-0.1.0 -- ghc-check-0.1.0.3 +- ghc-check-0.3.0.1 - ghc-lib-parser-8.10.1.20200412 - ghc-lib-parser-ex-8.10.0.4 - haddock-library-1.8.0 - haskell-lsp-0.22.0.0 - haskell-lsp-types-0.22.0.0 -# - hie-bios-0.4.0 -- github: mpickering/hie-bios - commit: 501cc337691cc9da45ff12db46d8b3af9a2a0eda +- hie-bios-0.5.0 - indexed-profunctors-0.1 - lsp-test-0.10.3.0 - monad-dijkstra-0.1.1.2